Skip to content

Commit

Permalink
chore: remove abi refs from publisher (#10766)
Browse files Browse the repository at this point in the history
Removes unecessary import of abis to `l1-publisher`, now that we add
errors to the `RollupAbi` (thanks to #10697). This means we can remove
my ugly code to try and catch blob and leonidas errors from a header
check.

---

Note: I found that the use of `getContractError` is still needed in
`tryGetErrorFromRevertedTx`. Viem doesn't play nice when simulating blob
txs and either doesn't allow blob sidecars (hence the `checkBlobSlot`
override) or doesn't throw an error to catch.

I found a middle ground where `prepareTransactionRequest` would throw
with the error we wanted in the case of a blob issue (e.g. incorrect
blob proof), but this error still only has the selector thrown and not
the custom name e.g.
`Execution reverted with reason: custom error 0x5ca17bef:
0113d536ef349476f9a5112623449dd1cf574b8213bc6fe33c1edd63bf832890.`
To get the name, I used viem's `getContractError` which works fine:
`The contract function "propose" reverted. Error:
Rollup__InvalidBlobProof(bytes32 blobHash)
(0x0113d536ef349476f9a5112623449dd1cf574b8213bc6fe33c1edd63bf832890)`

---

Another note: I also snuck in adding the issue number for #10754 in some
comments (sorry)
  • Loading branch information
MirandaWood authored Jan 8, 2025
1 parent 6f07132 commit 17d6802
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
3 changes: 3 additions & 0 deletions noir-projects/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test:
test-protocol-circuits:
FROM ../+bootstrap
ENV PATH="/usr/src/noir/noir-repo/target/release:${PATH}"
# TODO(#10754): Remove --skip-brillig-constraints-check
RUN cd /usr/src/noir-projects/noir-protocol-circuits && nargo test --silence-warnings --skip-brillig-constraints-check

test-aztec-nr:
Expand Down Expand Up @@ -52,6 +53,8 @@ gates-report:

# Install bb
ENV BB_BIN /usr/src/barretenberg/cpp/build/bin/bb

# TODO(#10754): Remove --skip-brillig-constraints-check
RUN cd noir-protocol-circuits && yarn && node ./scripts/generate_variants.js tiny && nargo compile --silence-warnings --skip-brillig-constraints-check

COPY ./gates_report.sh ./gates_report.sh
Expand Down
2 changes: 1 addition & 1 deletion noir-projects/noir-protocol-circuits/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function compile {
if ! cache_download circuit-$hash.tar.gz 1>&2; then
SECONDS=0
rm -f $json_path
# TODO: --skip-brillig-constraints-check added temporarily for blobs build time.
# TODO(#10754): Remove --skip-brillig-constraints-check
local compile_cmd="$NARGO compile --package $name --skip-brillig-constraints-check"
echo_stderr "$compile_cmd"
dump_fail "$compile_cmd"
Expand Down
43 changes: 5 additions & 38 deletions yarn-project/sequencer-client/src/publisher/l1-publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
import { type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
import { InterruptibleSleep } from '@aztec/foundation/sleep';
import { Timer } from '@aztec/foundation/timer';
import { EmpireBaseAbi, ExtRollupLibAbi, LeonidasLibAbi, RollupAbi, SlasherAbi } from '@aztec/l1-artifacts';
import { EmpireBaseAbi, RollupAbi, SlasherAbi } from '@aztec/l1-artifacts';
import { type TelemetryClient } from '@aztec/telemetry-client';

import pick from 'lodash.pick';
import {
type BaseError,
type Chain,
type Client,
ContractFunctionExecutionError,
type ContractFunctionExecutionError,
ContractFunctionRevertedError,
type GetContractReturnType,
type Hex,
Expand Down Expand Up @@ -421,38 +421,6 @@ export class L1Publisher {
if (error instanceof ContractFunctionRevertedError) {
const err = error as ContractFunctionRevertedError;
this.log.debug(`Validation failed: ${err.message}`, err.data);
} else if (error instanceof ContractFunctionExecutionError) {
let err = error as ContractFunctionRevertedError;
if (!tryGetCustomErrorName(err)) {
// If we get here, it's because the custom error no longer exists in Rollup.sol,
// but in another lib. The below reconstructs the error message.
try {
await this.publicClient.estimateGas({
data: encodeFunctionData({
abi: this.rollupContract.abi,
functionName: 'validateHeader',
args,
}),
account: this.account,
to: this.rollupContract.address,
});
} catch (estGasErr: unknown) {
const possibleAbis = [ExtRollupLibAbi, LeonidasLibAbi];
possibleAbis.forEach(abi => {
const possibleErr = getContractError(estGasErr as BaseError, {
args: [],
abi: abi,
functionName: 'validateHeader',
address: this.rollupContract.address,
sender: this.account.address,
});
err = tryGetCustomErrorName(possibleErr) ? possibleErr : err;
});
}
throw err;
}
} else {
this.log.debug(`Unexpected error during validation: ${error}`);
}
throw error;
}
Expand Down Expand Up @@ -771,8 +739,7 @@ export class L1Publisher {
},
],
});
// If the above passes, we have a blob error. We cannot simulate blob txs, and failed txs no longer throw errors,
// and viem provides no way to get the revert reason from a given tx.
// If the above passes, we have a blob error. We cannot simulate blob txs, and failed txs no longer throw errors.
// Strangely, the only way to throw the revert reason as an error and provide blobs is prepareTransactionRequest.
// See: https://github.com/wevm/viem/issues/2075
// This throws a EstimateGasExecutionError with the custom error information:
Expand All @@ -784,13 +751,13 @@ export class L1Publisher {
});
return undefined;
} catch (simulationErr: any) {
// If we don't have a ContractFunctionExecutionError, we have a blob related error => use ExtRollupLibAbi to get the error msg.
// If we don't have a ContractFunctionExecutionError, we have a blob related error => use getContractError to get the error msg.
const contractErr =
simulationErr.name === 'ContractFunctionExecutionError'
? simulationErr
: getContractError(simulationErr as BaseError, {
args: [],
abi: ExtRollupLibAbi,
abi: RollupAbi,
functionName: args.functionName,
address: args.address,
sender: this.account.address,
Expand Down

0 comments on commit 17d6802

Please sign in to comment.