Commit 9195dcf2 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #1992 from ethereum-optimism/feat/hh-gas-oracle

feat(contracts): add in better gas oracle management
parents 9246754a 279603e5
---
'@eth-optimism/contracts': patch
---
Update hardhat task for managing the gas oracle
...@@ -7,8 +7,25 @@ import { predeploys } from '../src/predeploys' ...@@ -7,8 +7,25 @@ import { predeploys } from '../src/predeploys'
import { getContractDefinition } from '../src/contract-defs' import { getContractDefinition } from '../src/contract-defs'
task('set-l2-gasprice') task('set-l2-gasprice')
.addOptionalParam('l2GasPrice', 'Gas Price to set on L2', 0, types.int) .addOptionalParam(
'l2GasPrice',
'Gas Price to set on L2',
undefined,
types.int
)
.addOptionalParam('transactionGasPrice', 'tx.gasPrice', undefined, types.int) .addOptionalParam('transactionGasPrice', 'tx.gasPrice', undefined, types.int)
.addOptionalParam(
'overhead',
'amortized additional gas used by each batch that users must pay for',
undefined,
types.int
)
.addOptionalParam(
'scalar',
'amount to scale up the gas to charge',
undefined,
types.int
)
.addOptionalParam( .addOptionalParam(
'contractsRpcUrl', 'contractsRpcUrl',
'Sequencer HTTP Endpoint', 'Sequencer HTTP Endpoint',
...@@ -42,15 +59,45 @@ task('set-l2-gasprice') ...@@ -42,15 +59,45 @@ task('set-l2-gasprice')
throw new Error(`Incorrect key. Owner ${owner}, Signer ${addr}`) throw new Error(`Incorrect key. Owner ${owner}, Signer ${addr}`)
} }
// List the current values
const gasPrice = await GasPriceOracle.callStatic.gasPrice() const gasPrice = await GasPriceOracle.callStatic.gasPrice()
console.log(`Gas Price is currently ${gasPrice.toString()}`) const scalar = await GasPriceOracle.callStatic.scalar()
console.log(`Setting Gas Price to ${args.l2GasPrice}`) const overhead = await GasPriceOracle.callStatic.overhead()
const tx = await GasPriceOracle.connect(signer).setGasPrice( console.log('Current values:')
args.l2GasPrice, console.log(`Gas Price: ${gasPrice.toString()}`)
{ gasPrice: args.transactionGasPrice } console.log(`Scalar: ${scalar.toString()}`)
) console.log(`Overhead: ${overhead.toString()}`)
if (args.l2GasPrice !== undefined) {
console.log(`Setting gas price to ${args.l2GasPrice}`)
const tx = await GasPriceOracle.connect(signer).setGasPrice(
args.l2GasPrice,
{ gasPrice: args.transactionGasPrice }
)
const receipt = await tx.wait() const receipt = await tx.wait()
console.log(`Success - ${receipt.transactionHash}`) console.log(`Success - ${receipt.transactionHash}`)
}
if (args.scalar !== undefined) {
console.log(`Setting scalar to ${args.scalar}`)
const tx = await GasPriceOracle.connect(signer).setScalar(args.scalar, {
gasPrice: args.transactionGasPrice,
})
const receipt = await tx.wait()
console.log(`Success - ${receipt.transactionHash}`)
}
if (args.overhead !== undefined) {
console.log(`Setting overhead to ${args.overhead}`)
const tx = await GasPriceOracle.connect(signer).setOverhead(
args.overhead,
{ gasPrice: args.transactionGasPrice }
)
const receipt = await tx.wait()
console.log(`Success - ${receipt.transactionHash}`)
}
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment