Skip to content

Conversation

@linh2931
Copy link
Contributor

@linh2931 linh2931 commented Mar 14, 2025

This PR introduces a new version of chain_config chain_config_v2 for sync call parameters: max_sync_call_depth and max_sync_call_data_size. They are on chain parameters and require BP agreement for changes.

A new version of snapshot (snapshot_v9) is required to accommodate chain_config_v2.

abieos needs to be updated AntelopeIO/abieos#39

Tests have been updated to verify the new parameters can be read and set.

Resolves #1256

@spoonincode
Copy link
Contributor

It looks like ship's ABI needs to have chain_config_v2 added. I think we can wait on touching abieos for now though, as long as we don't forget later.

I think snapshot version should be increased to v9 too due to chain_config_v2 too?

@linh2931
Copy link
Contributor Author

It looks like ship's ABI needs to have chain_config_v2 added. I think we can wait on touching abieos for now though, as long as we don't forget later.

I think snapshot version should be increased to v9 too due to chain_config_v2 too?

Thanks! Yes, snapshot version needs to be increased to v9. I will change ship and snapshot for now and create an issue for abieos so we won't forget.

@spoonincode
Copy link
Contributor

I noticed this will probably need to be changed to use chain_config_v1

struct snapshot_global_property_object_v5 {
// minimum_version and maximum_version refer to chain_snapshot_header
// version. snapshot_global_property_object_v5 applies to version 5 & 6
static constexpr uint32_t minimum_version = 5;
static constexpr uint32_t maximum_version = 6;
static_assert(chain_snapshot_header::minimum_compatible_version <= maximum_version,
"snapshot_global_property_object_v5 is no longer needed");
std::optional<block_num_type> proposed_schedule_block_num;
producer_authority_schedule proposed_schedule;
chain_config configuration;
chain_id_type chain_id;
kv_database_config kv_configuration;
wasm_config wasm_configuration;
};

I'm guessing we're also going to need to create a snapshot_global_property_object_v8 since the current serialized GPO has a chain_config_v1

@linh2931
Copy link
Contributor Author

It looks like ship's ABI needs to have chain_config_v2 added. I think we can wait on touching abieos for now though, as long as we don't forget later.
I think snapshot version should be increased to v9 too due to chain_config_v2 too?

Thanks! Yes, snapshot version needs to be increased to v9. I will change ship and snapshot for now and create an issue for abieos so we won't forget.

V9 snapshot: 35cee9e

@linh2931
Copy link
Contributor Author

I noticed this will probably need to be changed to use chain_config_v1

struct snapshot_global_property_object_v5 {
// minimum_version and maximum_version refer to chain_snapshot_header
// version. snapshot_global_property_object_v5 applies to version 5 & 6
static constexpr uint32_t minimum_version = 5;
static constexpr uint32_t maximum_version = 6;
static_assert(chain_snapshot_header::minimum_compatible_version <= maximum_version,
"snapshot_global_property_object_v5 is no longer needed");
std::optional<block_num_type> proposed_schedule_block_num;
producer_authority_schedule proposed_schedule;
chain_config configuration;
chain_id_type chain_id;
kv_database_config kv_configuration;
wasm_config wasm_configuration;
};

I'm guessing we're also going to need to create a snapshot_global_property_object_v8 since the current serialized GPO has a chain_config_v1

Thanks. Done in the snapshot commit aa28ece.

It seems the version numbers for Legacy snapshot_global_property_object grows sequentially. I named it snapshot_global_property_object_v6

@linh2931
Copy link
Contributor Author

It looks like ship's ABI needs to have chain_config_v2 added. I think we can wait on touching abieos for now though, as long as we don't forget later.
I think snapshot version should be increased to v9 too due to chain_config_v2 too?

Thanks! Yes, snapshot version needs to be increased to v9. I will change ship and snapshot for now and create an issue for abieos so we won't forget.

V9 snapshot: 35cee9e

SHiP ABI update: 2ffd898


