Skip to content

Commit 19600db

Browse files
committed
wip: further debug
1 parent 0db9d38 commit 19600db

File tree

15 files changed

+113
-46
lines changed

15 files changed

+113
-46
lines changed

l1-contracts/bootstrap.sh

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ function build {
3333
# Step 1: Build everything in src.
3434
forge build $(find src test -name '*.sol')
3535

36+
# Step 1.5: Output storage information for the rollup contract.
37+
forge inspect src/core/Rollup.sol:Rollup storage > ./out/Rollup.sol/storage.json
38+
3639
# Step 2: Build the the generated verifier contract with optimization.
3740
forge build $(find generated -name '*.sol') \
3841
--optimize \

l1-contracts/src/core/Rollup.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, ValidatorSelection, IRo
434434
}
435435

436436
/**
437-
* @notice Validate blob transactions against given inputs.
437+
* @notice Validate blob transactions against given inputs
438438
* @dev Only exists here for gas estimation.
439439
*/
440440
function validateBlobs(bytes calldata _blobsInput)

yarn-project/aztec-node/src/aztec-node/server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ export class AztecNodeService implements AztecNode, Traceable {
863863
);
864864
const fork = await this.worldStateSynchronizer.fork();
865865

866-
this.log.verbose(`Simulating public calls for tx ${tx.getTxHash()}`, {
866+
this.log.verbose(`Simulating public calls for tx ${txHash}`, {
867867
globalVariables: newGlobalVariables.toInspect(),
868868
txHash,
869869
blockNumber,
@@ -876,7 +876,7 @@ export class AztecNodeService implements AztecNode, Traceable {
876876
const [processedTxs, failedTxs, returns] = await processor.process([tx]);
877877
// REFACTOR: Consider returning the error rather than throwing
878878
if (failedTxs.length) {
879-
this.log.warn(`Simulated tx ${tx.getTxHash()} fails: ${failedTxs[0].error}`, { txHash });
879+
this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
880880
throw failedTxs[0].error;
881881
}
882882

yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ describe('L1Publisher integration', () => {
191191
);
192192
const l1TxUtils = new L1TxUtilsWithBlobs(sequencerPublicClient, sequencerWalletClient, logger, config);
193193
const rollupContract = new RollupContract(sequencerPublicClient, l1ContractAddresses.rollupAddress.toString());
194-
const forwarderContract = await createForwarderContract(config, sequencerPK);
194+
const forwarderContract = await createForwarderContract(
195+
config,
196+
sequencerPK,
197+
l1ContractAddresses.rollupAddress.toString(),
198+
);
195199
const slashingProposerAddress = await rollupContract.getSlashingProposerAddress();
196200
const slashingProposerContract = new SlashingProposerContract(
197201
sequencerPublicClient,

yarn-project/end-to-end/src/e2e_synching.test.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,8 @@ describe('e2e_synching', () => {
408408
logger,
409409
config,
410410
);
411-
const rollupContract = new RollupContract(
412-
deployL1ContractsValues.publicClient,
413-
deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
414-
);
411+
const rollupAddress = deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString();
412+
const rollupContract = new RollupContract(deployL1ContractsValues.publicClient, rollupAddress);
415413
const governanceProposerContract = new GovernanceProposerContract(
416414
deployL1ContractsValues.publicClient,
417415
config.l1Contracts.governanceProposerAddress.toString(),
@@ -421,7 +419,7 @@ describe('e2e_synching', () => {
421419
deployL1ContractsValues.publicClient,
422420
slashingProposerAddress.toString(),
423421
);
424-
const forwarderContract = await createForwarderContract(config, sequencerPK);
422+
const forwarderContract = await createForwarderContract(config, sequencerPK, rollupAddress);
425423
const epochCache = await EpochCache.create(config.l1Contracts.rollupAddress, config, {
426424
dateProvider: new TestDateProvider(),
427425
});

yarn-project/end-to-end/src/fixtures/utils.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -767,13 +767,18 @@ function createDelayedL1TxUtils(aztecNodeConfig: AztecNodeConfig, privateKey: `0
767767
return l1TxUtils;
768768
}
769769

770-
export async function createForwarderContract(aztecNodeConfig: AztecNodeConfig, privateKey: `0x${string}`) {
770+
export async function createForwarderContract(
771+
aztecNodeConfig: AztecNodeConfig,
772+
privateKey: `0x${string}`,
773+
rollupAddress: Hex,
774+
) {
771775
const { walletClient, publicClient } = createL1Clients(aztecNodeConfig.l1RpcUrl, privateKey, foundry);
772776
const forwarderContract = await ForwarderContract.create(
773777
walletClient.account.address,
774778
walletClient,
775779
publicClient,
776780
createLogger('forwarder'),
781+
rollupAddress,
777782
);
778783
return forwarderContract;
779784
}

yarn-project/end-to-end/src/spartan/upgrade_governance_proposer.test.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ describe('spartan_upgrade_governance_proposer', () => {
6868
// check the balance of the account
6969
const balance = await validatorWalletClient.getBalance({ address: account.address });
7070
debugLogger.info(`deployer balance: ${balance}`);
71-
if (balance <= parseEther('0.5')) {
71+
if (balance <= parseEther('5')) {
7272
debugLogger.info('sending some eth to the deployer account');
7373
// send some eth to the account
7474
const tx = await validatorWalletClient.sendTransaction({
7575
to: account.address,
76-
value: parseEther('1'),
76+
value: parseEther('10'),
7777
});
7878
const receipt = await validatorWalletClient.waitForTransactionReceipt({ hash: tx });
7979
debugLogger.info(`receipt: ${stringify(receipt)}`);
@@ -149,16 +149,17 @@ describe('spartan_upgrade_governance_proposer', () => {
149149
debugLogger.info(`Waiting for round ${executableRound + 1n}`);
150150

151151
while (info.round === executableRound) {
152-
await sleep(12000);
152+
await sleep(12500);
153153
info = await govInfo();
154154
debugLogger.info(`slot: ${info.slot}`);
155155
}
156156

157157
expect(info.round).toBeGreaterThan(executableRound);
158158

159159
debugLogger.info(`Executing proposal ${info.round}`);
160+
160161
const l1TxUtils = new L1TxUtils(l1PublicClient, l1WalletClient, debugLogger);
161-
const { receipt } = await governanceProposer.executeProposal(info.round, l1TxUtils);
162+
const { receipt } = await governanceProposer.executeProposal(executableRound, l1TxUtils);
162163
expect(receipt).toBeDefined();
163164
expect(receipt.status).toEqual('success');
164165
debugLogger.info(`Executed proposal ${info.round}`);

yarn-project/ethereum/src/contracts/forwarder.ts

+29-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { toHex } from '@aztec/foundation/bigint-buffer';
12
import { type Logger } from '@aztec/foundation/log';
23
import { ForwarderAbi, ForwarderBytecode } from '@aztec/l1-artifacts';
34

@@ -15,11 +16,12 @@ import {
1516

1617
import { type L1Clients, deployL1Contract } from '../deploy_l1_contracts.js';
1718
import { type L1BlobInputs, type L1GasConfig, type L1TxRequest, type L1TxUtils } from '../l1_tx_utils.js';
19+
import { RollupContract } from './rollup.js';
1820

1921
export class ForwarderContract {
2022
private readonly forwarder: GetContractReturnType<typeof ForwarderAbi, PublicClient<HttpTransport, Chain>>;
2123

22-
constructor(public readonly client: L1Clients['publicClient'], address: Hex) {
24+
constructor(public readonly client: L1Clients['publicClient'], address: Hex, public readonly rollupAddress: Hex) {
2325
this.forwarder = getContract({ address, abi: ForwarderAbi, client });
2426
}
2527

@@ -28,6 +30,7 @@ export class ForwarderContract {
2830
walletClient: WalletClient<HttpTransport, Chain, Account>,
2931
publicClient: PublicClient<HttpTransport, Chain>,
3032
logger: Logger,
33+
rollupAddress: Hex,
3134
) {
3235
logger.info('Deploying forwarder contract');
3336

@@ -48,7 +51,7 @@ export class ForwarderContract {
4851

4952
logger.info(`Forwarder contract deployed at ${address} with owner ${owner}`);
5053

51-
return new ForwarderContract(publicClient, address.toString());
54+
return new ForwarderContract(publicClient, address.toString(), rollupAddress);
5255
}
5356

5457
public getAddress() {
@@ -60,6 +63,7 @@ export class ForwarderContract {
6063
l1TxUtils: L1TxUtils,
6164
gasConfig: L1GasConfig | undefined,
6265
blobConfig: L1BlobInputs | undefined,
66+
logger: Logger,
6367
) {
6468
requests = requests.filter(request => request.to !== null);
6569
const toArgs = requests.map(request => request.to!);
@@ -83,6 +87,7 @@ export class ForwarderContract {
8387
const stats = await l1TxUtils.getTransactionStats(receipt.transactionHash);
8488
return { receipt, gasPrice, stats };
8589
} else {
90+
logger.error('Forwarder transaction failed', { receipt });
8691
const args = {
8792
args: [toArgs, dataArgs],
8893
functionName: 'forward',
@@ -97,14 +102,30 @@ export class ForwarderContract {
97102
if (maxFeePerBlobGas === undefined) {
98103
errorMsg = 'maxFeePerBlobGas is required to get the error message';
99104
} else {
100-
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(data, args, {
101-
blobs: blobConfig.blobs,
102-
kzg: blobConfig.kzg,
103-
maxFeePerBlobGas,
104-
});
105+
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(
106+
data,
107+
args,
108+
{
109+
blobs: blobConfig.blobs,
110+
kzg: blobConfig.kzg,
111+
maxFeePerBlobGas,
112+
},
113+
[
114+
{
115+
address: this.rollupAddress,
116+
stateDiff: [
117+
{
118+
slot: toHex(RollupContract.checkBlobSlot, true),
119+
value: toHex(0n, true),
120+
},
121+
],
122+
},
123+
],
124+
);
105125
}
106126
} else {
107-
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(data, args);
127+
logger.info('Trying to get error from reverted tx without blob config');
128+
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(data, args, undefined, []);
108129
}
109130

110131
return { receipt, gasPrice, errorMsg };

yarn-project/ethereum/src/contracts/rollup.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { memoize } from '@aztec/foundation/decorators';
22
import { EthAddress } from '@aztec/foundation/eth-address';
33
import type { ViemSignature } from '@aztec/foundation/eth-signature';
4-
import { RollupAbi, SlasherAbi } from '@aztec/l1-artifacts';
4+
import { RollupAbi, RollupStorage, SlasherAbi } from '@aztec/l1-artifacts';
55

66
import {
77
type Account,
@@ -45,6 +45,14 @@ export type EpochProofQuoteViemArgs = {
4545
export class RollupContract {
4646
private readonly rollup: GetContractReturnType<typeof RollupAbi, PublicClient<HttpTransport, Chain>>;
4747

48+
static get checkBlobSlot(): bigint {
49+
const asString = RollupStorage.find(storage => storage.label === 'checkBlob')?.slot;
50+
if (asString === undefined) {
51+
throw new Error('checkBlobSlot not found');
52+
}
53+
return BigInt(asString);
54+
}
55+
4856
static getFromL1ContractsValues(deployL1ContractsValues: DeployL1Contracts) {
4957
const {
5058
publicClient,

yarn-project/ethereum/src/l1_tx_utils.ts

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { toHex } from '@aztec/foundation/bigint-buffer';
21
import { compactArray, times } from '@aztec/foundation/collection';
32
import {
43
type ConfigMappingsType,
@@ -663,27 +662,24 @@ export class L1TxUtils {
663662
abi: Abi;
664663
address: Hex;
665664
},
666-
blobInputs?: L1BlobInputs & { maxFeePerBlobGas: bigint },
665+
blobInputs: (L1BlobInputs & { maxFeePerBlobGas: bigint }) | undefined,
666+
stateOverride: {
667+
address: `0x${string}`;
668+
stateDiff: {
669+
slot: `0x${string}`;
670+
value: `0x${string}`;
671+
}[];
672+
}[] = [],
667673
) {
668674
try {
669675
// NB: If this fn starts unexpectedly giving incorrect blob hash errors, it may be because the checkBlob
670676
// bool is no longer at the slot below. To find the slot, run: forge inspect src/core/Rollup.sol:Rollup storage
671-
const checkBlobSlot = 9n;
672677
await this.publicClient.simulateContract({
673678
...args,
674679
account: this.walletClient.account,
675-
stateOverride: [
676-
{
677-
address: args.address,
678-
stateDiff: [
679-
{
680-
slot: toHex(checkBlobSlot, true),
681-
value: toHex(0n, true),
682-
},
683-
],
684-
},
685-
],
680+
stateOverride,
686681
});
682+
this.logger?.info('Simulated blob tx', { blobInputs });
687683
// If the above passes, we have a blob error. We cannot simulate blob txs, and failed txs no longer throw errors.
688684
// Strangely, the only way to throw the revert reason as an error and provide blobs is prepareTransactionRequest.
689685
// See: https://github.com/wevm/viem/issues/2075
@@ -702,7 +698,9 @@ export class L1TxUtils {
702698
to: args.address,
703699
data,
704700
};
701+
this.logger?.info('Preparing tx', { request });
705702
await this.walletClient.prepareTransactionRequest(request);
703+
this.logger?.info('Prepared tx');
706704
return undefined;
707705
} catch (simulationErr: any) {
708706
// If we don't have a ContractFunctionExecutionError, we have a blob related error => use getContractError to get the error msg.

yarn-project/l1-artifacts/scripts/generate-artifacts.sh

+13
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,17 @@ for contract_name in "${contracts[@]}"; do
108108
echo "export * from './${contract_name}Bytecode.js';" >>"generated/index.ts"
109109
done
110110

111+
# Generate RollupStorage.ts
112+
(
113+
echo "/**"
114+
echo " * Rollup storage."
115+
echo " */"
116+
echo -n "export const RollupStorage = "
117+
jq -j '.storage' "../../l1-contracts/out/Rollup.sol/storage.json"
118+
echo " as const;"
119+
) >"generated/RollupStorage.ts"
120+
121+
# Update index.ts exports
122+
echo "export * from './RollupStorage.js';" >>"generated/index.ts"
123+
111124
echo "Successfully generated TS artifacts!"

yarn-project/p2p/src/services/libp2p/libp2p_service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ export class LibP2PService<T extends P2PClientType> extends WithTracer implement
584584
}
585585

586586
private async processTxFromPeer(tx: Tx): Promise<void> {
587-
const txHash = tx.getTxHash();
587+
const txHash = await tx.getTxHash();
588588
const txHashString = txHash.toString();
589589
this.logger.verbose(`Received tx ${txHashString} from external peer.`);
590590
await this.mempools.txPool.addTxs([tx]);

yarn-project/prover-node/src/prover-node-publisher.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,17 @@ export class ProverNodePublisher {
229229
return receipt;
230230
} catch (err) {
231231
this.log.error(`Rollup submit epoch proof failed`, err);
232-
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(data, {
233-
args: [...txArgs],
234-
functionName: 'submitEpochRootProof',
235-
abi: RollupAbi,
236-
address: this.rollupContract.address,
237-
});
232+
const errorMsg = await this.l1TxUtils.tryGetErrorFromRevertedTx(
233+
data,
234+
{
235+
args: [...txArgs],
236+
functionName: 'submitEpochRootProof',
237+
abi: RollupAbi,
238+
address: this.rollupContract.address,
239+
},
240+
undefined,
241+
[],
242+
);
238243
this.log.error(`Rollup submit epoch proof tx reverted. ${errorMsg}`);
239244
return undefined;
240245
}

yarn-project/sequencer-client/src/client/sequencer-client.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,18 @@ export class SequencerClient {
8686
] as const);
8787
const forwarderContract =
8888
config.customForwarderContractAddress && config.customForwarderContractAddress !== EthAddress.ZERO
89-
? new ForwarderContract(publicClient, config.customForwarderContractAddress.toString())
90-
: await ForwarderContract.create(walletClient.account.address, walletClient, publicClient, log);
89+
? new ForwarderContract(
90+
publicClient,
91+
config.customForwarderContractAddress.toString(),
92+
config.l1Contracts.rollupAddress.toString(),
93+
)
94+
: await ForwarderContract.create(
95+
walletClient.account.address,
96+
walletClient,
97+
publicClient,
98+
log,
99+
config.l1Contracts.rollupAddress.toString(),
100+
);
91101

92102
const governanceProposerContract = new GovernanceProposerContract(
93103
publicClient,

yarn-project/sequencer-client/src/publisher/sequencer-publisher.ts

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ export class SequencerPublisher {
228228
this.l1TxUtils,
229229
gasConfig,
230230
blobConfig,
231+
this.log,
231232
);
232233
this.callbackBundledTransactions(validRequests, result);
233234
return result;

0 commit comments

Comments
 (0)