Skip to content

Commit

Permalink
Merge branch 'develop' into chore/merge-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed Dec 12, 2024
2 parents 0e67220 + 9e9d97e commit 49cc90e
Show file tree
Hide file tree
Showing 96 changed files with 4,824 additions and 1,488 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/bitcoin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,15 @@ jobs:
- tests::signer::v0::signer_set_rollover
- tests::signer::v0::signing_in_0th_tenure_of_reward_cycle
- tests::signer::v0::continue_after_tenure_extend
- tests::signer::v0::tenure_extend_after_idle
- tests::signer::v0::stx_transfers_dont_effect_idle_timeout
- tests::signer::v0::idle_tenure_extend_active_mining
- tests::signer::v0::multiple_miners_with_custom_chain_id
- tests::signer::v0::block_commit_delay
- tests::signer::v0::continue_after_fast_block_no_sortition
- tests::signer::v0::block_validation_response_timeout
- tests::signer::v0::tenure_extend_after_bad_commit
- tests::signer::v0::block_proposal_max_age_rejections
- tests::nakamoto_integrations::burn_ops_integration_test
- tests::nakamoto_integrations::check_block_heights
- tests::nakamoto_integrations::clarity_burn_state
Expand All @@ -142,6 +146,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
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE

### Changed

## [3.1.0.0.1]

### Added

