Skip to content

Commit

Permalink
Merge branch develop into chore/clippy-vec-and-iter-lints and fix…
Browse files Browse the repository at this point in the history
… conflicts
  • Loading branch information
jbencin committed Jan 10, 2025
2 parents a0dca4f + f5934db commit bab1182
Show file tree
Hide file tree
Showing 52 changed files with 482 additions and 302 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,38 @@ jobs:
- check-release
uses: ./.github/workflows/stacks-core-tests.yml

## Checks to run on built binaries
##
## Runs when:
## - it is a release run
## or:
## - it is not a release run
## and any of:
## - this workflow is called manually
## - PR is opened
## - PR added to merge queue
## - commit to either (development, next, master) branch
stacks-core-build-tests:
if: |
needs.check-release.outputs.is_release == 'true' || (
github.event_name == 'workflow_dispatch' ||
github.event_name == 'pull_request' ||
github.event_name == 'merge_group' ||
(
contains('
refs/heads/master
refs/heads/develop
refs/heads/next
', github.event.pull_request.head.ref) &&
github.event_name == 'push'
)
)
name: Stacks Core Build Tests
needs:
- rustfmt
- check-release
uses: ./.github/workflows/core-build-tests.yml

bitcoin-tests:
if: |
needs.check-release.outputs.is_release == 'true' || (
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/core-build-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Core build tests

# Only run when:
# - PRs are (re)opened against develop branch
on:
workflow_call:

jobs:
check-consts:
name: Check the constants from stacks-inspect
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
id: git_checkout
uses: actions/checkout@v3
- name: Define Rust Toolchain
id: define_rust_toolchain
run: echo "RUST_TOOLCHAIN=$(cat ./rust-toolchain)" >> $GITHUB_ENV
- name: Setup Rust Toolchain
id: setup_rust_toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Build the binaries
id: build
run: |
cargo build
- name: Dump constants JSON
id: consts-dump
run: cargo run --bin stacks-inspect -- dump-consts | tee out.json
- name: Set expected constants JSON
id: expects-json
run: diff out.json ./sample/expected_consts.json
14 changes: 5 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
### Added

- Add `tenure_timeout_secs` to the miner for determining when a time-based tenure extend should be attempted.
- Added configuration option `block_proposal_max_age_secs` under `[connection_options]` to prevent processing stale block proposals

### Changed
- The RPC endpoint `/v3/block_proposal` no longer will evaluate block proposals more than `block_proposal_max_age_secs` old

- When a transaction is dropped due to replace-by-fee, the `/drop_mempool_tx` event observer payload now includes `new_txid`, which is the transaction that replaced this dropped transaction. When a transaction is dropped for other reasons, `new_txid` is `null`. [#5381](https://github.com/stacks-network/stacks-core/pull/5381)
- Nodes will assume that all PoX anchor blocks exist by default, and stall initial block download indefinitely to await their arrival (#5502)

## [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]
## [3.1.0.0.2]

### Added

Expand All @@ -33,6 +27,8 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
- `/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))
- 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))
- Set the epoch to 3.1 in the Clarity DB upon activation.

### Changed

Expand Down
1 change: 1 addition & 0 deletions pox-locking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ mutants = "0.0.3"

[features]
slog_json = ["stacks_common/slog_json", "clarity/slog_json"]
testing = []
4 changes: 2 additions & 2 deletions sample/conf/testnet-follower-conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ start_height = 6

[[burnchain.epochs]]
epoch_name = "3.0"
start_height = 56_457
start_height = 1900

[[burnchain.epochs]]
epoch_name = "3.1"
start_height = 77_770
start_height = 2000
4 changes: 2 additions & 2 deletions sample/conf/testnet-miner-conf.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ start_height = 6

[[burnchain.epochs]]
epoch_name = "3.0"
start_height = 56_457
start_height = 1900

[[burnchain.epochs]]
epoch_name = "3.1"
start_height = 77_770
start_height = 2000
6 changes: 5 additions & 1 deletion sample/conf/testnet-signer.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,8 @@ start_height = 6

[[burnchain.epochs]]
epoch_name = "3.0"
start_height = 56_457
start_height = 1900

[[burnchain.epochs]]
epoch_name = "3.1"
start_height = 2000
12 changes: 12 additions & 0 deletions sample/expected_consts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"chain_id_mainnet": 1,
"chain_id_testnet": 2147483648,
"microstacks_per_stacks": 1000000,
"miner_reward_maturity": 100,
"network_id_mainnet": 385875968,
"network_id_testnet": 4278190080,
"peer_version_mainnet_major": 402653184,
"peer_version_testnet_major": 4207599104,
"signer_slots_per_user": 13,
"stacks_epoch_max": 9223372036854775807
}
1 change: 0 additions & 1 deletion stacks-common/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ use std::time::{SystemTime, UNIX_EPOCH};
use std::{error, fmt, thread, time};

/// Given a relative path inside the Cargo workspace, return the absolute path
#[cfg(any(test, feature = "testing"))]
pub fn cargo_workspace<P>(relative_path: P) -> PathBuf
where
P: AsRef<Path>,
Expand Down
15 changes: 13 additions & 2 deletions stacks-signer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
- Improvements to the stale signer cleanup logic: deletes the prior signer if it has no remaining unprocessed blocks in its database
- Signers now listen to new block events from the stacks node to determine whether a block has been successfully appended to the chain tip

## [3.1.0.0.1.0]
# [3.1.0.0.2.1]

### Added
## Added

## Changed

- Prevent old reward cycle signers from processing block validation response messages that do not apply to blocks from their cycle.

## [3.1.0.0.2.0]

## Added

- **SIP-029 consensus rules, activating in epoch 3.1 at block 875,000** (see [SIP-029](https://github.com/will-corcoran/sips/blob/feat/sip-029-halving-alignment/sips/sip-029/sip-029-halving-alignment.md) for details)

### Changed

- Added tenure extend timestamp to signer block responses
- Added tenure_idle_timeout_secs configuration option for determining when a time-based tenure extend will be accepted


## [3.1.0.0.0.0]

### Added
Expand Down
3 changes: 2 additions & 1 deletion stacks-signer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ serde_stacker = "0.1"
slog = { version = "2.5.2", features = [ "max_level_trace" ] }
slog-json = { version = "2.3.0", optional = true }
slog-term = "2.6.0"
stacks-common = { path = "../stacks-common", features = ["testing"] }
stacks-common = { path = "../stacks-common" }
stackslib = { path = "../stackslib" }
thiserror = { workspace = true }
tiny_http = { version = "0.12", optional = true }
Expand All @@ -49,6 +49,7 @@ rusqlite = { workspace = true, features = ["functions"] }

[dev-dependencies]
clarity = { path = "../clarity", features = ["testing"] }
stacks-common = { path = "../stacks-common", features = ["testing"] }
num-traits = "0.2.18"

[dependencies.serde_json]
Expand Down
2 changes: 1 addition & 1 deletion stacks-signer/src/chainstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ impl SortitionsView {
///
/// The rationale here is that the signer DB can be out-of-sync with the node. For example,
/// the signer may have been added to an already-running node.
fn check_tenure_change_confirms_parent(
pub fn check_tenure_change_confirms_parent(
tenure_change: &TenureChangePayload,
block: &NakamotoBlock,
signer_db: &mut SignerDb,
Expand Down
2 changes: 1 addition & 1 deletion stacks-signer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::path::PathBuf;
use std::time::Duration;

use blockstack_lib::chainstate::stacks::TransactionVersion;
use blockstack_lib::net::connection::DEFAULT_BLOCK_PROPOSAL_MAX_AGE_SECS;
use clarity::util::hash::to_hex;
use libsigner::SignerEntries;
use serde::Deserialize;
Expand All @@ -39,7 +40,6 @@ const BLOCK_PROPOSAL_VALIDATION_TIMEOUT_MS: u64 = 120_000;
const DEFAULT_FIRST_PROPOSAL_BURN_BLOCK_TIMING_SECS: u64 = 60;
const DEFAULT_TENURE_LAST_BLOCK_PROPOSAL_TIMEOUT_SECS: u64 = 30;
const TENURE_IDLE_TIMEOUT_SECS: u64 = 300;
const DEFAULT_BLOCK_PROPOSAL_MAX_AGE_SECS: u64 = 600;

#[derive(thiserror::Error, Debug)]
/// An error occurred parsing the provided configuration
Expand Down
77 changes: 0 additions & 77 deletions stacks-signer/src/signerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,18 +733,6 @@ impl SignerDb {
try_deserialize(result)
}

/// Return the last accepted block the signer (highest stacks height). It will tie break a match based on which was more recently signed.
pub fn get_signer_last_accepted_block(&self) -> Result<Option<BlockInfo>, DBError> {
let query = "SELECT block_info FROM blocks WHERE state IN (?1, ?2) ORDER BY stacks_height DESC, signed_group DESC, signed_self DESC LIMIT 1";
let args = params![
&BlockState::GloballyAccepted.to_string(),
&BlockState::LocallyAccepted.to_string()
];
let result: Option<String> = query_row(&self.db, query, args)?;

try_deserialize(result)
}

/// Return the last accepted block in a tenure (identified by its consensus hash).
pub fn get_last_accepted_block(
&self,
Expand Down Expand Up @@ -1769,69 +1757,4 @@ mod tests {
< block_infos[0].proposed_time
);
}

#[test]
fn signer_last_accepted_block() {
let db_path = tmp_db_path();
let mut db = SignerDb::new(db_path).expect("Failed to create signer db");

let (mut block_info_1, _block_proposal_1) = create_block_override(|b| {
b.block.header.miner_signature = MessageSignature([0x01; 65]);
b.block.header.chain_length = 1;
b.burn_height = 1;
});

let (mut block_info_2, _block_proposal_2) = create_block_override(|b| {
b.block.header.miner_signature = MessageSignature([0x02; 65]);
b.block.header.chain_length = 2;
b.burn_height = 1;
});

let (mut block_info_3, _block_proposal_3) = create_block_override(|b| {
b.block.header.miner_signature = MessageSignature([0x02; 65]);
b.block.header.chain_length = 2;
b.burn_height = 4;
});
block_info_3
.mark_locally_accepted(false)
.expect("Failed to mark block as locally accepted");

db.insert_block(&block_info_1)
.expect("Unable to insert block into db");
db.insert_block(&block_info_2)
.expect("Unable to insert block into db");

assert!(db.get_signer_last_accepted_block().unwrap().is_none());

block_info_1
.mark_globally_accepted()
.expect("Failed to mark block as globally accepted");
db.insert_block(&block_info_1)
.expect("Unable to insert block into db");

assert_eq!(
db.get_signer_last_accepted_block().unwrap().unwrap(),
block_info_1
);

block_info_2
.mark_globally_accepted()
.expect("Failed to mark block as globally accepted");
block_info_2.signed_self = Some(get_epoch_time_secs());
db.insert_block(&block_info_2)
.expect("Unable to insert block into db");

assert_eq!(
db.get_signer_last_accepted_block().unwrap().unwrap(),
block_info_2
);

db.insert_block(&block_info_3)
.expect("Unable to insert block into db");

assert_eq!(
db.get_signer_last_accepted_block().unwrap().unwrap(),
block_info_3
);
}
}
Loading

0 comments on commit bab1182

Please sign in to comment.