Skip to content

Commit

Permalink
Merge pull request #5461 from stacks-network/feat/sip-029
Browse files Browse the repository at this point in the history
feat/SIP-029
  • Loading branch information
wileyj authored Dec 6, 2024
2 parents 583b857 + e4a042b commit 8c99a12
Show file tree
Hide file tree
Showing 37 changed files with 1,229 additions and 83 deletions.
1 change: 1 addition & 0 deletions .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ jobs:
- tests::nakamoto_integrations::v3_signer_api_endpoint
- tests::nakamoto_integrations::test_shadow_recovery
- tests::nakamoto_integrations::signer_chainstate
- tests::nakamoto_integrations::sip029_coinbase_change
- tests::nakamoto_integrations::clarity_cost_spend_down
- tests::nakamoto_integrations::v3_blockbyheight_api_endpoint
# TODO: enable these once v1 signer is supported by a new nakamoto epoch
Expand Down
3 changes: 2 additions & 1 deletion clarity/src/vm/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ pub fn run_analysis(
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => {
TypeChecker2_1::run_pass(&epoch, &mut contract_analysis, db, build_type_map)
}
StacksEpochId::Epoch10 => {
Expand Down
6 changes: 4 additions & 2 deletions clarity/src/vm/analysis/type_checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ impl FunctionType {
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => self.check_args_2_1(accounting, args, clarity_version),
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => self.check_args_2_1(accounting, args, clarity_version),
StacksEpochId::Epoch10 => {
return Err(CheckErrors::Expects("Epoch10 is not supported".into()).into())
}
Expand All @@ -75,7 +76,8 @@ impl FunctionType {
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => {
self.check_args_by_allowing_trait_cast_2_1(db, clarity_version, func_args)
}
StacksEpochId::Epoch10 => {
Expand Down
3 changes: 2 additions & 1 deletion clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ impl LimitedCostTracker {
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => COSTS_3_NAME.to_string(),
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => COSTS_3_NAME.to_string(),
};
Ok(result)
}
Expand Down
2 changes: 2 additions & 0 deletions clarity/src/vm/functions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ macro_rules! switch_on_global_epoch {
StacksEpochId::Epoch25 => $Epoch205Version(args, env, context),
// Note: We reuse 2.05 for 3.0.
StacksEpochId::Epoch30 => $Epoch205Version(args, env, context),
// Note: We reuse 2.05 for 3.1.
StacksEpochId::Epoch31 => $Epoch205Version(args, env, context),
}
}
};
Expand Down
3 changes: 2 additions & 1 deletion clarity/src/vm/test_util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pub fn generate_test_burn_state_db(epoch_id: StacksEpochId) -> UnitTestBurnState
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => UnitTestBurnStateDB {
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => UnitTestBurnStateDB {
epoch_id,
ast_rules: ASTRules::PrecheckSize,
},
Expand Down
4 changes: 4 additions & 0 deletions clarity/src/vm/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ epochs_template! {
Epoch24,
Epoch25,
Epoch30,
Epoch31,
}

clarity_template! {
Expand All @@ -140,6 +141,9 @@ clarity_template! {
(Epoch30, Clarity1),
(Epoch30, Clarity2),
(Epoch30, Clarity3),
(Epoch31, Clarity1),
(Epoch31, Clarity2),
(Epoch31, Clarity3),
}

#[cfg(test)]
Expand Down
9 changes: 6 additions & 3 deletions clarity/src/vm/types/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ impl TypeSignature {
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => self.admits_type_v2_1(other),
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => self.admits_type_v2_1(other),
StacksEpochId::Epoch10 => {
return Err(CheckErrors::Expects("epoch 1.0 not supported".into()))
}
Expand Down Expand Up @@ -800,7 +801,8 @@ impl TypeSignature {
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => self.canonicalize_v2_1(),
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => self.canonicalize_v2_1(),
}
}

Expand Down Expand Up @@ -1158,7 +1160,8 @@ impl TypeSignature {
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24
| StacksEpochId::Epoch25
| StacksEpochId::Epoch30 => Self::least_supertype_v2_1(a, b),
| StacksEpochId::Epoch30
| StacksEpochId::Epoch31 => Self::least_supertype_v2_1(a, b),
StacksEpochId::Epoch10 => {
return Err(CheckErrors::Expects("epoch 1.0 not supported".into()))
}
Expand Down
1 change: 1 addition & 0 deletions clarity/src/vm/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ impl ClarityVersion {
StacksEpochId::Epoch24 => ClarityVersion::Clarity2,
StacksEpochId::Epoch25 => ClarityVersion::Clarity2,
StacksEpochId::Epoch30 => ClarityVersion::Clarity3,
StacksEpochId::Epoch31 => ClarityVersion::Clarity3,
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion stacks-common/src/libcommon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ pub mod consts {
pub const PEER_VERSION_EPOCH_2_4: u8 = 0x09;
pub const PEER_VERSION_EPOCH_2_5: u8 = 0x0a;
pub const PEER_VERSION_EPOCH_3_0: u8 = 0x0b;
pub const PEER_VERSION_EPOCH_3_1: u8 = 0x0c;

/// this should be updated to the latest network epoch version supported by
/// this node. this will be checked by the `validate_epochs()` method.
pub const PEER_NETWORK_EPOCH: u32 = PEER_VERSION_EPOCH_3_0 as u32;
pub const PEER_NETWORK_EPOCH: u32 = PEER_VERSION_EPOCH_3_1 as u32;

/// set the fourth byte of the peer version
pub const PEER_VERSION_MAINNET: u32 = PEER_VERSION_MAINNET_MAJOR | PEER_NETWORK_EPOCH;
Expand All @@ -93,6 +94,9 @@ pub mod consts {
/// network identifiers
pub const NETWORK_ID_MAINNET: u32 = 0x17000000;
pub const NETWORK_ID_TESTNET: u32 = 0xff000000;

/// number of uSTX per STX
pub const MICROSTACKS_PER_STACKS: u32 = 1_000_000;
}

/// This test asserts that the constant above doesn't change.
Expand Down
Loading

0 comments on commit 8c99a12

Please sign in to comment.