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

Nakamoto staging blocks #3992

Merged
merged 11 commits into from
Oct 31, 2023
3 changes: 2 additions & 1 deletion clarity/src/vm/analysis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ pub fn run_analysis(
StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24 => {
| StacksEpochId::Epoch24
| StacksEpochId::Epoch30 => {
TypeChecker2_1::run_pass(&epoch, &mut contract_analysis, db)
}
StacksEpochId::Epoch10 => unreachable!("Epoch 1.0 is not a valid epoch for analysis"),
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::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24 => self.check_args_2_1(accounting, args, clarity_version),
| StacksEpochId::Epoch24
| StacksEpochId::Epoch30 => self.check_args_2_1(accounting, args, clarity_version),
StacksEpochId::Epoch10 => unreachable!("Epoch10 is not supported"),
}
}
Expand All @@ -71,7 +72,8 @@ impl FunctionType {
StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24 => {
| StacksEpochId::Epoch24
| StacksEpochId::Epoch30 => {
self.check_args_by_allowing_trait_cast_2_1(db, clarity_version, func_args)
}
StacksEpochId::Epoch10 => unreachable!("Epoch10 is not supported"),
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 @@ -723,7 +723,8 @@ impl LimitedCostTracker {
StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24 => COSTS_3_NAME.to_string(),
| StacksEpochId::Epoch24
| StacksEpochId::Epoch30 => COSTS_3_NAME.to_string(),
}
}
}
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 @@ -62,6 +62,8 @@ macro_rules! switch_on_global_epoch {
StacksEpochId::Epoch23 => $Epoch205Version(args, env, context),
// Note: We reuse 2.05 for 2.4.
StacksEpochId::Epoch24 => $Epoch205Version(args, env, context),
// Note: We reuse 2.05 for 3.0.
StacksEpochId::Epoch30 => $Epoch205Version(args, env, context),
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions clarity/src/vm/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ macro_rules! epochs_template {
match epoch {
// don't test Epoch-1.0
StacksEpochId::Epoch10 => (),
StacksEpochId::Epoch30 => (),
// this will lead to a compile time failure if an epoch is left out
// of the epochs_template! macro list
$(StacksEpochId::$epoch)|* => (),
Expand All @@ -75,6 +76,7 @@ macro_rules! clarity_template {
match (epoch, clarity) {
// don't test Epoch-1.0
(StacksEpochId::Epoch10, _) => (),
(StacksEpochId::Epoch30, _) => (),
// don't test these pairs, because they aren't supported:
(StacksEpochId::Epoch20, ClarityVersion::Clarity2) => (),
(StacksEpochId::Epoch2_05, ClarityVersion::Clarity2) => (),
Expand Down
8 changes: 5 additions & 3 deletions clarity/src/vm/types/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,8 @@ impl TypeSignature {
StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24 => self.admits_type_v2_1(other),
| StacksEpochId::Epoch24
| StacksEpochId::Epoch30 => self.admits_type_v2_1(other),
StacksEpochId::Epoch10 => unreachable!("epoch 1.0 not supported"),
}
}
Expand Down Expand Up @@ -727,7 +728,7 @@ impl TypeSignature {
// Epoch-2.2 had a regression in canonicalization, so it must be preserved here.
| StacksEpochId::Epoch22 => self.clone(),
// Note for future epochs: Epochs >= 2.3 should use the canonicalize_v2_1() routine
StacksEpochId::Epoch21 | StacksEpochId::Epoch23 | StacksEpochId::Epoch24 => self.canonicalize_v2_1(),
StacksEpochId::Epoch21 | StacksEpochId::Epoch23 | StacksEpochId::Epoch24 | StacksEpochId::Epoch30 => self.canonicalize_v2_1(),
}
}

Expand Down Expand Up @@ -1058,7 +1059,8 @@ impl TypeSignature {
StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23
| StacksEpochId::Epoch24 => Self::least_supertype_v2_1(a, b),
| StacksEpochId::Epoch24
| StacksEpochId::Epoch30 => Self::least_supertype_v2_1(a, b),
StacksEpochId::Epoch10 => unreachable!("Clarity 1.0 is not supported"),
}
}
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 @@ -36,6 +36,7 @@ impl ClarityVersion {
StacksEpochId::Epoch22 => ClarityVersion::Clarity2,
StacksEpochId::Epoch23 => ClarityVersion::Clarity2,
StacksEpochId::Epoch24 => ClarityVersion::Clarity2,
StacksEpochId::Epoch30 => ClarityVersion::Clarity2,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/rpc-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Possible values for the "reason" field and "reason_data" field are:
* `PoisonMicroblockIsInvalid`
* `BadAddressVersionByte`
* `NoCoinbaseViaMempool`
* `NoTenureChangeViaMempool`
* `ServerFailureNoSuchChainTip`
* `ServerFailureDatabase`
* The `reason_data` field will be an object containing a `message`
Expand Down
7 changes: 5 additions & 2 deletions stacks-common/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ pub enum StacksEpochId {
Epoch22 = 0x0200f,
Epoch23 = 0x02014,
Epoch24 = 0x02019,
Epoch30 = 0x03000,
}

impl StacksEpochId {
pub fn latest() -> StacksEpochId {
StacksEpochId::Epoch24
StacksEpochId::Epoch30
}

/// Returns whether or not this Epoch should perform
Expand All @@ -91,7 +92,7 @@ impl StacksEpochId {
| StacksEpochId::Epoch21
| StacksEpochId::Epoch22
| StacksEpochId::Epoch23 => false,
StacksEpochId::Epoch24 => true,
StacksEpochId::Epoch24 | StacksEpochId::Epoch30 => true,
}
}
}
Expand All @@ -106,6 +107,7 @@ impl std::fmt::Display for StacksEpochId {
StacksEpochId::Epoch22 => write!(f, "2.2"),
StacksEpochId::Epoch23 => write!(f, "2.3"),
StacksEpochId::Epoch24 => write!(f, "2.4"),
StacksEpochId::Epoch30 => write!(f, "3.0"),
}
}
}
Expand All @@ -122,6 +124,7 @@ impl TryFrom<u32> for StacksEpochId {
x if x == StacksEpochId::Epoch22 as u32 => Ok(StacksEpochId::Epoch22),
x if x == StacksEpochId::Epoch23 as u32 => Ok(StacksEpochId::Epoch23),
x if x == StacksEpochId::Epoch24 as u32 => Ok(StacksEpochId::Epoch24),
x if x == StacksEpochId::Epoch30 as u32 => Ok(StacksEpochId::Epoch30),
_ => Err("Invalid epoch"),
}
}
Expand Down
2 changes: 1 addition & 1 deletion stacks-common/src/util/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Hash160 {
}

