Skip to content

Commit

Permalink
Merge branch 'next' into feat/4354-aggregate-key
Browse files Browse the repository at this point in the history
  • Loading branch information
obycode committed Feb 21, 2024
2 parents 91a1fd9 + 9ca7d71 commit 055fad3
Show file tree
Hide file tree
Showing 17 changed files with 752 additions and 112 deletions.
24 changes: 13 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
- New [`pox-4` contract](./stackslib/src/chainstate/stacks/boot/pox-4.clar) that reflects changes in how Stackers are signers in Nakamoto:
- `stack-stx`, `stack-extend`, and `stack-aggregation-commit` now include a `signer-key` parameter, which represents the public key used by the Signer. This key is used for determining the signer set in Nakamoto.
- Functions that include a `signer-key` parameter also include a `signer-sig` parameter to demonstrate that the owner of `signer-key` is approving that particular Stacking operation. For more details, refer to the `verify-signer-key-sig` method in the `pox-4` contract.
- Signer key authorizations can be added via `set-signer-key-authorization` to omit the need for `signer-key` signatures

### Modified

Expand Down Expand Up @@ -43,23 +44,24 @@ and this project adheres to the versioning scheme outlined in the [README.md](RE
- New RPC endpoint at /v2/block_proposal for miner to validate proposed block.
Only accessible on local loopback interface

In addition, this introduces a set of improvements to the Stacks miner behavior. In
In addition, this introduces a set of improvements to the Stacks miner behavior. In
particular:
* The VRF public key can be re-used across node restarts.
* Settings that affect mining are hot-reloaded from the config file. They take

- The VRF public key can be re-used across node restarts.
- Settings that affect mining are hot-reloaded from the config file. They take
effect once the file is updated; there is no longer a need to restart the
node.
* The act of changing the miner settings in the config file automatically
node.
- The act of changing the miner settings in the config file automatically
triggers a subsequent block-build attempt, allowing the operator to force the
miner to re-try building blocks.
* This adds a new tip-selection algorithm that minimizes block orphans within a
miner to re-try building blocks.
- This adds a new tip-selection algorithm that minimizes block orphans within a
configurable window of time.
* When configured, the node will automatically stop mining if it is not achieving a
- When configured, the node will automatically stop mining if it is not achieving a
targeted win rate over a configurable window of blocks.
* When configured, the node will selectively mine transactions from only certain
- When configured, the node will selectively mine transactions from only certain
addresses, or only of certain types (STX-transfers, contract-publishes,
contract-calls).
* When configured, the node will optionally only RBF block-commits if it can
contract-calls).
- When configured, the node will optionally only RBF block-commits if it can
produce a block with strictly more transactions.

### Changed
Expand Down
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ hashbrown = "0.14.3"
rand_core = "0.6"
rand = "0.8"
rand_chacha = "0.3.1"
tikv-jemallocator = "0.5.4"
wsts = { version = "8.1", default-features = false }

