Skip to content

Commit 306188f

Browse files
authored
chore: Use L1TxUtils instead of raw client (#16529)
Shuld fix this [flake](http://ci.aztec-labs.com/80f33f293999bdcc) by implementing what @just-mitch suggested :)
2 parents e47abd8 + ba15c44 commit 306188f

File tree

1 file changed

+28
-16
lines changed

1 file changed

+28
-16
lines changed

yarn-project/end-to-end/src/e2e_p2p/slash_veto_demo.test.ts

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
EmpireSlashingProposerArtifact,
55
type ExtendedViemWalletClient,
66
L1Deployer,
7+
L1TxUtils,
78
RollupContract,
89
SlasherArtifact,
910
} from '@aztec/ethereum';
@@ -15,7 +16,7 @@ import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
1516
import fs from 'fs';
1617
import os from 'os';
1718
import path from 'path';
18-
import { getContract } from 'viem';
19+
import { encodeFunctionData, getContract } from 'viem';
1920
import { privateKeyToAccount } from 'viem/accounts';
2021

2122
import { createNodes } from '../fixtures/setup_p2p_test.js';
@@ -49,6 +50,7 @@ describe('veto slash', () => {
4950
let slashingAmount: bigint;
5051
let additionalNode: AztecNodeService | undefined;
5152
let rollup: RollupContract;
53+
let l1TxUtils: L1TxUtils;
5254

5355
beforeAll(async () => {
5456
t = await P2PNetworkTest.create({
@@ -89,6 +91,7 @@ describe('veto slash', () => {
8991
);
9092

9193
({ rollup } = await t.getContracts());
94+
l1TxUtils = new L1TxUtils(t.ctx.deployL1ContractsValues.l1Client);
9295
// slash amount is just below the ejection threshold
9396
slashingAmount = (await rollup.getActivationThreshold()) - (await rollup.getEjectionThreshold()) - 1n;
9497
t.ctx.aztecNodeConfig.slashInactivityEnabled = true;
@@ -145,9 +148,15 @@ describe('veto slash', () => {
145148
const proposer = await deployer.deploy(EmpireSlashingProposerArtifact, proposerArgs);
146149

147150
debugLogger.info(`\n\ninitializing slasher with proposer: ${proposer}\n\n`);
148-
const slasherContract = getContract({ address: slasher.toString(), abi: SlasherAbi, client: deployerClient });
149-
const txHash = await slasherContract.write.initializeProposer([proposer.toString()]);
150-
await deployerClient.waitForTransactionReceipt({ hash: txHash });
151+
const txUtils = new L1TxUtils(deployerClient);
152+
await txUtils.sendAndMonitorTransaction({
153+
to: slasher.toString(),
154+
data: encodeFunctionData({
155+
abi: SlasherAbi,
156+
functionName: 'initializeProposer',
157+
args: [proposer.toString()],
158+
}),
159+
});
151160

152161
return slasher;
153162
}
@@ -164,13 +173,14 @@ describe('veto slash', () => {
164173
const l1Client = t.ctx.deployL1ContractsValues.l1Client;
165174
const newSlasherAddress = await deployNewSlasher(l1Client);
166175
debugLogger.info(`\n\nnewSlasherAddress: ${newSlasherAddress}\n\n`);
167-
const rollupRaw = getContract({
168-
address: rollup.address,
169-
abi: RollupAbi,
170-
client: l1Client,
176+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
177+
to: rollup.address,
178+
data: encodeFunctionData({
179+
abi: RollupAbi,
180+
functionName: 'setSlasher',
181+
args: [newSlasherAddress.toString()],
182+
}),
171183
});
172-
const tx = await rollupRaw.write.setSlasher([newSlasherAddress.toString()]);
173-
const receipt = await l1Client.waitForTransactionReceipt({ hash: tx });
174184
expect(receipt.status).toEqual('success');
175185
const slasherAddress = await rollup.getSlasher();
176186
expect(slasherAddress.toLowerCase()).toEqual(newSlasherAddress.toString().toLowerCase());
@@ -268,13 +278,15 @@ describe('veto slash', () => {
268278
//##############################//
269279

270280
if (shouldVeto) {
271-
const slasher = getContract({
272-
address: await rollup.getSlasher(),
273-
abi: SlasherAbi,
274-
client: t.ctx.deployL1ContractsValues.l1Client,
281+
const slasherAddress = await rollup.getSlasher();
282+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
283+
to: slasherAddress,
284+
data: encodeFunctionData({
285+
abi: SlasherAbi,
286+
functionName: 'vetoPayload',
287+
args: [submittableRound.payload],
288+
}),
275289
});
276-
const tx = await slasher.write.vetoPayload([submittableRound.payload]);
277-
const receipt = await t.ctx.deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: tx });
278290
debugLogger.info(`\n\nvetoPayload tx receipt: ${receipt.status}\n\n`);
279291
}
280292

0 commit comments

Comments
 (0)