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

SC: SYNC_CALL protocol feature definition and registration #1222

Merged
merged 7 commits into from
Mar 3, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum class builtin_protocol_feature_t : uint32_t {
disable_deferred_trxs_stage_1 = 22,
disable_deferred_trxs_stage_2 = 23,
savanna = 24,
sync_call = 25,
reserved_private_fork_protocol_features = 500000,
};

Expand Down
11 changes: 11 additions & 0 deletions libraries/chain/protocol_feature_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,17 @@ host function call will trigger a transition to the Savanna consensus algorithm.
builtin_protocol_feature_t::disable_deferred_trxs_stage_2
}
} )
( builtin_protocol_feature_t::sync_call, builtin_protocol_feature_spec{
"SYNC_CALL",
fc::variant("49f6fbc4fee045bc5c8b09a96b2b5c096afdc320ac29b54e0f3805c660b88483").as<digest_type>(),
// SHA256 hash of the raw message below within the comment delimiters (exclude newline after /*) (do not modify message below).
/*
Builtin protocol feature: SYNC_CALL
Enables synchronous calls to functions in other and own contracts.
*/
{builtin_protocol_feature_t::savanna}
} )
;


Expand Down
26 changes: 26 additions & 0 deletions unittests/protocol_feature_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2316,4 +2316,30 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(set_finalizers_test, T, testers) { try {
c.error("alice does not have permission to call this API"));
} FC_LOG_AND_RETHROW() }

BOOST_AUTO_TEST_CASE(sync_call_activation_test) try {
tester c( setup_policy::preactivate_feature_and_new_bios );
const auto& pfm = c.control->get_protocol_feature_manager();

// Ensure SYNC_CALL not yet activated
BOOST_CHECK( !c.control->is_builtin_activated( builtin_protocol_feature_t::sync_call ) );

// Activate SYNC_CALL without the dependency met (it depends on SAVANNA).
auto d = pfm.get_builtin_digest( builtin_protocol_feature_t::sync_call );
BOOST_REQUIRE( d );
BOOST_CHECK_EXCEPTION( c.preactivate_protocol_features({ *d }),
protocol_feature_exception,
fc_exception_message_starts_with("not all dependencies of protocol feature with digest") );

// Activate the depending Savanna
c.preactivate_savanna_protocol_features();
c.produce_block();

// Activate SYNC_CALL after the dependency met
c.preactivate_protocol_features({ *d });
c.produce_block();

// Ensure SYNC_CALL is now activated
BOOST_CHECK( c.control->is_builtin_activated( builtin_protocol_feature_t::sync_call ) );
} FC_LOG_AND_RETHROW()

BOOST_AUTO_TEST_SUITE_END()
Loading