Skip to content

Commit

Permalink
update: move gasPrice multiplier near the gas limit for better clarif…
Browse files Browse the repository at this point in the history
…ying
  • Loading branch information
mhrynenko committed May 8, 2024
1 parent 34060d2 commit 9c94f65
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions internal/service/api/handlers/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func Register(w http.ResponseWriter, r *http.Request) {
ape.RenderErr(w, problems.InternalError())
return
}
gasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier)

NetworkConfig(r).LockNonce()
defer NetworkConfig(r).UnlockNonce()
Expand All @@ -106,7 +105,7 @@ func Register(w http.ResponseWriter, r *http.Request) {
&types.LegacyTx{
Nonce: NetworkConfig(r).Nonce(),
Gas: uint64(float64(gas) * NetworkConfig(r).GasMultiplier),
GasPrice: gasPrice,
GasPrice: multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier),
To: &registration,
Data: dataBytes,
},
Expand Down
3 changes: 1 addition & 2 deletions internal/service/api/handlers/transit_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ func getTxOpts(r *http.Request, receiver common.Address, txData []byte) (*bind.T
if err != nil {
return nil, errors.Wrap(err, "failed to suggest gas price")
}
gasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier)

gasLimit, err := EthClient(r).EstimateGas(r.Context(), ethereum.CallMsg{
From: crypto.PubkeyToAddress(NetworkConfig(r).PrivateKey.PublicKey),
Expand All @@ -123,7 +122,7 @@ func getTxOpts(r *http.Request, receiver common.Address, txData []byte) (*bind.T
}

txOpts.Nonce = new(big.Int).SetUint64(NetworkConfig(r).Nonce())
txOpts.GasPrice = gasPrice
txOpts.GasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier)
txOpts.GasLimit = uint64(float64(gasLimit) * NetworkConfig(r).GasMultiplier)

return txOpts, nil
Expand Down
3 changes: 1 addition & 2 deletions internal/service/api/handlers/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func Vote(w http.ResponseWriter, r *http.Request) {
ape.RenderErr(w, problems.InternalError())
return
}
gasPrice = multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier)

NetworkConfig(r).LockNonce()
defer NetworkConfig(r).UnlockNonce()
Expand All @@ -77,7 +76,7 @@ func Vote(w http.ResponseWriter, r *http.Request) {
&types.LegacyTx{
Nonce: NetworkConfig(r).Nonce(),
Gas: uint64(float64(gas) * NetworkConfig(r).GasMultiplier),
GasPrice: gasPrice,
GasPrice: multiplyGasPrice(gasPrice, NetworkConfig(r).GasMultiplier),
To: &voting,
Data: dataBytes,
},
Expand Down

0 comments on commit 9c94f65

Please sign in to comment.