Skip to content
This repository has been archived by the owner on Apr 11, 2021. It is now read-only.

Commit

Permalink
chore: adjust review comments
Browse files Browse the repository at this point in the history
* do not cast gasUsed
* adjust comment on GasPrice method
* add nil check for args.Data
* log gas price changes in the sync service
  • Loading branch information
gakonst committed Mar 27, 2021
1 parent 8bce251 commit aaa0a34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/rollup_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 5 additions & 1 deletion internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions rollup/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aaa0a34

Please sign in to comment.