Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build blocks for adblock #6

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tasks/build-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@
method?: string,
}
const builderInterface = utils.getInterface('EthBlockBidSenderContract')
const adbidInterface = utils.getInterface('BlockAdAuctionV2')

task('build-blocks', 'Build blocks and send them to relay')
.addOptionalParam('nslots', 'Number of slots to build blocks for. Default is two.', 1, types.int)
.addOptionalParam('nslots', 'Number of slots to build blocks for.', 1, types.int)
.addOptionalParam('builder', 'Address of a Builder contract. By default fetch most recently deployed one.')
.addFlag('blockad', 'Whether to build blocks for ad-bids')
.setAction(async function (taskArgs: any, hre: HRE) {

Check warning on line 32 in tasks/build-blocks.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 32 in tasks/build-blocks.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
utils.checkChain(hre, [SUAVE_CHAIN_ID, RIGIL_CHAIN_ID])
const config = await getConfig(hre, taskArgs)

console.log(`Sending blocks for the next ${config.nSlots} slots`)
console.log(`Suave signer: ${config.suaveSigner.address}`)

await doBlockBuilding(config, null)
await doBlockBuilding(config, config.buildOpts)
})

export async function doBlockBuilding(c: ITaskConfig, opt?: IBuildOptions) {
Expand Down Expand Up @@ -185,9 +187,10 @@
suaveSigner: Wallet,
relayUrl: string,
beaconUrl: string,
buildOpts?: IBuildOptions,
}

async function getConfig(hre: HRE, taskArgs: any): Promise<ITaskConfig> {

Check warning on line 193 in tasks/build-blocks.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 193 in tasks/build-blocks.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const useTestnet = utils.getNetworkChainId(hre) === RIGIL_CHAIN_ID
const cliConfig = await parseTaskArgs(hre, taskArgs)
const envConfig = getEnvConfig(useTestnet)
Expand All @@ -211,11 +214,15 @@
}
}

async function parseTaskArgs(hre: HRE, taskArgs: any) {

Check warning on line 217 in tasks/build-blocks.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 217 in tasks/build-blocks.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const nSlots = parseInt(taskArgs.nslots)
const builderCName = taskArgs.blockad ? 'BlockAdAuctionV2' : 'Builder'
const builderAdd = taskArgs.builder
? taskArgs.builder
: await utils.fetchDeployedContract(hre, 'Builder').then(c => c.address)
: await utils.fetchDeployedContract(hre, builderCName).then(c => c.address)
const buildOpts = taskArgs.blockad
? { iface: adbidInterface, method: 'buildBlock' }
: null

return { nSlots, builderAdd }
return { nSlots, builderAdd, buildOpts }
}
Loading