Skip to content

Commit 78e4669

Browse files
sparrowDomclaude
andauthored
fix: decode BalancesSnapped event via strategy interface in snapBalances task (#2881)
When snapBalances runs with --consol, the tx is sent to ConsolidationController but the BalancesSnapped event is emitted by the target strategy. The receipt's decoded events are bound to the controller's ABI so the event lookup failed and the task threw even though the tx succeeded. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a2c24b5 commit 78e4669

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

contracts/tasks/validatorCompound.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,28 @@ async function snapBalances({ consol = false }) {
5050
await logTxDetails(tx, "snapBalances");
5151

5252
const receipt = await tx.wait();
53-
const event = receipt.events.find(
54-
(event) => event.event === "BalancesSnapped"
53+
54+
// When called via ConsolidationController the BalancesSnapped event is emitted
55+
// by the target strategy, so decode logs against the strategy's interface.
56+
const strategy = await resolveContract(
57+
"CompoundingStakingSSVStrategyProxy",
58+
"CompoundingStakingSSVStrategy"
5559
);
56-
if (!event) {
60+
const eventTopic = strategy.interface.getEventTopic("BalancesSnapped");
61+
const rawLog = receipt.logs.find(
62+
(l) =>
63+
l.address.toLowerCase() === strategy.address.toLowerCase() &&
64+
l.topics[0] === eventTopic
65+
);
66+
if (!rawLog) {
5767
throw new Error("BalancesSnapped event not found in transaction receipt");
5868
}
69+
const parsed = strategy.interface.parseLog(rawLog);
5970
console.log(
6071
`Balances snapped successfully. Beacon block root ${
61-
event.args.blockRoot
72+
parsed.args.blockRoot
6273
}, block ${receipt.blockNumber}, ETH balance ${formatUnits(
63-
event.args.ethBalance
74+
parsed.args.ethBalance
6475
)}`
6576
);
6677
}

0 commit comments

Comments
 (0)