Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalodner authored and joshuacolvin0 committed Dec 9, 2021
1 parent 5f2a82f commit be98be2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/arb-rpc-node/dev/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
6 changes: 3 additions & 3 deletions packages/arb-rpc-node/web3/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
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)),
applyGasPriceBidFactor(res.GasPrice),
ApplyGasPriceBidFactor(res.GasPrice),
})
}

0 comments on commit be98be2

Please sign in to comment.