Skip to content

Commit

Permalink
Merge pull request #134 from AdminXeq/sn_reg
Browse files Browse the repository at this point in the history
Service Node Registration fixes. This fix is MANDATORY and required. Hard-Fork v16 ( ~10/01/2023 ) is set for it
  • Loading branch information
AdminXeq committed Jan 6, 2023
2 parents ff56822 + 9beb6ff commit 13b7887
Show file tree
Hide file tree
Showing 36 changed files with 673 additions and 601 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -26,7 +26,7 @@ Use-cases span from stablecoins to eSports

# General Information
Copyright (c) 2014-2019 The Monero Project.
Copyright (c) 2018-2022 Project Triton/Equilibria.
Copyright (c) 2018-2023 Project Triton/Equilibria.
Portions Copyright (c) 2012-2013 The Cryptonote developers.

## Current maintainer
Expand Down Expand Up @@ -116,7 +116,7 @@ invokes cmake commands as needed.
* Change to the root of the source code directory, change to the most recent release branch, and build:

cd equilibria
git checkout v14.1.0
git checkout v16
make

*Optional*: If your machine has several cores and enough memory, enable
Expand Down Expand Up @@ -205,17 +205,18 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (

* If using an external hard disk without an external power supply, ensure it gets enough power to avoid hardware issues when syncing, by adding the line "max_usb_current=1" to /boot/config.txt

* Clone monero and checkout the most recent release version:
* Clone Equilibria and checkout the most recent release version:

```bash
git clone https://github.com/equilibriacc/equilibria.git
cd equilibria
git checkout tags/v14.1.0
git checkout v16
```

* Build:

```bash
git submodule init && git submodule update
make release
```

Expand Down Expand Up @@ -323,7 +324,7 @@ application.

cd equilibria

git checkout v14.1.0
git checkout v16

* If you are on a 64-bit system, run:

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -133,6 +133,7 @@ if(NOT IOS)
add_subdirectory(simplewallet)
add_subdirectory(daemonizer)
add_subdirectory(daemon)
#add_subdirectory(blockchain_utilities)
endif()

if(BUILD_DEBUG_UTILITIES)
Expand Down
2 changes: 1 addition & 1 deletion src/blockchain_db/lmdb/db_lmdb.cpp
Expand Up @@ -788,7 +788,7 @@ void BlockchainLMDB::add_block(const block& blk, size_t block_weight, uint64_t l
bi.bi_diff_lo = (cumulative_difficulty & 0xffffffffffffffff).convert_to<uint64_t>();
bi.bi_hash = blk_hash;
bi.bi_cum_rct = num_rct_outs;
if (blk.major_version >= 8)
if (blk.major_version >= 4)
{
uint64_t last_height = m_height-1;
MDB_val_set(h, last_height);
Expand Down
21 changes: 4 additions & 17 deletions src/blockchain_utilities/blockchain_ancestry.cpp
Expand Up @@ -28,6 +28,7 @@

#include <unordered_map>
#include <unordered_set>
#include <boost/filesystem.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/archive/portable_binary_iarchive.hpp>
Expand All @@ -36,9 +37,8 @@
#include "common/command_line.h"
#include "common/varint.h"
#include "cryptonote_basic/cryptonote_boost_serialization.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_objects.h"
#include "blockchain_db/blockchain_db.h"
#include "version.h"

Expand Down Expand Up @@ -448,21 +448,8 @@ int main(int argc, char* argv[])
// because unlike blockchain_storage constructor, which takes a pointer to
// tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
// This is done this way because of the circular constructors.
struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};

BlockchainObjects *blockchain_objects = new BlockchainObjects();
Blockchain *core_storage = &blockchain_objects->m_blockchain;
blockchain_objects_t blockchain_objects = {};
Blockchain *core_storage = &blockchain_objects.m_blockchain;
BlockchainDB *db = new_db();
if (db == NULL)
{
Expand Down
10 changes: 8 additions & 2 deletions src/blockchain_utilities/blockchain_blackball.cpp
Expand Up @@ -35,9 +35,8 @@
#include "common/varint.h"
#include "serialization/crypto.h"
#include "cryptonote_basic/cryptonote_boost_serialization.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_objects.h"
#include "blockchain_db/blockchain_db.h"
#include "wallet/ringdb.h"
#include "version.h"
Expand Down Expand Up @@ -1266,6 +1265,13 @@ int main(int argc, char* argv[])
return 1;
}

std::vector<Blockchain*> core_storage(inputs.size());
for (size_t n = 0; n < inputs.size(); ++n)
{
blockchain_objects_t *blockchain_objects = new blockchain_objects_t();
core_storage[n] = &(blockchain_objects->m_blockchain);
}

const std::string cache_dir = (output_file_path / "spent-outputs-cache").string();
init(cache_dir);

Expand Down
20 changes: 3 additions & 17 deletions src/blockchain_utilities/blockchain_depth.cpp
Expand Up @@ -30,9 +30,8 @@
#include <boost/algorithm/string.hpp>
#include "common/command_line.h"
#include "common/varint.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_objects.h"
#include "blockchain_db/blockchain_db.h"
#include "version.h"

Expand Down Expand Up @@ -135,21 +134,8 @@ int main(int argc, char* argv[])
// because unlike blockchain_storage constructor, which takes a pointer to
// tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
// This is done this way because of the circular constructors.
struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};

BlockchainObjects *blockchain_objects = new BlockchainObjects();
Blockchain *core_storage = &blockchain_objects->m_blockchain;
blockchain_objects_t blockchain_objects = {};
Blockchain *core_storage = &blockchain_objects.m_blockchain;
BlockchainDB *db = new_db();
if (db == NULL)
{
Expand Down
32 changes: 4 additions & 28 deletions src/blockchain_utilities/blockchain_export.cpp
Expand Up @@ -29,9 +29,8 @@
#include "bootstrap_file.h"
#include "blocksdat_file.h"
#include "common/command_line.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "blockchain_db/blockchain_db.h"
#include "blockchain_objects.h"
#include "version.h"

#undef MONERO_DEFAULT_LOG_CATEGORY
Expand Down Expand Up @@ -120,33 +119,10 @@ int main(int argc, char* argv[])
output_file_path = boost::filesystem::path(m_config_folder) / "export" / BLOCKCHAIN_RAW;
LOG_PRINT_L0("Export output file: " << output_file_path.string());

// If we wanted to use the memory pool, we would set up a fake_core.

// Use Blockchain instead of lower-level BlockchainDB for two reasons:
// 1. Blockchain has the init() method for easy setup
// 2. exporter needs to use get_current_blockchain_height(), get_block_id_by_height(), get_block_by_hash()
//
// cannot match blockchain_storage setup above with just one line,
// e.g.
// Blockchain* core_storage = new Blockchain(NULL);
// because unlike blockchain_storage constructor, which takes a pointer to
// tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};
BlockchainObjects* blockchain_objects = new BlockchainObjects();
Blockchain* core_storage = &(blockchain_objects->m_blockchain);

BlockchainDB* db = new_db();
blockchain_objects_t blockchain_objects = {};
Blockchain *core_storage = &blockchain_objects.m_blockchain;
BlockchainDB *db = new_db();
if (db == NULL)
{
LOG_ERROR("Failed to initialize a database");
Expand Down
4 changes: 2 additions & 2 deletions src/blockchain_utilities/blockchain_import.cpp
Expand Up @@ -715,9 +715,9 @@ int main(int argc, char* argv[])
"This is a DANGEROUS operation: if the file was tampered with in transit, or obtained from a malicious source,\n"
"you could end up with a compromised database. It is recommended to NOT use " << arg_noverify.name << ".\n"
"*****************************************************************************************\n"
"You have 90 seconds to press ^C or terminate this program before unverified import starts\n"
"You have 10 seconds to press ^C or terminate this program before unverified import starts\n"
"*****************************************************************************************");
sleep(90);
sleep(10);
}

cryptonote::cryptonote_protocol_stub pr; //TODO: stub only for this kind of test, make real validation of relayed objects
Expand Down
21 changes: 21 additions & 0 deletions src/blockchain_utilities/blockchain_objects.h
@@ -0,0 +1,21 @@
#ifndef BLOCKCHAIN_OBJECTS_H
#define BLOCKCHAIN_OBJECTS_H

#include "cryptonote_core/blockchain.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/service_node_list.h"
#include "cryptonote_core/service_node_deregister.h"

struct blockchain_objects_t
{
cryptonote::Blockchain m_blockchain;
cryptonote::tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
blockchain_objects_t() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};

#endif // BLOCKCHAIN_OBJECTS_H
18 changes: 3 additions & 15 deletions src/blockchain_utilities/blockchain_prune.cpp
Expand Up @@ -35,6 +35,7 @@
#include "cryptonote_core/blockchain.h"
#include "blockchain_db/blockchain_db.h"
#include "blockchain_db/lmdb/db_lmdb.h"
#include "blockchain_objects.h"
#include "version.h"

#undef MONERO_DEFAULT_LOG_CATEGORY
Expand Down Expand Up @@ -521,28 +522,15 @@ int main(int argc, char* argv[])
// because unlike blockchain_storage constructor, which takes a pointer to
// tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
MINFO("Initializing source blockchain (BlockchainDB)");

struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};
std::array<Blockchain *, 2> core_storage;
boost::filesystem::path paths[2];