# Use a bit more than default optimization for
Expand Down
2 changes: 1 addition & 1 deletion stacks-signer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ pub mod tests {
let program = format!(
r#"
{}
(verify-signer-key-sig {} u{} "{}" u{} 0x{} 0x{})
(verify-signer-key-sig {} u{} "{}" u{} (some 0x{}) 0x{})
"#,
&*POX_4_CODE, //s
Value::Tuple(pox_addr.clone().as_clarity_tuple().unwrap()), //p
Expand Down
1 change: 1 addition & 0 deletions stacks-signer/src/runloop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ mod tests {

#[test]
#[serial]
#[ignore]
fn verify_transactions_valid() {
let config = Config::load_from_file("./src/tests/conf/signer-0.toml").unwrap();
let mut runloop: RunLoop<FireCoordinator<v2::Aggregator>> = RunLoop::from(&config);
Expand Down
3 changes: 3 additions & 0 deletions stackslib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ siphasher = "0.3.7"
wsts = { workspace = true }
hashbrown = { workspace = true }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = {workspace = true}

[target.'cfg(unix)'.dependencies]
nix = "0.23"

Expand Down
6 changes: 3 additions & 3 deletions stackslib/src/chainstate/nakamoto/coordinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ fn advance_to_nakamoto(
&test_stacker.stacker_private_key,
0,
test_stacker.amount,
pox_addr.clone(),
&pox_addr,
12,
signing_key,
&signing_key,
34,
signature,
Some(signature),
)
})
.collect()
Expand Down
59 changes: 51 additions & 8 deletions stackslib/src/chainstate/stacks/boot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1848,13 +1848,17 @@ pub mod test {
key: &StacksPrivateKey,
nonce: u64,
amount: u128,
addr: PoxAddress,
addr: &PoxAddress,
lock_period: u128,
signer_key: StacksPublicKey,
signer_key: &StacksPublicKey,
burn_ht: u64,
signature: Vec<u8>,
signature_opt: Option<Vec<u8>>,
) -> StacksTransaction {
let addr_tuple = Value::Tuple(addr.as_clarity_tuple().unwrap());
let signature = match signature_opt {
Some(sig) => Value::some(Value::buff_from(sig).unwrap()).unwrap(),
None => Value::none(),
};
let payload = TransactionPayload::new_contract_call(
boot_code_test_addr(),
"pox-4",
Expand All @@ -1864,7 +1868,7 @@ pub mod test {
addr_tuple,
Value::UInt(burn_ht as u128),
Value::UInt(lock_period),
Value::buff_from(signature).unwrap(),
signature,
Value::buff_from(signer_key.to_bytes_compressed()).unwrap(),
],
)
Expand Down Expand Up @@ -2008,17 +2012,21 @@ pub mod test {
addr: PoxAddress,
lock_period: u128,
signer_key: StacksPublicKey,
signature: Vec<u8>,
signature_opt: Option<Vec<u8>>,
) -> StacksTransaction {
let addr_tuple = Value::Tuple(addr.as_clarity_tuple().unwrap());
let signature = match signature_opt {
Some(sig) => Value::some(Value::buff_from(sig).unwrap()).unwrap(),
None => Value::none(),
};
let payload = TransactionPayload::new_contract_call(
boot_code_test_addr(),
POX_4_NAME,
"stack-extend",
vec![
Value::UInt(lock_period),
addr_tuple,
Value::buff_from(signature).unwrap(),
signature,
Value::buff_from(signer_key.to_bytes_compressed()).unwrap(),
],
)
Expand Down Expand Up @@ -2112,18 +2120,22 @@ pub mod test {
nonce: u64,
pox_addr: &PoxAddress,
reward_cycle: u128,
signature: Vec<u8>,
signature_opt: Option<Vec<u8>>,
signer_key: &Secp256k1PublicKey,
) -> StacksTransaction {
let addr_tuple = Value::Tuple(pox_addr.as_clarity_tuple().unwrap());
let signature = match signature_opt {
Some(sig) => Value::some(Value::buff_from(sig).unwrap()).unwrap(),
None => Value::none(),
};
let payload = TransactionPayload::new_contract_call(
boot_code_test_addr(),
POX_4_NAME,
"stack-aggregation-commit-indexed",
vec![
addr_tuple,
Value::UInt(reward_cycle),
Value::buff_from(signature).unwrap(),
signature,
Value::buff_from(signer_key.to_bytes_compressed()).unwrap(),
],
)
Expand Down Expand Up @@ -2202,6 +2214,37 @@ pub mod test {
signature.to_rsv()
}

pub fn make_pox_4_set_signer_key_auth(
pox_addr: &PoxAddress,
signer_key: &StacksPrivateKey,
reward_cycle: u128,
topic: &Pox4SignatureTopic,
period: u128,
enabled: bool,
nonce: u64,
sender_key: Option<&StacksPrivateKey>,
) -> StacksTransaction {
let signer_pubkey = StacksPublicKey::from_private(signer_key);
let payload = TransactionPayload::new_contract_call(
boot_code_test_addr(),
POX_4_NAME,
"set-signer-key-authorization",
vec![
Value::Tuple(pox_addr.as_clarity_tuple().unwrap()),
Value::UInt(period),
Value::UInt(reward_cycle),
Value::string_ascii_from_bytes(topic.get_name_str().into()).unwrap(),
Value::buff_from(signer_pubkey.to_bytes_compressed()).unwrap(),
Value::Bool(enabled),
],
)
.unwrap();

let sender_key = sender_key.unwrap_or(signer_key);

make_tx(sender_key, nonce, 0, payload)
}

fn make_tx(
key: &StacksPrivateKey,
nonce: u64,
Expand Down
Loading

0 comments on commit 055fad3

Please sign in to comment.