- A miner will now generate a tenure-extend when at least 70% of the signers have confirmed that they are willing to allow one, via the new timestamp included in block responses. This allows the miner to refresh its budget in between Bitcoin blocks. ([#5476](https://github.com/stacks-network/stacks-core/discussions/5476))

### Changed

## [3.1.0.0.0]

### Added

- **SIP-029 consensus rules, activating in epoch 3.1 at block 875,000** (see [SIP-029](https://github.com/stacksgov/sips/blob/main/sips/sip-029/sip-029-halving-alignment.md) for details)
- New RPC endpoints
- `/v2/clarity/marf/:marf_key_hash`
- `/v2/clarity/metadata/:principal/:contract_name/:clarity_metadata_key`
- When a proposed block is validated by a node, the block can be validated even when the block version is different than the node's default ([#5539](https://github.com/stacks-network/stacks-core/pull/5539))

### Changed

## [3.0.0.0.4]

### Added

### Changed

- Use the same burn view loader in both block validation and block processing

## [3.0.0.0.3]

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ _Do_ document things that are not clear, e.g.:
Keep in mind that better variable names can reduce the need for comments, e.g.:

- `burnblock_height` instead of `height` may eliminate the need to comment that `height` refers to a burnblock height
- `process_microblocks` instead of `process_blocks` is more correct, and may eliminate the need to to explain that the inputs are microblocks
- `process_microblocks` instead of `process_blocks` is more correct, and may eliminate the need to explain that the inputs are microblocks
- `add_transaction_to_microblock` explains more than `handle_transaction`, and reduces the need to even read the comment

# Licensing and contributor license agreement
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
2 changes: 1 addition & 1 deletion clarity/src/vm/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ mod test {
) -> std::result::Result<ExecutionCost, CostErrors> {
self.invoked_functions.push((cost_f, input.to_vec()));
self.invocation_count += 1;
Ok(ExecutionCost::zero())
Ok(ExecutionCost::ZERO)
}
fn add_cost(&mut self, _cost: ExecutionCost) -> std::result::Result<(), CostErrors> {
self.cost_addition_count += 1;
Expand Down
2 changes: 1 addition & 1 deletion clarity/src/vm/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ impl<'a> GlobalContext<'a> {
database: ClarityDatabase<'a>,
cost_track: LimitedCostTracker,
epoch_id: StacksEpochId,
) -> GlobalContext {
) -> GlobalContext<'a> {
#[cfg(feature = "clarity-wasm")]
let engine = Engine::default();

Expand Down
33 changes: 18 additions & 15 deletions clarity/src/vm/costs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl CostTracker for () {
_cost_function: ClarityCostFunction,
_input: &[u64],
) -> std::result::Result<ExecutionCost, CostErrors> {
Ok(ExecutionCost::zero())
Ok(ExecutionCost::ZERO)
}
fn add_cost(&mut self, _cost: ExecutionCost) -> std::result::Result<(), CostErrors> {
Ok(())
Expand Down Expand Up @@ -715,7 +715,7 @@ impl LimitedCostTracker {
contract_call_circuits: HashMap::new(),
limit,
memory_limit: CLARITY_MEMORY_LIMIT,
total: ExecutionCost::zero(),
total: ExecutionCost::ZERO,
memory: 0,
epoch,
mainnet,
Expand All @@ -739,7 +739,7 @@ impl LimitedCostTracker {
contract_call_circuits: HashMap::new(),
limit,
memory_limit: CLARITY_MEMORY_LIMIT,
total: ExecutionCost::zero(),
total: ExecutionCost::ZERO,
memory: 0,
epoch,
mainnet,
Expand Down Expand Up @@ -783,7 +783,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 Expand Up @@ -887,7 +888,7 @@ impl LimitedCostTracker {
pub fn get_total(&self) -> ExecutionCost {
match self {
Self::Limited(TrackerData { total, .. }) => total.clone(),
Self::Free => ExecutionCost::zero(),
Self::Free => ExecutionCost::ZERO,
}
}
#[allow(clippy::panic)]
Expand Down Expand Up @@ -1057,7 +1058,7 @@ impl CostTracker for LimitedCostTracker {
match self {
Self::Free => {
// tracker is free, return zero!
return Ok(ExecutionCost::zero());
return Ok(ExecutionCost::ZERO);
}
Self::Limited(ref mut data) => {
if cost_function == ClarityCostFunction::Unimplemented {
Expand Down Expand Up @@ -1202,15 +1203,13 @@ impl CostOverflowingMath<u64> for u64 {
}

impl ExecutionCost {
pub fn zero() -> ExecutionCost {
Self {
runtime: 0,
write_length: 0,
read_count: 0,
write_count: 0,
read_length: 0,
}
}
pub const ZERO: Self = Self {
runtime: 0,
write_length: 0,
read_count: 0,
write_count: 0,
read_length: 0,
};

/// Returns the percentage of self consumed in `numerator`'s largest proportion dimension.
pub fn proportion_largest_dimension(&self, numerator: &ExecutionCost) -> u64 {
Expand Down Expand Up @@ -1335,6 +1334,10 @@ impl ExecutionCost {
read_length: first.read_length.max(second.read_length),
}
}

pub fn is_zero(&self) -> bool {
*self == Self::ZERO
}
}

// ONLY WORKS IF INPUT IS u64
Expand Down
4 changes: 2 additions & 2 deletions clarity/src/vm/database/key_value_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ where
}

impl<'a> RollbackWrapper<'a> {
pub fn new(store: &'a mut dyn ClarityBackingStore) -> RollbackWrapper {
pub fn new(store: &'a mut dyn ClarityBackingStore) -> RollbackWrapper<'a> {
RollbackWrapper {
store,
lookup_map: HashMap::new(),
Expand All @@ -218,7 +218,7 @@ impl<'a> RollbackWrapper<'a> {
pub fn from_persisted_log(
store: &'a mut dyn ClarityBackingStore,
log: RollbackWrapperPersistedLog,
) -> RollbackWrapper {
) -> RollbackWrapper<'a> {
RollbackWrapper {
store,
lookup_map: log.lookup_map,
Expand Down
4 changes: 2 additions & 2 deletions clarity/src/vm/docs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ const LOG2_API: SimpleFunctionAPI = SimpleFunctionAPI {
snippet: "log2 ${1:expr-1}",
signature: "(log2 n)",
description:
"Returns the power to which the number 2 must be raised to to obtain the value `n`, rounded
"Returns the power to which the number 2 must be raised to obtain the value `n`, rounded
down to the nearest integer. Fails on a negative numbers.
",
example: "(log2 u8) ;; Returns u3
Expand Down Expand Up @@ -2187,7 +2187,7 @@ type defined using `define-fungible-token`. The increased token balance is _not_
rather minted.
If a non-positive amount is provided to mint, this function returns `(err 1)`. Otherwise, on successfully mint, it
returns `(ok true)`. If this call would result in more supplied tokens than defined by the total supply in
returns `(ok true)`. If this call would result in more supplied tokens than defined by the total supply in
`define-fungible-token`, then a `SupplyOverflow` runtime error is thrown.
",
example: "
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
2 changes: 1 addition & 1 deletion clarity/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub fn execute(program: &str) -> Result<Option<Value>> {
)
}

/// Execute for test in in Clarity2, Epoch21, testnet.
/// Execute for test in Clarity2, Epoch21, testnet.
#[cfg(any(test, feature = "testing"))]
pub fn execute_v2(program: &str) -> Result<Option<Value>> {
execute_with_parameters(
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 @@ -1203,7 +1205,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
Loading

0 comments on commit 49cc90e

Please sign in to comment.