/// Create a hash by hashing some data
/// (borrwed from Andrew Poelstra)
// (borrowed from Andrew Poelstra)
pub fn from_data(data: &[u8]) -> Hash160 {
let sha2_result = Sha256::digest(data);
let ripe_160_result = Ripemd160::digest(sha2_result.as_slice());
Expand Down
1 change: 1 addition & 0 deletions stacks-common/src/util/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ macro_rules! impl_byte_array_newtype {
}

/// Instantiates from a slice of bytes
/// Note: if this type is a hashing type, this sets the hash result to `inp` exactly: this method does **not** perform the hash.
#[allow(dead_code)]
pub fn from_bytes(inp: &[u8]) -> Option<$thing> {
match inp.len() {
Expand Down
4 changes: 4 additions & 0 deletions stackslib/src/burnchains/tests/burnchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ fn test_process_block_ops() {
canonical_stacks_tip_height: 0,
canonical_stacks_tip_hash: BlockHeaderHash([0u8; 32]),
canonical_stacks_tip_consensus_hash: ConsensusHash([0u8; 20]),
miner_pk_hash: None,
};

let block_ops_122 = vec![BlockstackOperationType::LeaderKeyRegister(
Expand Down Expand Up @@ -529,6 +530,7 @@ fn test_process_block_ops() {
canonical_stacks_tip_height: 0,
canonical_stacks_tip_hash: BlockHeaderHash([0u8; 32]),
canonical_stacks_tip_consensus_hash: ConsensusHash([0u8; 20]),
miner_pk_hash: None,
};

let block_ops_123 = vec![
Expand Down Expand Up @@ -583,6 +585,7 @@ fn test_process_block_ops() {
canonical_stacks_tip_height: 0,
canonical_stacks_tip_hash: BlockHeaderHash([0u8; 32]),
canonical_stacks_tip_consensus_hash: ConsensusHash([0u8; 20]),
miner_pk_hash: None,
};

// multiple possibilities for block 124 -- we'll reorg the chain each time back to 123 and
Expand Down Expand Up @@ -777,6 +780,7 @@ fn test_process_block_ops() {
canonical_stacks_tip_height: 0,
canonical_stacks_tip_hash: BlockHeaderHash([0u8; 32]),
canonical_stacks_tip_consensus_hash: ConsensusHash([0u8; 20]),
miner_pk_hash: None,
};

if next_sortition {
Expand Down
Loading