Skip to content

Commit

Permalink
requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adraffy committed Oct 30, 2024
1 parent 0a11cc0 commit 0b9e39a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
16 changes: 8 additions & 8 deletions contracts/TrustedVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ contract TrustedVerifier is IGatewayVerifier {

mapping(address fetcher => Config) _configs;

function gatewayURLs() external view returns (string[] memory) {
return _configs[msg.sender].urls;
}

function getLatestContext() external view returns (bytes memory) {
return abi.encode(block.timestamp, msg.sender);
}

modifier _canModifyFetcher(address op, address fetcher) {
if (fetcher == op) {
require(fetcher.code.length != 0, 'Trusted: not code');
Expand Down Expand Up @@ -82,6 +74,14 @@ contract TrustedVerifier is IGatewayVerifier {
return _configs[sender].signers[signer];
}

function gatewayURLs() external view returns (string[] memory) {
return _configs[msg.sender].urls;
}

function getLatestContext() external view returns (bytes memory) {
return abi.encode(block.timestamp, msg.sender);
}

struct GatewayProof {
bytes signature;
uint64 signedAt;
Expand Down
3 changes: 3 additions & 0 deletions scripts/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ function getProverFactory(chain: Chain): LatestProverFactory<AbstractProver> {
case CHAINS.ZKSYNC_SEPOLIA:
return ZKSyncProver;
// NOTE: linea should use eth_getProof instead of linea_getProof
// NOTE: this probably needs "--latest" cli option too
// rollup => SMT w/Mimc root using linea_getProof
// chain => PMT w/Keccak root using eth_getProof
// case CHAINS.LINEA:
// case CHAINS.LINEA_SEPOLIA:
// return LineaProver;
Expand Down
7 changes: 5 additions & 2 deletions src/GatewayProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ export class GatewayProvider extends JsonRpcProvider {
let backoff = 250;
for (let attempt = 0; ; attempt++) {
try {
// ethers bug: this type is wrong
// ethers bug: return type is wrong
// expected: (JsonRpcResult | JsonRpcErrror)[]
const results: any[] = await super._send(payload);
if (!results.some((x) => x.error?.code === 429)) {
// what the fuck is this
// handle alchemy weirdness
// note: this is only supposed to happen over WebSocket
// note: there is no header "retry-after"
// https://docs.alchemy.com/reference/throughput
return results;
}
Expand Down
4 changes: 0 additions & 4 deletions src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export const CHAINS = {
APE: 33139n,
} as const satisfies Record<string, Chain>;

// const NAMES = new Map<Chain, string>(
// Object.entries(CHAINS).map(([a, b]) => [b, a])
// );

export function chainName(chain: Chain): string {
for (const [name, c] of Object.entries(CHAINS)) {
if (c === chain) return name;
Expand Down
2 changes: 1 addition & 1 deletion src/linea/LineaProver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class LineaProver extends BlockProver {
// 20240825: most cloud providers seem to reject batched getProof
// since we aren't in control of provider construction (ie. batchMaxSize)
// sendImmediate is a temporary hack to avoid this issue
// 20241027: switch to RetryProvider
// 20241027: use GatewayProvider
this.provider.send('linea_getProof', [
target,
slots
Expand Down
7 changes: 5 additions & 2 deletions src/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ function checkSize(size: bigint | number, limit: number) {
}

const GATEWAY_EXT_ABI = new Interface([
// IReadBytesAt.sol
// ReadBytesAt.sol
'function readBytesAt(uint256 slot) view returns (bytes)',
]);

Expand Down Expand Up @@ -560,7 +560,10 @@ export abstract class AbstractProver {
storageProofs: Array.from(order.subarray(1), (i) => proofs[i]),
};
}
// non-essential
// NOTE: if a prover cannot provide this value, throw
// eg. LineaProver stateRoot is part of the rollup machinery
// a block-derived LineaProver doesn't have a stateRoot
// whereas LineaRollup => getCommit() => prover does (from L1)
abstract fetchStateRoot(): Promise<HexString32>;

// machine interface
Expand Down
1 change: 1 addition & 0 deletions test/gateway/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export function testTrustedEth(chain2: Chain, opts: TestOptions) {
EthProver,
new SigningKey(randomBytes(32))
);
rollup.latestBlockTag = 'latest';
afterAll(foundry.shutdown);
const gateway = new Gateway(rollup);
const ccip = await serve(gateway, { protocol: 'raw', log: !!opts.log });
Expand Down

0 comments on commit 0b9e39a

Please sign in to comment.