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: eip 1559 dynamic transactions #3504

Merged
merged 9 commits into from Nov 7, 2022
Merged

feat: eip 1559 dynamic transactions #3504

merged 9 commits into from Nov 7, 2022

Conversation

istae
Copy link
Member

@istae istae commented Nov 7, 2022

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):


This change is Reviewable

Value: request.Value,
Gas: gasLimit,
GasTipCap: gasPrice,
GasFeeCap: gasPrice,
Copy link
Contributor

Choose a reason for hiding this comment

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

they both use the same value?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I've added some comments that clarifies it hopefully

@istae istae linked an issue Nov 7, 2022 that may be closed by this pull request
return nil, ErrGasPriceTooLow
}
gasPrice = new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(tipPercent)+100), gasPrice), big.NewInt(100))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, you're going to boost the provided price? Shouldn't the boost be inside the gasPrice == nil block? If the user specifies a price, then I don't think they'd expect it to be boosted before being used.

@istae istae merged commit e11d96b into master Nov 7, 2022
@istae istae deleted the dynamic-trx branch November 7, 2022 16:40
Copy link
Collaborator

@ldeffenb ldeffenb left a comment

Choose a reason for hiding this comment

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

Mostly suggestions and questions except for my concern on recalling the StoredTransaction in ResendTransaction.

@@ -254,7 +254,7 @@ func (t *transactionService) StoredTransaction(txHash common.Hash) (*StoredTrans
}

// prepareTransaction creates a signable transaction based on a request.
func (t *transactionService) prepareTransaction(ctx context.Context, request *TxRequest, nonce uint64, boostPercent int) (tx *types.Transaction, err error) {
func (t *transactionService) prepareTransaction(ctx context.Context, request *TxRequest, nonce uint64, tipPercent int) (tx *types.Transaction, err error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would this be better as tipBoostPercent?

Value: storedTransaction.Value,
Gas: storedTransaction.GasLimit,
GasTipCap: storedTransaction.GasPrice,
GasFeeCap: storedTransaction.GasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we be recalling the individual GasTipCap and GasFeeCap that were originally specified for the transaction? Or haven't we modified the transaction store for the new fields yet?

Copy link
Member Author

@istae istae Nov 7, 2022

Choose a reason for hiding this comment

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

it's ok to put the gas price of the transaction as the gas fee cap and tip because the gas price was originally calculated using the gas tip cap and gas fee cap.

here is an example:
https://goerli.etherscan.io/tx/0x621afbab180977bc77230ec1d5066bda0c617bd8a7126f4896c384ffb8b94dc7

where the gas price is base fee + gas tip, with an upper bound of gas fee cap.

ideally, what needs to be done is get a fresh suggested gas price and tip cap and resend the trx with that because the base price of the blockchain might have changed in the meanwhile.

Value: big.NewInt(0),
Gas: 21000,
GasTipCap: gasPrice,
GasFeeCap: gasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto here on the difference between GasTipCap and GasFeeCap?

Copy link
Member Author

Choose a reason for hiding this comment

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

we have a test case called "sendWithBoost" which defines a different tip and fee, this is sufficient unit testing for now.

return signermock.New(
signermock.WithSignTxFunc(func(transaction *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
if transaction.Type() != 0 {
if transaction.Type() != 2 {
t.Fatalf("wrong transaction type. wanted 0, got %d", transaction.Type())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Waring should be "wanted 2", not "wanted 0".

Value: value,
Gas: estimatedGasLimit,
GasTipCap: suggestedGasPrice,
GasFeeCap: suggestedGasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the test, do we want to separate the GasTipCap and GasFeeCap to 2 different values to ensure that they are properly carried through and not mixed?

Value: value,
Gas: estimatedGasLimit,
GasTipCap: suggestedGasPrice,
GasFeeCap: suggestedGasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto with the different values for traceability.

@@ -445,6 +466,9 @@ func TestTransactionSend(t *testing.T) {
backendmock.WithPendingNonceAtFunc(func(ctx context.Context, account common.Address) (uint64, error) {
return nextNonce, nil
}),
backendmock.WithSuggestGasTipCapFunc(func(ctx context.Context) (*big.Int, error) {
return big.NewInt(0), nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto with returning a uniquely recognizable value.

Value: value,
Gas: gasLimit,
GasTipCap: gasPrice,
GasFeeCap: gasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto with different values for Tip and Fee.

Value: value,
Gas: gasLimit,
GasTipCap: gasPrice,
GasFeeCap: gasPrice,
Copy link
Collaborator

Choose a reason for hiding this comment

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

And again (hopefully this is the last instance of this!).

Value: big.NewInt(0),
Gas: 21000,
GasTipCap: price,
GasFeeCap: price,
Copy link
Collaborator

Choose a reason for hiding this comment

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

It wasn't the last, and neither is this, but I'll leave it to you to apply the suggestion to all tests or none.

@aloknerurkar aloknerurkar added this to the 1.10.0 milestone Dec 8, 2022
darkobas2 added a commit to darkobas2/bee that referenced this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

low blockchain gas price prevents transactions (like storage-incentives)
5 participants