Skip to content

Commit

Permalink
Merge pull request #1 from eosnetworkfoundation/elmato/dev
Browse files Browse the repository at this point in the history
Many fixes
  • Loading branch information
yarkinwho committed Jul 7, 2023
2 parents 21ca81e + cb5a0d1 commit b687cd7
Show file tree
Hide file tree
Showing 29 changed files with 9,093 additions and 14 deletions.
25 changes: 15 additions & 10 deletions src/blockchain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <map>
#include <string>

#include <silkworm/node/stagedsync/types.hpp>
#include <silkworm/node/stagedsync/execution_engine.hpp>

using sys = sys_plugin;
Expand All @@ -18,18 +19,22 @@ class blockchain_plugin_impl : std::enable_shared_from_this<blockchain_plugin_im
node_settings = appbase::app().get_plugin<engine_plugin>().get_node_settings();
SILK_INFO << "Using DB environment at location : " << node_settings->data_directory->chaindata().path().string();

exec_engine = std::make_unique<silkworm::stagedsync::ExecutionEngine>(appbase::app().get_io_context(), *node_settings, silkworm::db::RWAccess{*db_env});
exec_engine->open();

evm_blocks_subscription = appbase::app().get_channel<channels::evm_blocks>().subscribe(
[this](auto b) {
[this](auto new_block) {
try {
// //SILK_INFO << "EVM Block " << b->header.number;
exec_engine->insert_block(b);
static size_t block_count{0};

SILK_DEBUG << "EVM Block " << new_block->header.number;
if(!exec_engine) {
exec_engine = std::make_unique<silkworm::stagedsync::ExecutionEngine>(appbase::app().get_io_context(), *node_settings, silkworm::db::RWAccess{*db_env});
exec_engine->open();
}

// if( exec_engine->get_state() == silkworm::Worker::State::kStopped ) {
// appbase::app().quit();
// }
exec_engine->insert_block(new_block);
if(!(++block_count % 5000) || !new_block->irreversible) {
exec_engine->verify_chain(new_block->header.hash());
block_count=0;
}
} catch (const mdbx::exception& ex) {
SILK_CRIT << "CALLBACK ERR1" << std::string(ex.what());
} catch (const std::exception& ex) {
Expand Down Expand Up @@ -72,4 +77,4 @@ void blockchain_plugin::plugin_startup() {
void blockchain_plugin::plugin_shutdown() {
my->shutdown();
SILK_INFO << "Shutdown Blockchain plugin";
}
}
6 changes: 5 additions & 1 deletion src/engine_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ class engine_plugin_impl : std::enable_shared_from_this<engine_plugin_impl> {
node_settings.chain_config = silkworm::db::read_chain_config(txn);
node_settings.network_id = node_settings.chain_config->chain_id;


// Load genesis_hash
node_settings.chain_config->genesis_hash = silkworm::db::read_canonical_header_hash(txn, 0);
if (!node_settings.chain_config->genesis_hash.has_value())
throw std::runtime_error("Could not load genesis hash");

auto sentry = std::make_shared<nopsentry>();
eth.reset(new silkworm::EthereumBackEnd(node_settings, &db_env, sentry));
eth->set_node_name("EOS EVM Node");
Expand Down
5 changes: 3 additions & 2 deletions src/rpc_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ void rpc_plugin::plugin_initialize( const appbase::variables_map& options ) try
.log_verbosity = log_level
},
.context_pool_settings = silkworm::concurrency::ContextPoolSettings{},
.datadir = node_settings.data_directory->chaindata().path().string(),
.datadir = data_dir,
.eth_end_point = http_port,
.engine_end_point = engine_port,
.eth_api_spec = options.at("api-spec").as<std::string>(),
.private_api_addr = node_port,
.num_workers = threads
.num_workers = threads,
.skip_protocol_check = true
};

my.reset(new rpc_plugin_impl(settings));
Expand Down
33 changes: 33 additions & 0 deletions tests/antelope_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
def convert_name_to_value(name):
def value_of_char(c: str):
assert len(c) == 1
if c >= 'a' and c <= 'z':
return ord(c) - ord('a') + 6
if c >= '1' and c <= '5':
return ord(c) - ord('1') + 1
if c == '.':
return 0
raise ValueError("invalid Antelope name: character '{0}' is not allowed".format(c))

name_length = len(name)

if name_length > 13:
raise ValueError("invalid Antelope name: cannot exceed 13 characters")

thirteen_char_value = 0
if name_length == 13:
thirteen_char_value = value_of_char(name[12])
if thirteen_char_value > 15:
raise ValueError("invalid Antelope name: 13th character cannot be letter past j")

normalized_name = name[:12].ljust(12,'.') # truncate/extend to at exactly 12 characters since the 13th character is handled differently

def convert_to_value(str):
value = 0
for c in str:
value <<= 5
value |= value_of_char(c)

return value

return (convert_to_value(normalized_name) << 4) | thirteen_char_value
Loading

0 comments on commit b687cd7

Please sign in to comment.