Skip to content

Commit

Permalink
feat: statelessnet protocol (#10518)
Browse files Browse the repository at this point in the history
Set special protocol feature and version to launch
near/near-one-project-tracking#20 against.

---------

Co-authored-by: Longarithm <the.aleksandr.logunov@gmail.com>
  • Loading branch information
Longarithm and Looogarithm authored Jan 29, 2024
1 parent 84b4559 commit abb2b28
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 4 deletions.
3 changes: 3 additions & 0 deletions chain/jsonrpc/jsonrpc-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ nightly_protocol = [
"near-primitives/nightly_protocol",
"near-store/nightly_protocol",
]
statelessnet_protocol = [
"near-primitives/statelessnet_protocol",
]
sandbox = ["near-jsonrpc/sandbox"]
2 changes: 1 addition & 1 deletion chain/jsonrpc/jsonrpc-tests/tests/rpc_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ fn test_validators_ordered() {
fn test_genesis_config() {
test_with_client!(test_utils::NodeType::NonValidator, client, async move {
let genesis_config = client.EXPERIMENTAL_genesis_config().await.unwrap();
if !cfg!(feature = "nightly_protocol") {
if !cfg!(feature = "nightly_protocol") && !cfg!(feature = "statelessnet_protocol") {
assert_eq!(
genesis_config["protocol_version"].as_u64().unwrap(),
near_primitives::version::PROTOCOL_VERSION as u64
Expand Down
2 changes: 2 additions & 0 deletions core/primitives-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ nightly = [

nightly_protocol = [
]

statelessnet_protocol = []
9 changes: 7 additions & 2 deletions core/primitives-core/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,16 @@ impl ProtocolFeature {
| ProtocolFeature::TestnetFewerBlockProducers
| ProtocolFeature::SimpleNightshadeV2 => 64,

// StatelessNet features
ProtocolFeature::ChunkValidation => 80,

// Nightly features
#[cfg(feature = "protocol_feature_fix_staking_threshold")]
ProtocolFeature::FixStakingThreshold => 126,
#[cfg(feature = "protocol_feature_fix_contract_loading_cost")]
ProtocolFeature::FixContractLoadingCost => 129,
#[cfg(feature = "protocol_feature_reject_blocks_with_outdated_protocol_version")]
ProtocolFeature::RejectBlocksWithOutdatedProtocolVersions => 132,
ProtocolFeature::ChunkValidation => 137,
ProtocolFeature::EthImplicitAccounts => 138,
}
}
Expand All @@ -196,7 +198,10 @@ impl ProtocolFeature {
const STABLE_PROTOCOL_VERSION: ProtocolVersion = 64;

/// Largest protocol version supported by the current binary.
pub const PROTOCOL_VERSION: ProtocolVersion = if cfg!(feature = "nightly_protocol") {
pub const PROTOCOL_VERSION: ProtocolVersion = if cfg!(feature = "statelessnet_protocol") {
// Current StatelessNet protocol version.
80
} else if cfg!(feature = "nightly_protocol") {
// On nightly, pick big enough version to support all features.
139
} else {
Expand Down
5 changes: 5 additions & 0 deletions core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ nightly_protocol = [
"near-primitives-core/nightly_protocol",
"near-vm-runner/nightly_protocol",
]

statelessnet_protocol = [
"near-primitives-core/statelessnet_protocol",
]

new_epoch_sync = []


Expand Down
3 changes: 3 additions & 0 deletions neard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ nightly_protocol = [
"near-undo-block/nightly_protocol",
"nearcore/nightly_protocol",
]
statelessnet_protocol = [
"near-primitives/statelessnet_protocol",
]

calimero_zero_storage = [
"near-primitives/calimero_zero_storage",
Expand Down
3 changes: 2 additions & 1 deletion neard/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ pub(super) struct InitCmd {
fn check_release_build(chain: &str) {
let is_release_build = option_env!("NEAR_RELEASE_BUILD") == Some("release")
&& !cfg!(feature = "nightly")
&& !cfg!(feature = "nightly_protocol");
&& !cfg!(feature = "nightly_protocol")
&& !cfg!(feature = "statelessnet_protocol");
if !is_release_build
&& [near_primitives::chains::MAINNET, near_primitives::chains::TESTNET].contains(&chain)
{
Expand Down

0 comments on commit abb2b28

Please sign in to comment.