Skip to content

Commit

Permalink
Low gas price bid factor from 2 to 1.25
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalodner authored and joshuacolvin0 committed Dec 9, 2021
1 parent 2ad1d6c commit 5f2a82f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/arb-rpc-node/web3/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ import (
"github.com/offchainlabs/arbitrum/packages/arb-util/machine"
)

var gasPriceFactor = big.NewInt(2)
var gasPriceFactorNum = big.NewInt(5)
var gasPriceFactorDenom = big.NewInt(4)
var gasEstimationCushion = 10

func applyGasPriceBidFactor(price *big.Int) *big.Int {
adjustedPrice := new(big.Int).Mul(price, gasPriceFactorNum)
return adjustedPrice.Div(adjustedPrice, gasPriceFactorDenom)
}

const maxGas = 1<<31 - 1

type ServerConfig struct {
Expand Down Expand Up @@ -96,7 +102,7 @@ func (s *Server) GasPrice() (*hexutil.Big, error) {
if err != nil {
return nil, err
}
return (*hexutil.Big)(new(big.Int).Mul(prices[5], gasPriceFactor)), nil
return (*hexutil.Big)(applyGasPriceBidFactor(prices[5])), nil
}

func (s *Server) Accounts() []common.Address {
Expand Down Expand Up @@ -285,7 +291,7 @@ func (s *Server) EstimateGas(args CallTxArgs) (hexutil.Uint64, error) {
if res.FeeStats.Price.L2Computation.Cmp(big.NewInt(0)) == 0 {
return hexutil.Uint64(res.GasUsed.Uint64() + 10000), nil
} else {
extraCalldataUnits := (len(res.FeeStats.GasUsed().Bytes()) + len(new(big.Int).Mul(res.FeeStats.Price.L2Computation, gasPriceFactor).Bytes()) + gasEstimationCushion) * 16
extraCalldataUnits := (len(res.FeeStats.GasUsed().Bytes()) + len(applyGasPriceBidFactor(res.FeeStats.Price.L2Computation).Bytes()) + gasEstimationCushion) * 16
// Adjust calldata units used for calldata from gas limit
res.FeeStats.UnitsUsed.L1Calldata = res.FeeStats.UnitsUsed.L1Calldata.Add(res.FeeStats.UnitsUsed.L1Calldata, big.NewInt(int64(extraCalldataUnits)))
used := res.FeeStats.TargetGasUsed()
Expand Down
2 changes: 1 addition & 1 deletion packages/arb-rpc-node/web3/nodeInterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ func handleEstimateRetryableTicket(srv *Server, calldata []byte, blockNum rpc.Bl
used = used.Div(used, big.NewInt(10))
return estimateRetryableTicket.Outputs.PackValues([]interface{}{
new(big.Int).Add(used, big.NewInt(100)),
new(big.Int).Mul(res.GasPrice, gasPriceFactor),
applyGasPriceBidFactor(res.GasPrice),
})
}

0 comments on commit 5f2a82f

Please sign in to comment.