Skip to content

Commit 08e04d9

Browse files
authored
Merge pull request #4728 from stacks-network/fix/agg-increase-event
fix: add signer-key to synthetic `stack-aggregation-increase` event
2 parents 41e57ef + 837f4a4 commit 08e04d9

File tree

2 files changed

+59
-11
lines changed

2 files changed

+59
-11
lines changed

pox-locking/src/events.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,13 +467,25 @@ fn create_event_info_data_code(
467467
end-cycle-id: (some (+ {reward_cycle} u1)),
468468
;; Get start cycle ID
469469
start-cycle-id: start-cycle,
470+
;; equal to args[3]
471+
signer-sig: {signer_sig},
472+
;; equal to args[4]
473+
signer-key: {signer_key},
474+
;; equal to args[5]
475+
max-amount: {max_amount},
476+
;; equal to args[6]
477+
auth-id: {auth_id},
470478
}}
471479
}})
472480
"#,
473481
pox_addr = &args[0],
474482
reward_cycle = &args[1],
475483
reward_cycle_index = &args.get(2).unwrap_or(&Value::none()),
476484
pox_set_offset = pox_set_offset.replace("%height%", "burn-block-height"),
485+
signer_sig = &args.get(3).unwrap_or(&Value::none()),
486+
signer_key = &args.get(4).unwrap_or(&Value::none()),
487+
max_amount = &args.get(5).unwrap_or(&Value::none()),
488+
auth_id = &args.get(6).unwrap_or(&Value::none()),
477489
)
478490
}
479491
"delegate-stx" => {

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

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4498,7 +4498,7 @@ fn stack_agg_increase() {
44984498
.clone()
44994499
.expect_u128()
45004500
.unwrap(),
4501-
Some(alice_signature_increase),
4501+
Some(alice_signature_increase.clone()),
45024502
&alice.public_key,
45034503
u128::MAX,
45044504
1,
@@ -4596,16 +4596,52 @@ fn stack_agg_increase() {
45964596
&bob_err_increase_result_expected
45974597
);
45984598

4599+
let bob_aggregate_increase_tx = &tx_block.receipts.get(4).unwrap();
4600+
45994601
// Fetch the aggregate increase result & check that value is true
4600-
let bob_aggregate_increase_result = &tx_block
4601-
.receipts
4602-
.get(4)
4603-
.unwrap()
4602+
let bob_aggregate_increase_result = bob_aggregate_increase_tx
46044603
.result
46054604
.clone()
46064605
.expect_result_ok()
46074606
.unwrap();
4608-
assert_eq!(bob_aggregate_increase_result, &Value::Bool(true));
4607+
assert_eq!(bob_aggregate_increase_result, Value::Bool(true));
4608+
4609+
let aggregation_increase_event = &bob_aggregate_increase_tx.events[0];
4610+
4611+
let expected_result = Value::okay(Value::Tuple(
4612+
TupleData::from_data(vec![
4613+
(
4614+
"stacker".into(),
4615+
Value::Principal(PrincipalData::from(bob.address.clone())),
4616+
),
4617+
("total-locked".into(), Value::UInt(min_ustx * 2)),
4618+
])
4619+
.unwrap(),
4620+
))
4621+
.unwrap();
4622+
4623+
let increase_op_data = HashMap::from([
4624+
(
4625+
"signer-sig",
4626+
Value::some(Value::buff_from(alice_signature_increase).unwrap()).unwrap(),
4627+
),
4628+
(
4629+
"signer-key",
4630+
Value::buff_from(alice.public_key.to_bytes_compressed()).unwrap(),
4631+
),
4632+
("max-amount", Value::UInt(u128::MAX)),
4633+
("auth-id", Value::UInt(1)),
4634+
]);
4635+
4636+
let common_data = PoxPrintFields {
4637+
op_name: "stack-aggregation-increase".to_string(),
4638+
stacker: Value::Principal(PrincipalData::from(bob.address.clone())),
4639+
balance: Value::UInt(1000000000000000000),
4640+
locked: Value::UInt(0),
4641+
burnchain_unlock_height: Value::UInt(0),
4642+
};
4643+
4644+
check_pox_print_event(&aggregation_increase_event, common_data, increase_op_data);
46094645

46104646
// Check that Bob's second pool has an assigned reward index of 1
46114647
let bob_aggregate_commit_reward_index = &tx_block
@@ -6502,7 +6538,7 @@ fn test_scenario_one() {
65026538
// Bob solo stacker-signer setup
65036539
let mut bob = StackerSignerInfo::new();
65046540
let default_initial_balances: u64 = 1_000_000_000_000_000_000;
6505-
let mut initial_balances = vec![
6541+
let initial_balances = vec![
65066542
(alice.principal.clone(), default_initial_balances),
65076543
(bob.principal.clone(), default_initial_balances),
65086544
];
@@ -6911,7 +6947,7 @@ fn test_scenario_two() {
69116947
let mut dave = StackerSignerInfo::new();
69126948

69136949
let default_initial_balances = 1_000_000_000_000_000_000;
6914-
let mut initial_balances = vec![
6950+
let initial_balances = vec![
69156951
(alice.principal.clone(), default_initial_balances),
69166952
(bob.principal.clone(), default_initial_balances),
69176953
(carl.principal.clone(), default_initial_balances),
@@ -7252,7 +7288,7 @@ fn test_scenario_three() {
72527288
// Bob stacker signer setup
72537289
let mut bob = StackerSignerInfo::new();
72547290
// Carl service signer setup
7255-
let mut carl = StackerSignerInfo::new();
7291+
let carl = StackerSignerInfo::new();
72567292
// David stacking pool operator setup
72577293
let mut david = StackerSignerInfo::new();
72587294
// Eve pool stacker setup
@@ -7729,7 +7765,7 @@ fn test_scenario_four() {
77297765
let mut bob = StackerSignerInfo::new();
77307766

77317767
let default_initial_balances = 1_000_000_000_000_000_000;
7732-
let mut initial_balances = vec![
7768+
let initial_balances = vec![
77337769
(alice.principal.clone(), default_initial_balances),
77347770
(bob.principal.clone(), default_initial_balances),
77357771
];
@@ -8770,7 +8806,7 @@ fn test_scenario_five() {
87708806
let mut mallory = StackerSignerInfo::new();
87718807

87728808
let default_initial_balances = 1_000_000_000_000_000_000;
8773-
let mut initial_balances = vec![
8809+
let initial_balances = vec![
87748810
(alice.principal.clone(), default_initial_balances),
87758811
(bob.principal.clone(), default_initial_balances),
87768812
(carl.principal.clone(), default_initial_balances),

0 commit comments

Comments
 (0)