Skip to content

Commit

Permalink
chore: scale down optimism (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladinlight authored Jul 24, 2024
1 parent e7c907d commit 05283c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ aliases:
api-cpu-threshold: 75
api-memory-limit: 1Gi
api-memory-request: 500Mi
stateful-service-replicas: 2
stateful-service-replicas: 1
service-name-1: daemon
service-image-1: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:v1.101315.2
service-cpu-limit-1: "2"
Expand Down Expand Up @@ -473,7 +473,7 @@ aliases:
api-replicas: 1
api-max-replicas: 2
api-memory-limit: 500Mi
stateful-service-replicas: 1
stateful-service-replicas: 0

- &bnbsmartchain
assetName: bnbsmartchain
Expand Down
21 changes: 14 additions & 7 deletions node/coinstacks/optimism/api/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,19 @@ export class Optimism extends EVM implements BaseAPI, API {

// ecotone l1GasPrice = ((l1BaseFee * baseFeeScalar * 16) + (blobBaseFee * baseFeeScalar)) / (16 * 10^decimals)
if (isEcotone) {
const l1BaseFee = BigNumber.from(await gpo.l1BaseFee())
const baseFeeScalar = BigNumber.from(await gpo.baseFeeScalar())
const blobBaseFee = BigNumber.from(await gpo.blobBaseFeeScalar())
const blobBaseFeeScalar = BigNumber.from(await gpo.blobBaseFeeScalar())
const [l1BaseFee, baseFeeScalar, blobBaseFee, blobBaseFeeScalar, decimals] = (
await Promise.all([
gpo.l1BaseFee(),
gpo.baseFeeScalar(),
gpo.blobBaseFeeScalar(),
gpo.blobBaseFeeScalar(),
gpo.decimals(),
])
).map((value) => BigNumber.from(value))

const scaledBaseFee = l1BaseFee.mul(baseFeeScalar).mul(16)
const scaledBlobBaseFee = blobBaseFee.mul(blobBaseFeeScalar)

const decimals = BigNumber.from(await gpo.decimals())
const l1GasPrice = new BN(scaledBaseFee.add(scaledBlobBaseFee).toString()).div(
new BN(16).times(new BN(10).exponentiatedBy(decimals.toString()))
)
Expand All @@ -151,8 +156,10 @@ export class Optimism extends EVM implements BaseAPI, API {
}

// legacy l1GasPrice = l1BaseFee * scalar
const l1BaseFee = BigNumber.from(await gpo.l1BaseFee())
const scalar = BigNumber.from(await gpo.scalar())
const [l1BaseFee, scalar] = (await Promise.all([gpo.l1BaseFee(), gpo.scalar()])).map((value) =>
BigNumber.from(value)
)

const l1GasPrice = l1BaseFee.mul(scalar)

return { l1GasPrice: l1GasPrice.toString(), ...gasFees }
Expand Down

0 comments on commit 05283c5

Please sign in to comment.