Skip to content

Commit

Permalink
Merge pull request #18 from base-org/jack/update-ts-filler
Browse files Browse the repository at this point in the history
fix proof generation script for contract testing compatibility
  • Loading branch information
jackchuma authored Nov 18, 2024
2 parents a55acf5 + 66c157d commit 4e2d8cf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
1 change: 0 additions & 1 deletion services/ts-filler/Proof.json

This file was deleted.

5 changes: 3 additions & 2 deletions services/ts-filler/scripts/generateProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import config from "../src/config";
import chains from "../src/chain/chains";
import { SupportedChains } from "../src/common/types/chain";
import ConfigService from "../src/config/config.service";
import { replaceBigInts } from "../src/common/utils/bigIntReplacer";

// Generate and store proof in json file to be used for testing
async function main() {
Expand All @@ -26,9 +27,9 @@ async function main() {
const configService = new ConfigService();
const chainService = new ChainService(activeChains, configService);
const prover = new Prover(activeChains, chainService);
const proof = await prover.generateProof();
const proof = await prover.generateProof(config.requestHash);

await Bun.write("./Proof.json", JSON.stringify(proof));
await Bun.write("./Proof.json", JSON.stringify(proof, replaceBigInts));
}

main().catch((error) => {
Expand Down
6 changes: 3 additions & 3 deletions services/ts-filler/src/chain/chain.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class ChainService {
// 1. Get latest node from Rollup contract
const nodeIndex: bigint = await exponentialBackoff(async () => {
return await this.activeChains.l1.publicClient.readContract({
address: this.activeChains.l1.contracts.arbRollupAddr,
address: this.activeChains.l1.contracts.arbRollup,
abi: ArbitrumRollup,
functionName: "latestConfirmed",
});
Expand Down Expand Up @@ -155,7 +155,7 @@ export default class ChainService {
private async getLogs(index: bigint): Promise<Log[]> {
const etherscanApiKey = this.configService.getOrThrow("ETHERSCAN_API_KEY");
const url = `https://api-sepolia.etherscan.io/api?module=logs&action=getLogs&address=${
this.activeChains.l1.contracts.arbRollupAddr
this.activeChains.l1.contracts.arbRollup
}&topic0=0x4f4caa9e67fb994e349dd35d1ad0ce23053d4323f83ce11dc817b5435031d096&topic0_1_opr=and&topic1=${toHex(
index,
{ size: 32 }
Expand All @@ -169,7 +169,7 @@ export default class ChainService {
const [, l2BlockNumber]: [any, bigint] = await exponentialBackoff(
async () => {
return await config.publicClient.readContract({
address: config.contracts.anchorStateRegistryAddr,
address: config.contracts.anchorStateRegistry,
abi: AnchorStateRegistry,
functionName: "anchors",
args: [0n],
Expand Down
1 change: 1 addition & 0 deletions services/ts-filler/src/chain/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
l2OracleStorageKey:
"0x0000000000000000000000000000000000000000000000000000000000000076",
contracts: {
// inbox: "0x49E2cDC9e81825B6C718ae8244fe0D5b062F4874", // mock verifier address
inbox: "0xeE962eD1671F655a806cB22623eEA8A7cCc233bC",
outbox: "0xBCd5762cF9B07EF5597014c350CE2efB2b0DB2D2",
},
Expand Down
6 changes: 6 additions & 0 deletions services/ts-filler/src/common/utils/bigIntReplacer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function replaceBigInts(_: any, v: any): any {
if (typeof v === "bigint") {
return v.toString();
}
return v;
}
2 changes: 1 addition & 1 deletion services/ts-filler/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default {
// requestHash:
// "0xe38ad8c9e84178325f28799eb3aaae72551b2eea7920c43d88854edd350719f5" as Address, // opt-sep
requestHash:
"0xd758704a57f68d8454a2e178564de8917b3f5403c103f296ec973c5c0844850c" as Address,
"0x2ac60f23d7c0dea48c6b0383f3f3c4453a0983beb90d45cbee51ba52a4b4b0f9" as Address,
};
10 changes: 5 additions & 5 deletions services/ts-filler/src/prover/prover.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default class ProverService {
this.buildL1Proof(l1BlockNumber, nodeIndex)
),
dstConfig.publicClient.getProof({
// address: addresses[dstChain].opSepoliaWethAddr,
address: dstConfig.contracts.rip7755VerifierContractAddr,
// address: dstConfig.contracts.weth,
address: dstConfig.contracts.inbox,
storageKeys: [l2Slot],
blockNumber: l2Block.number,
}),
Expand All @@ -105,7 +105,7 @@ export default class ProverService {
if (dstConfig.chainId === SupportedChains.OptimismSepolia) {
calls.push(
dstConfig.publicClient.getProof({
address: dstConfig.contracts.l2MessagePasserAddr,
address: dstConfig.contracts.l2MessagePasser,
storageKeys: [],
blockNumber: l2Block.number,
})
Expand All @@ -124,14 +124,14 @@ export default class ProverService {
nodeIndex?: bigint
): { address: Address; storageKeys: Address[]; blockNumber: bigint } {
const l1Config = this.activeChains.l1;
let address = l1Config.contracts.anchorStateRegistryAddr;
let address = l1Config.contracts.anchorStateRegistry;
let storageKeys = [constants.slots.anchorStateRegistrySlot];

if (this.activeChains.dst.chainId === SupportedChains.ArbitrumSepolia) {
if (!nodeIndex) {
throw new Error("Node index is required for Arbitrum proofs");
}
address = l1Config.contracts.arbRollupAddr;
address = l1Config.contracts.arbRollup;
const slot = 118n;
const offset = 2n; // confirmData is offset by 2 slots in Node struct
const derivedSlotStart = keccak256(
Expand Down

0 comments on commit 4e2d8cf

Please sign in to comment.