Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request stacks-network#4728 from stacks-network/fix/agg-in…
Browse files Browse the repository at this point in the history
…crease-event

fix: add signer-key to synthetic `stack-aggregation-increase` event
  • Loading branch information
hstove authored Apr 30, 2024
2 parents 41e57ef + 837f4a4 commit 08e04d9
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 11 deletions.
12 changes: 12 additions & 0 deletions pox-locking/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,25 @@ fn create_event_info_data_code(
end-cycle-id: (some (+ {reward_cycle} u1)),
;; Get start cycle ID
start-cycle-id: start-cycle,
;; equal to args[3]
signer-sig: {signer_sig},
;; equal to args[4]
signer-key: {signer_key},
;; equal to args[5]
max-amount: {max_amount},
;; equal to args[6]
auth-id: {auth_id},
}}
}})
"#,
pox_addr = &args[0],
reward_cycle = &args[1],
reward_cycle_index = &args.get(2).unwrap_or(&Value::none()),
pox_set_offset = pox_set_offset.replace("%height%", "burn-block-height"),
signer_sig = &args.get(3).unwrap_or(&Value::none()),
signer_key = &args.get(4).unwrap_or(&Value::none()),
max_amount = &args.get(5).unwrap_or(&Value::none()),
auth_id = &args.get(6).unwrap_or(&Value::none()),
)
}
"delegate-stx" => {
Expand Down
58 changes: 47 additions & 11 deletions stackslib/src/chainstate/stacks/boot/pox_4_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4498,7 +4498,7 @@ fn stack_agg_increase() {
.clone()
.expect_u128()
.unwrap(),
Some(alice_signature_increase),
Some(alice_signature_increase.clone()),
&alice.public_key,
u128::MAX,
1,
Expand Down Expand Up @@ -4596,16 +4596,52 @@ fn stack_agg_increase() {
&bob_err_increase_result_expected
);

let bob_aggregate_increase_tx = &tx_block.receipts.get(4).unwrap();

// Fetch the aggregate increase result & check that value is true
let bob_aggregate_increase_result = &tx_block
.receipts
.get(4)
.unwrap()
let bob_aggregate_increase_result = bob_aggregate_increase_tx
.result
.clone()
.expect_result_ok()
.unwrap();
assert_eq!(bob_aggregate_increase_result, &Value::Bool(true));
assert_eq!(bob_aggregate_increase_result, Value::Bool(true));

let aggregation_increase_event = &bob_aggregate_increase_tx.events[0];

let expected_result = Value::okay(Value::Tuple(
TupleData::from_data(vec![
(
"stacker".into(),
Value::Principal(PrincipalData::from(bob.address.clone())),
),
("total-locked".into(), Value::UInt(min_ustx * 2)),
])
.unwrap(),
))
.unwrap();

let increase_op_data = HashMap::from([
(
"signer-sig",
Value::some(Value::buff_from(alice_signature_increase).unwrap()).unwrap(),
),
(
"signer-key",
Value::buff_from(alice.public_key.to_bytes_compressed()).unwrap(),
),
("max-amount", Value::UInt(u128::MAX)),
("auth-id", Value::UInt(1)),
]);

let common_data = PoxPrintFields {
op_name: "stack-aggregation-increase".to_string(),
stacker: Value::Principal(PrincipalData::from(bob.address.clone())),
balance: Value::UInt(1000000000000000000),
locked: Value::UInt(0),
burnchain_unlock_height: Value::UInt(0),
};

check_pox_print_event(&aggregation_increase_event, common_data, increase_op_data);

// Check that Bob's second pool has an assigned reward index of 1
let bob_aggregate_commit_reward_index = &tx_block
Expand Down Expand Up @@ -6502,7 +6538,7 @@ fn test_scenario_one() {
// Bob solo stacker-signer setup
let mut bob = StackerSignerInfo::new();
let default_initial_balances: u64 = 1_000_000_000_000_000_000;
let mut initial_balances = vec![
let initial_balances = vec![
(alice.principal.clone(), default_initial_balances),
(bob.principal.clone(), default_initial_balances),
];
Expand Down Expand Up @@ -6911,7 +6947,7 @@ fn test_scenario_two() {
let mut dave = StackerSignerInfo::new();

let default_initial_balances = 1_000_000_000_000_000_000;
let mut initial_balances = vec![
let initial_balances = vec![
(alice.principal.clone(), default_initial_balances),
(bob.principal.clone(), default_initial_balances),
(carl.principal.clone(), default_initial_balances),
Expand Down Expand Up @@ -7252,7 +7288,7 @@ fn test_scenario_three() {
// Bob stacker signer setup
let mut bob = StackerSignerInfo::new();
// Carl service signer setup
let mut carl = StackerSignerInfo::new();
let carl = StackerSignerInfo::new();
// David stacking pool operator setup
let mut david = StackerSignerInfo::new();
// Eve pool stacker setup
Expand Down Expand Up @@ -7729,7 +7765,7 @@ fn test_scenario_four() {
let mut bob = StackerSignerInfo::new();

let default_initial_balances = 1_000_000_000_000_000_000;
let mut initial_balances = vec![
let initial_balances = vec![
(alice.principal.clone(), default_initial_balances),
(bob.principal.clone(), default_initial_balances),
];
Expand Down Expand Up @@ -8770,7 +8806,7 @@ fn test_scenario_five() {
let mut mallory = StackerSignerInfo::new();

let default_initial_balances = 1_000_000_000_000_000_000;
let mut initial_balances = vec![
let initial_balances = vec![
(alice.principal.clone(), default_initial_balances),
(bob.principal.clone(), default_initial_balances),
(carl.principal.clone(), default_initial_balances),
Expand Down

0 comments on commit 08e04d9

Please sign in to comment.