Skip to content

Commit aca4027

Browse files
committed
include signer equivalence check
1 parent 48442cc commit aca4027

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

stackslib/src/chainstate/stacks/boot/pox-4.clar

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,8 @@
904904
(existing-entry (unwrap! (map-get? reward-cycle-pox-address-list { reward-cycle: reward-cycle, index: reward-cycle-index })
905905
(err ERR_DELEGATION_NO_REWARD_SLOT)))
906906
(increased-entry-total (+ (get total-ustx existing-entry) partial-amount-ustx))
907-
(increased-cycle-total (+ (get total-ustx existing-cycle) partial-amount-ustx)))
907+
(increased-cycle-total (+ (get total-ustx existing-cycle) partial-amount-ustx))
908+
(existing-signer-key (get signer existing-entry)))
908909

909910
;; must be stackable
910911
(try! (minimal-can-stack-stx pox-addr increased-entry-total reward-cycle u1))
@@ -924,6 +925,9 @@
924925
;; Validate that amount is less than or equal to `max-amount`
925926
(asserts! (>= max-amount increased-entry-total) (err ERR_SIGNER_AUTH_AMOUNT_TOO_HIGH))
926927

928+
;; Validate that signer-key matches the existing signer-key
929+
(asserts! (is-eq existing-signer-key signer-key) (err ERR_INVALID_SIGNER_KEY))
930+
927931
;; Verify signature from delegate that allows this sender for this cycle
928932
;; 'lock-period' param set to one period, same as aggregation-commit-indexed
929933
(try! (consume-signer-key-authorization pox-addr reward-cycle "agg-increase" u1 signer-sig signer-key increased-entry-total max-amount auth-id))

stackslib/src/chainstate/stacks/boot/pox_4_tests.rs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,6 +3410,7 @@ fn stack_agg_increase() {
34103410
observer.get_blocks();
34113411
}
34123412
let latest_block = latest_block.expect("Failed to get tip");
3413+
//let latest_block = peer.tenure_with_txs(&[], &mut peer_nonce);
34133414
// Current reward cycle: 5 (starts at burn block 101)
34143415
let reward_cycle = get_current_reward_cycle(&peer, &peer.config.burnchain);
34153416
let next_reward_cycle = reward_cycle.wrapping_add(1);
@@ -3430,6 +3431,17 @@ fn stack_agg_increase() {
34303431
u128::MAX,
34313432
1,
34323433
);
3434+
// Increase Error Bob Signature For Bob
3435+
let lock_period = 1;
3436+
let bob_err_signature_increase = make_signer_key_signature(
3437+
&bob.pox_address,
3438+
&bob.private_key,
3439+
next_reward_cycle,
3440+
&Pox4SignatureTopic::AggregationCommit,
3441+
lock_period,
3442+
u128::MAX,
3443+
1,
3444+
);
34333445
// Increase Alice Signature For Bob
34343446
let alice_signature_increase = make_signer_key_signature(
34353447
&bob.pox_address,
@@ -3556,6 +3568,22 @@ fn stack_agg_increase() {
35563568
lock_period,
35573569
);
35583570
bob.nonce += 1;
3571+
// Bob's Error Aggregate Increase
3572+
let bobs_err_aggregate_increase = make_pox_4_aggregation_increase(
3573+
&bob.private_key,
3574+
bob.nonce,
3575+
&bob.pox_address,
3576+
next_reward_cycle,
3577+
bob_aggregate_commit_reward_index_actual
3578+
.clone()
3579+
.expect_u128()
3580+
.unwrap(),
3581+
Some(bob_err_signature_increase),
3582+
&bob.public_key,
3583+
u128::MAX,
3584+
1,
3585+
);
3586+
bob.nonce += 1;
35593587
// Bob's Aggregate Increase
35603588
let bobs_aggregate_increase = make_pox_4_aggregation_increase(
35613589
&bob.private_key,
@@ -3575,6 +3603,7 @@ fn stack_agg_increase() {
35753603
let txs = vec![
35763604
eve_delegate_stx_to_bob_tx.clone(),
35773605
bob_delegate_stack_stx_for_eve_tx.clone(),
3606+
bobs_err_aggregate_increase.clone(),
35783607
bobs_aggregate_increase.clone(),
35793608
];
35803609

@@ -3588,10 +3617,25 @@ fn stack_agg_increase() {
35883617
target_height.into(),
35893618
);
35903619

3620+
// Fetch the error aggregate increase result & check that the err is ERR_INVALID_SIGNER_KEY
3621+
let bob_err_increase_result_actual = &tx_block
3622+
.receipts
3623+
.get(3)
3624+
.unwrap()
3625+
.result
3626+
.clone()
3627+
.expect_result_err()
3628+
.unwrap();
3629+
let bob_err_increase_result_expected = Value::Int(32);
3630+
assert_eq!(
3631+
bob_err_increase_result_actual,
3632+
&bob_err_increase_result_expected
3633+
);
3634+
35913635
// Fetch the aggregate increase result & check that value is true
35923636
let bob_aggregate_increase_result = &tx_block
35933637
.receipts
3594-
.get(3)
3638+
.get(4)
35953639
.unwrap()
35963640
.result
35973641
.clone()

0 commit comments

Comments
 (0)