bool already_pruned = false;
for (size_t n = 0; n < core_storage.size(); ++n)
{
BlockchainObjects *blockchain_objects = new BlockchainObjects();
blockchain_objects_t *blockchain_objects = new blockchain_objects_t();
core_storage[n] = &(blockchain_objects->m_blockchain);

BlockchainDB* db = new_db();
BlockchainDB *db = new_db();
if (db == NULL)
{
MERROR("Failed to initialize a database");
Expand Down
21 changes: 4 additions & 17 deletions src/blockchain_utilities/blockchain_prune_known_spent_data.cpp
Expand Up @@ -29,9 +29,8 @@
#include <boost/algorithm/string.hpp>
#include "common/command_line.h"
#include "serialization/crypto.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_objects.h"
#include "blockchain_db/blockchain_db.h"
#include "version.h"

Expand Down Expand Up @@ -160,21 +159,9 @@ int main(int argc, char* argv[])
const std::string input = command_line::get_arg(vm, arg_input);

LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};
BlockchainObjects* blockchain_objects = new BlockchainObjects();
Blockchain* core_storage = &(blockchain_objects->m_blockchain);

BlockchainDB* db = new_db();
blockchain_objects_t blockchain_objects = {};
Blockchain *core_storage = &blockchain_objects.m_blockchain;
BlockchainDB *db = new_db();
if (db == NULL)
{
LOG_ERROR("Failed to initialize a database");
Expand Down
19 changes: 3 additions & 16 deletions src/blockchain_utilities/blockchain_stats.cpp
Expand Up @@ -30,9 +30,8 @@
#include "common/command_line.h"
#include "common/varint.h"
#include "cryptonote_basic/cryptonote_boost_serialization.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_objects.h"
#include "blockchain_db/blockchain_db.h"
#include "version.h"

Expand Down Expand Up @@ -122,20 +121,8 @@ int main(int argc, char* argv[])
bool do_hours = command_line::get_arg(vm, arg_hours);

LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};
BlockchainObjects* blockchain_objects = new BlockchainObjects();
Blockchain* core_storage;
core_storage = &(blockchain_objects->m_blockchain);
blockchain_objects_t blockchain_objects = {};
Blockchain *core_storage = &blockchain_objects.m_blockchain;
BlockchainDB *db = new_db();
if (db == NULL)
{
Expand Down
24 changes: 6 additions & 18 deletions src/blockchain_utilities/blockchain_usage.cpp
Expand Up @@ -30,9 +30,8 @@
#include <boost/algorithm/string.hpp>
#include "common/command_line.h"
#include "common/varint.h"
#include "cryptonote_core/tx_pool.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_core/blockchain.h"
#include "blockchain_objects.h"
#include "blockchain_db/blockchain_db.h"
#include "version.h"

Expand Down Expand Up @@ -150,22 +149,11 @@ int main(int argc, char* argv[])
// tx_memory_pool, Blockchain's constructor takes tx_memory_pool object.
LOG_PRINT_L0("Initializing source blockchain (BlockchainDB)");
const std::string input = command_line::get_arg(vm, arg_input);
// This is done this way because of the circular constructors.
struct BlockchainObjects
{
Blockchain m_blockchain;
tx_memory_pool m_mempool;
service_nodes::service_node_list m_service_node_list;
service_nodes::deregister_vote_pool m_deregister_vote_pool;
BlockchainObjects() :
m_blockchain(m_mempool, m_service_node_list, m_deregister_vote_pool),
m_service_node_list(m_blockchain),
m_mempool(m_blockchain) { }
};
BlockchainObjects* blockchain_objects = new BlockchainObjects();
Blockchain* core_storage;
core_storage = &(blockchain_objects->m_blockchain);
BlockchainDB* db = new_db();

blockchain_objects_t blockchain_objects = {};
Blockchain *core_storage = &blockchain_objects.m_blockchain;
tx_memory_pool& m_mempool = blockchain_objects.m_mempool;
BlockchainDB *db = new_db();
if (db == NULL)
{
LOG_ERROR("Attempted to use non-existent database type: LMDB");
Expand Down
Binary file modified src/blocks/checkpoints.dat
Binary file not shown.

0 comments on commit 13b7887

Please sign in to comment.