Skip to content

Commit

Permalink
feat: introduce min gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrekucci committed Dec 2, 2022
1 parent aba4328 commit 9915106
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
13 changes: 7 additions & 6 deletions pkg/storageincentives/redistribution/redistribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,13 @@ func (c *contract) Reveal(ctx context.Context, storageDepth uint8, reserveCommit
return err
}
request := &transaction.TxRequest{
To: &c.incentivesContractAddress,
Data: callData,
GasPrice: sctx.GetGasPrice(ctx),
GasLimit: sctx.GetGasLimit(ctx),
Value: big.NewInt(0),
Description: "reveal transaction",
To: &c.incentivesContractAddress,
Data: callData,
GasPrice: sctx.GetGasPrice(ctx),
GasLimit: sctx.GetGasLimit(ctx),
MinEstimatedGasLimit: 500_000,
Value: big.NewInt(0),
Description: "reveal transaction",
}
err = c.sendAndWait(ctx, request, 50)
if err != nil {
Expand Down
19 changes: 11 additions & 8 deletions pkg/transaction/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ const DefaultTipBoostPercent = 20

// TxRequest describes a request for a transaction that can be executed.
type TxRequest struct {
To *common.Address // recipient of the transaction
Data []byte // transaction data
GasPrice *big.Int // gas price or nil if suggested gas price should be used
GasLimit uint64 // gas limit or 0 if it should be estimated
GasFeeCap *big.Int // adds a cap to maximum fee user is willing to pay
Value *big.Int // amount of wei to send
Description string // optional description
To *common.Address // recipient of the transaction
Data []byte // transaction data
GasPrice *big.Int // gas price or nil if suggested gas price should be used
GasLimit uint64 // gas limit or 0 if it should be estimated
MinEstimatedGasLimit uint64 // minimum gas limit to use if the gas limit was estimated; it will not apply when this value is 0 or when GasLimit is not 0
GasFeeCap *big.Int // adds a cap to maximum fee user is willing to pay
Value *big.Int // amount of wei to send
Description string // optional description
}

type StoredTransaction struct {
Expand Down Expand Up @@ -271,7 +272,9 @@ func (t *transactionService) prepareTransaction(ctx context.Context, request *Tx
}

gasLimit += gasLimit / 4 // add 25% on top

if gasLimit < request.MinEstimatedGasLimit {
gasLimit = request.MinEstimatedGasLimit
}
} else {
gasLimit = request.GasLimit
}
Expand Down

0 comments on commit 9915106

Please sign in to comment.