From be98be2484f9390ecc2bc01c10ba173a904ecc69 Mon Sep 17 00:00:00 2001 From: Harry Kalodner Date: Thu, 9 Dec 2021 03:17:30 -0500 Subject: [PATCH] Fix test --- packages/arb-rpc-node/dev/fees_test.go | 2 +- packages/arb-rpc-node/web3/eth.go | 6 +++--- packages/arb-rpc-node/web3/nodeInterface.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/arb-rpc-node/dev/fees_test.go b/packages/arb-rpc-node/dev/fees_test.go index de9ab5f65f..7186ee30ee 100644 --- a/packages/arb-rpc-node/dev/fees_test.go +++ b/packages/arb-rpc-node/dev/fees_test.go @@ -369,7 +369,7 @@ func TestRetryableFee(t *testing.T) { res, _, err := backend.db.GetRequest(redeemId) test.FailIfError(t, err) - if new(big.Int).Mul(res.GasPrice, big.NewInt(2)).Cmp(gasPriceEstimate) != 0 { + if web3.ApplyGasPriceBidFactor(res.GasPrice).Cmp(gasPriceEstimate) != 0 { t.Error("wrong gas price") } diff --git a/packages/arb-rpc-node/web3/eth.go b/packages/arb-rpc-node/web3/eth.go index 01ce27b55d..d1d30f72a1 100644 --- a/packages/arb-rpc-node/web3/eth.go +++ b/packages/arb-rpc-node/web3/eth.go @@ -43,7 +43,7 @@ var gasPriceFactorNum = big.NewInt(5) var gasPriceFactorDenom = big.NewInt(4) var gasEstimationCushion = 10 -func applyGasPriceBidFactor(price *big.Int) *big.Int { +func ApplyGasPriceBidFactor(price *big.Int) *big.Int { adjustedPrice := new(big.Int).Mul(price, gasPriceFactorNum) return adjustedPrice.Div(adjustedPrice, gasPriceFactorDenom) } @@ -102,7 +102,7 @@ func (s *Server) GasPrice() (*hexutil.Big, error) { if err != nil { return nil, err } - return (*hexutil.Big)(applyGasPriceBidFactor(prices[5])), nil + return (*hexutil.Big)(ApplyGasPriceBidFactor(prices[5])), nil } func (s *Server) Accounts() []common.Address { @@ -291,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(applyGasPriceBidFactor(res.FeeStats.Price.L2Computation).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() diff --git a/packages/arb-rpc-node/web3/nodeInterface.go b/packages/arb-rpc-node/web3/nodeInterface.go index fb1213a5e5..51d38ecfc3 100644 --- a/packages/arb-rpc-node/web3/nodeInterface.go +++ b/packages/arb-rpc-node/web3/nodeInterface.go @@ -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)), - applyGasPriceBidFactor(res.GasPrice), + ApplyGasPriceBidFactor(res.GasPrice), }) }