Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sync start from certain evm height #170

Merged
merged 4 commits into from
Jan 12, 2024

Conversation

yarkinwho
Copy link
Contributor

Remove support for start from certain eos id functionality.

Resolve #151

@yarkinwho yarkinwho requested a review from elmato December 26, 2023 02:42
@@ -136,13 +136,16 @@ class engine_plugin_impl : std::enable_shared_from_this<engine_plugin_impl> {
return silkworm::db::read_canonical_header(txn, head_num);
}

std::optional<silkworm::Block> get_head_block() {
std::optional<silkworm::Block> get_head_block(uint64_t override_height) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should change this function name to something like get_canonical_block_at_height, and use a optional<uint64_t> as a parameter. If it has no value, then use current head

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -29,21 +29,19 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu
using native_block_t = channels::native_block;
static constexpr eosio::name pushtx = eosio::name("pushtx");

void init(std::string h, std::string p, eosio::name ca,
std::optional<eosio::checksum256> start_block_id, int64_t start_block_timestamp,
void init(std::string h, std::string p, eosio::name ca, uint64_t input_start_height,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also move to use std::optional<uint64_t> here for input_start_height

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -21,7 +21,7 @@ class ship_receiver_plugin : public appbase::plugin<ship_receiver_plugin> {
void plugin_startup();
void plugin_shutdown();

std::optional<channels::native_block> get_start_from_block();
uint64_t get_start_from_canonical_height();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

when overriding height when fetching header blocks.
@yarkinwho
Copy link
Contributor Author

please note that the logic for get_head_block is also changed a little bit:

Now we will not try fetch canonical header at all if the override option is present. <- The overriding is meant to fix the db anyway, so we should give it a try.

@yarkinwho yarkinwho requested a review from elmato January 9, 2024 07:00
std::optional<silkworm::Block> get_head_block() {
auto header = get_head_canonical_header();
if(!header) return {};
std::optional<silkworm::Block> get_canonical_block_at_height(const std::optional<uint64_t>& override_height) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override_height => height

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also for small types (uint64_t) we can pass std::optional by value.

std::optional<silkworm::Block> get_canonical_block_at_height(std::optional<uint64_t> height)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

std::optional<silkworm::Block> engine_plugin::get_head_block() {
return my->get_head_block();
std::optional<silkworm::Block> engine_plugin::get_canonical_block_at_height(const std::optional<uint64_t>& override_height) {
return my->get_canonical_block_at_height(override_height);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -22,7 +22,7 @@ class engine_plugin : public appbase::plugin<engine_plugin> {
uint32_t get_threads() const;
std::string get_chain_data_dir() const;
std::optional<silkworm::BlockHeader> get_head_canonical_header();
std::optional<silkworm::Block> get_head_block();
std::optional<silkworm::Block> get_canonical_block_at_height(const std::optional<uint64_t>& override_height);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -29,21 +29,19 @@ class ship_receiver_plugin_impl : std::enable_shared_from_this<ship_receiver_plu
using native_block_t = channels::native_block;
static constexpr eosio::name pushtx = eosio::name("pushtx");

void init(std::string h, std::string p, eosio::name ca,
std::optional<eosio::checksum256> start_block_id, int64_t start_block_timestamp,
void init(std::string h, std::string p, eosio::name ca, const std::optional<uint64_t>& input_start_height,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<< "#" << *start_from_canonical_height;
}

auto head_block = appbase::app().get_plugin<engine_plugin>().get_canonical_block_at_height(start_from_canonical_height);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not head_block anymore, it could be a specific height or the head of the chain. We should change it to start_block or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

nb.block_num = utils::to_block_num(*start_from_block_id);
return nb;
}
const std::optional<uint64_t>& get_start_from_canonical_height() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::optional<uint64_t>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -481,6 +468,7 @@ void ship_receiver_plugin::plugin_shutdown() {
SILK_INFO << "Shutdown SHiP Receiver";
}

std::optional<channels::native_block> ship_receiver_plugin::get_start_from_block() {
return my->get_start_from_block();
const std::optional<uint64_t>& ship_receiver_plugin::get_start_from_canonical_height() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::optional<uint64_t>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -21,7 +21,7 @@ class ship_receiver_plugin : public appbase::plugin<ship_receiver_plugin> {
void plugin_startup();
void plugin_shutdown();

std::optional<channels::native_block> get_start_from_block();
const std::optional<uint64_t>& get_start_from_canonical_height();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -46,7 +46,8 @@ class block_conversion_plugin_impl : std::enable_shared_from_this<block_conversi
}

void load_head() {
auto head_block = appbase::app().get_plugin<engine_plugin>().get_head_block();
const std::optional<uint64_t>& start_from_canonical_height = appbase::app().get_plugin<ship_receiver_plugin>().get_start_from_canonical_height();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto can be used here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@yarkinwho yarkinwho merged commit 960c6e7 into main Jan 12, 2024
6 checks passed
@yarkinwho yarkinwho deleted the yarkin/ship-start-from-new branch January 12, 2024 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate why the mechanism to start EOS EVM Node from a specific block doesn’t work
2 participants