friend inline bool operator != ( const chain_config_v2& lhs, const chain_config_v2& rhs ) {
return !(lhs == rhs);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

operator!= should not be needed with c++20.

Copy link
Contributor

@greg7mdp greg7mdp Mar 17, 2025

Choose a reason for hiding this comment

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

operator!= should not be needed with c++20.

No need to define operator ==() either when = default; is the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Removed.

93f0295

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need the = default still? I think this will skip equality check of v2 members as is

@spoonincode
Copy link
Contributor

btw I realize now that AntelopeIO/leap#1770 introduces an inconsistency. The premise is that we shouldn't return wasm_config unless the protocol feature is activated. ok sounds good. But we still always return max_action_return_value_size too -- even if that protocol feature is not enabled. This PR adds two more items returned even when their protocol feature is not activated.

I'm not sure what the right answer is.. we could potentially scrub the get_consensus_parameters reply for any config item related to an unactivated feature. That seems kinda hacky but would at least be consistent with AntelopeIO/leap#1770 and the confusion it solves.

@spoonincode
Copy link
Contributor

Also need to update this part of ship,

template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper_stateless<eosio::chain::chain_config>& obj) {

context.db.modify( context.control.get_global_properties(),
[&]( auto& gprops ) {
gprops.configuration = cfg;
gprops.configuration.copy_from_v0(cfg);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need an assignment operator from v0 that leaves v1 and v2 data alone?

This might be why. Does this change technically cause a consensus violation? The old code would leave max_action_return_value_size unchanged but this code will reset it to config::default_max_action_return_value_size. (I don't see any reason one can't call set_blockchain_parameters_packed() after activating ACTION_RETURN_VALUE)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Will revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to entirely revert but rather copy_from_v0() shouldn't stomp on v1 & v2 items.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to entirely revert

(pending the style question in the other thread)

@linh2931
Copy link
Contributor Author

Also need to update this part of ship,

template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper_stateless<eosio::chain::chain_config>& obj) {

Thanks. Done.

806fd71

@spoonincode
Copy link
Contributor

Also need to update this part of ship,

template <typename ST>
datastream<ST>& operator<<(datastream<ST>& ds, const history_serial_wrapper_stateless<eosio::chain::chain_config>& obj) {

Thanks. Done.

806fd71

This part needs to be changed to 2,


(it's manually encoding the variant index).

@linh2931
Copy link
Contributor Author

ebd7f51

Thank you so much for this! I did not notice that. ebd7f51

I have also added chain_config_v2 to abieos sync_call branch. Unit test test_deltas_global_property_history needs that.

Base automatically changed from call_implementation to sync_call March 27, 2025 11:52
// copy v0 fields
chain_config_v0::operator= (b);

// leave v1 and v2 fields alone as changing them might break cosensus
Copy link
Contributor

Choose a reason for hiding this comment

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

"consensus"

Copy link
Contributor Author

@linh2931 linh2931 Mar 28, 2025

Choose a reason for hiding this comment

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

Fixed by 30d934c

@linh2931
Copy link
Contributor Author

btw I realize now that AntelopeIO/leap#1770 introduces an inconsistency. The premise is that we shouldn't return wasm_config unless the protocol feature is activated. ok sounds good. But we still always return max_action_return_value_size too -- even if that protocol feature is not enabled. This PR adds two more items returned even when their protocol feature is not activated.

I'm not sure what the right answer is.. we could potentially scrub the get_consensus_parameters reply for any config item related to an unactivated feature. That seems kinda hacky but would at least be consistent with AntelopeIO/leap#1770 and the confusion it solves.

I created #1289 to track this.

auto genesis = eosio::chain::block_log::extract_genesis_state(source_log_dir);
std::filesystem::create_directories(config.blocks_dir);
std::filesystem::copy(source_log_dir / "blocks.log", config.blocks_dir / "blocks.log");
std::filesystem::copy(source_log_dir / "blocks.index", config.blocks_dir / "blocks.index");
Copy link
Contributor

Choose a reason for hiding this comment

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

The abieos submodule update should be via a PR to abieos. I don't see one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As the changes were small and I'd to have a quick test, I went ahead making the abieos changes in the sync_call branch. I will make sure all the future changes will be done from a branch created out of the sync_call branch.

Copy link
Contributor

@heifner heifner left a comment

Choose a reason for hiding this comment

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

Make sure to update to merged abieos commit.

@linh2931 linh2931 merged commit d390a3f into sync_call Mar 31, 2025
36 checks passed
@linh2931 linh2931 deleted the sync_call_limits branch March 31, 2025 19:31
@linh2931 linh2931 changed the title SC: Introduce chain_config_v2 for max_sync_call_depth and max_sync_call_data_size SC: Introduce chain_config_v2 and snapshot_v9 for max_sync_call_depth and max_sync_call_data_size Apr 3, 2025
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.

5 participants