diff --git a/ops/docker/Dockerfile.packages b/ops/docker/Dockerfile.packages index 8700a5ad4d..6a8efed295 100644 --- a/ops/docker/Dockerfile.packages +++ b/ops/docker/Dockerfile.packages @@ -53,6 +53,7 @@ COPY packages/message-relayer/package.json ./packages/message-relayer/package.js COPY integration-tests/package.json ./integration-tests/package.json COPY ops_boba/api/package.json ./ops_boba/api/package.json +COPY packages/boba/register/package.json ./packages/boba/register/package.json COPY packages/boba/contracts/package.json ./packages/boba/contracts/package.json COPY packages/boba/gas-price-oracle/package.json ./packages/boba/gas-price-oracle/package.json COPY packages/boba/turing/package.json ./packages/boba/turing/package.json @@ -116,6 +117,7 @@ ENTRYPOINT ["./scripts/wait-for-l1-and-l2.sh", "./scripts/deployer.sh"] FROM packages as data-transport-layer WORKDIR /opt/optimism/packages +COPY --from=builder /opt/optimism/packages/boba/register ./boba/register COPY --from=builder /opt/optimism/packages/data-transport-layer ./data-transport-layer WORKDIR /opt/optimism/packages/data-transport-layer RUN mkdir ./state-dumps diff --git a/packages/data-transport-layer/package.json b/packages/data-transport-layer/package.json index a09314b676..9aff7a6a1e 100644 --- a/packages/data-transport-layer/package.json +++ b/packages/data-transport-layer/package.json @@ -45,6 +45,7 @@ "@sentry/node": "^7.30.0", "@sentry/tracing": "^7.30.0", "@types/express": "^4.17.12", + "@boba/register": "0.0.1", "axios": "^0.21.1", "bcfg": "^0.1.6", "bfj": "^7.0.2", diff --git a/packages/data-transport-layer/src/services/l1-ingestion/addresses.ts b/packages/data-transport-layer/src/services/l1-ingestion/addresses.ts new file mode 100644 index 0000000000..c8c1e4cd99 --- /dev/null +++ b/packages/data-transport-layer/src/services/l1-ingestion/addresses.ts @@ -0,0 +1,33 @@ +import fs from 'fs' +import { constants } from 'ethers' + +export const getAddress = async ( + contractAddress: string, + contractName: string +): Promise => { + const dirname: string = 'node_modules/@boba/register/addresses' // TODO + + try { + const files = await fs.readdirSync( + dirname, + { withFileTypes: false } + ) + + for (const fileName of files) { + if (!fileName.includes(contractAddress)) { + continue + } + const content = fs.readFileSync(`${dirname}/${fileName}`, { + encoding: 'utf-8', + }) + const parsed = JSON.parse(content) + return parsed[contractName] ?? constants.AddressZero + } + } catch (error) { + console.log(error.message) + throw new Error( + 'Could not load address for contract from local json files!' + ) + } + return constants.AddressZero +} diff --git a/packages/data-transport-layer/src/services/l1-ingestion/service.ts b/packages/data-transport-layer/src/services/l1-ingestion/service.ts index b4192f6589..6010a92a75 100644 --- a/packages/data-transport-layer/src/services/l1-ingestion/service.ts +++ b/packages/data-transport-layer/src/services/l1-ingestion/service.ts @@ -29,6 +29,7 @@ import { } from '../../utils' import { EventHandlerSet } from '../../types' import { L1DataTransportServiceOptions } from '../main/service' +import { getAddress } from "./addresses"; interface L1IngestionMetrics { highestSyncedL1Block: Gauge @@ -486,7 +487,19 @@ export class L1IngestionService extends BaseService { blockNumber ) } else { - events = await this.state.contracts.Lib_AddressManager.queryFilter( + // import addresses_BobaBase from "@boba/register/addresses/addressesBobaBase_0xF8d0bF3a1411AC973A606f90B2d1ee0840e5979B" + // TODO: Instead look up from addresses.json file + const addrMgr = this.state.contracts.Lib_AddressManager.address + console.log("ADDDDDD", addrMgr) + + const address = await getAddress( + this.state.contracts.Lib_AddressManager.address, + contractName + ) + return address + } + + /*events = await this.state.contracts.Lib_AddressManager.queryFilter( this.state.contracts.Lib_AddressManager.filters.AddressSet( contractName ), @@ -499,7 +512,7 @@ export class L1IngestionService extends BaseService { } else { // Address wasn't set before this. return constants.AddressZero - } + }*/ } private async _findStartingL1BlockNumber(): Promise {