Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce min estimated gas limit #3617

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 21 additions & 18 deletions pkg/storageincentives/redistribution/redistribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ func (c *contract) Claim(ctx context.Context) error {
return err
}
request := &transaction.TxRequest{
To: &c.incentivesContractAddress,
Data: callData,
GasPrice: sctx.GetGasPrice(ctx),
GasLimit: sctx.GetGasLimit(ctx),
Value: big.NewInt(0),
Description: "claim win transaction",
To: &c.incentivesContractAddress,
Data: callData,
GasPrice: sctx.GetGasPrice(ctx),
GasLimit: sctx.GetGasLimit(ctx),
MinEstimatedGasLimit: 500_000,
Value: big.NewInt(0),
Description: "claim win transaction",
}
err = c.sendAndWait(ctx, request, 50)
if err != nil {
Expand All @@ -121,12 +122,13 @@ func (c *contract) Commit(ctx context.Context, obfusHash []byte, round *big.Int)
return err
}
request := &transaction.TxRequest{
To: &c.incentivesContractAddress,
Data: callData,
GasPrice: sctx.GetGasPrice(ctx),
GasLimit: sctx.GetGasLimit(ctx),
Value: big.NewInt(0),
Description: "commit transaction",
To: &c.incentivesContractAddress,
Data: callData,
GasPrice: sctx.GetGasPrice(ctx),
GasLimit: sctx.GetGasLimit(ctx),
MinEstimatedGasLimit: 500_000,
Value: big.NewInt(0),
Description: "commit transaction",
}
err = c.sendAndWait(ctx, request, 50)
if err != nil {
Expand All @@ -143,12 +145,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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrekucci can we add this to all the other calls in this pkg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

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