From aaa0a346c751070a8ae5f609deade4572c7b9978 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Tue, 23 Mar 2021 12:45:19 +0200 Subject: [PATCH] chore: adjust review comments * do not cast gasUsed * adjust comment on GasPrice method * add nil check for args.Data * log gas price changes in the sync service --- core/rollup_fee.go | 2 +- internal/ethapi/api.go | 6 +++++- rollup/sync_service.go | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/rollup_fee.go b/core/rollup_fee.go index d1d1614cb..bee222ec0 100644 --- a/core/rollup_fee.go +++ b/core/rollup_fee.go @@ -16,7 +16,7 @@ func CalculateRollupFee(data []byte, gasUsed uint64, dataPrice, executionPrice * dataLen := int64(ROLLUP_BASE_TX_SIZE + len(data)) // get the data fee dataFee := new(big.Int).Mul(dataPrice, big.NewInt(dataLen)) - executionFee := new(big.Int).Mul(executionPrice, big.NewInt(int64(gasUsed))) + executionFee := new(big.Int).Mul(executionPrice, new(big.Int).SetUint64(gasUsed)) fee := new(big.Int).Add(dataFee, executionFee) return fee } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index f16cc27ce..d80a8d51a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -63,7 +63,7 @@ func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI { return &PublicEthereumAPI{b} } -// GasPrice returns 1 gwei always. Rationale: https://github.com/ethereum-optimism/roadmap/issues/715 +// GasPrice always returns 1 gwei. See `DoEstimateGas` below for context. func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { return (*hexutil.Big)(big.NewInt(defaultGasPrice)), nil } @@ -1001,6 +1001,10 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr // fees can compensate for the additional costs the sequencer pays for publishing the // transaction calldata func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (hexutil.Uint64, error) { + if args.Data == nil { + return 0, errors.New("transaction data cannot be nil") + } + // 1. get the gas that would be used by the transaction gasUsed, err := legacyDoEstimateGas(ctx, b, args, blockNrOrHash, gasCap) if err != nil { diff --git a/rollup/sync_service.go b/rollup/sync_service.go index 56a9d0827..b38683448 100644 --- a/rollup/sync_service.go +++ b/rollup/sync_service.go @@ -366,6 +366,7 @@ func (s *SyncService) sequence() error { return err } s.L1gpo.SetL1GasPrice(l1GasPrice) + log.Info("Adjusted L1 Gas Price", "gasprice", l1GasPrice) // Only the sequencer needs to poll for enqueue transactions // and then can choose when to apply them. We choose to apply