diff --git a/openapi/SwarmCommon.yaml b/openapi/SwarmCommon.yaml index a70cfa3d9e0..8ac5cb931b7 100644 --- a/openapi/SwarmCommon.yaml +++ b/openapi/SwarmCommon.yaml @@ -1,6 +1,6 @@ openapi: 3.0.3 info: - version: 2.2.0 + version: 2.3.0 title: Common Data Types description: | \*****bzzz***** @@ -655,6 +655,12 @@ components: $ref: "#/components/schemas/BigInt" gasLimit: type: integer + gasTipCap: + $ref: "#/components/schemas/BigInt" + gasTipBoost: + type: integer + gasFeeCap: + $ref: "#/components/schemas/BigInt" data: type: string created: diff --git a/pkg/api/transaction.go b/pkg/api/transaction.go index cabeee7157c..9261c172282 100644 --- a/pkg/api/transaction.go +++ b/pkg/api/transaction.go @@ -32,6 +32,9 @@ type transactionInfo struct { Nonce uint64 `json:"nonce"` GasPrice *bigint.BigInt `json:"gasPrice"` GasLimit uint64 `json:"gasLimit"` + GasTipBoost int `json:"gasTipBoost"` + GasTipCap *bigint.BigInt `json:"gasTipCap"` + GasFeeCap *bigint.BigInt `json:"gasFeeCap"` Data string `json:"data"` Created time.Time `json:"created"` Description string `json:"description"` @@ -69,6 +72,9 @@ func (s *Service) transactionListHandler(w http.ResponseWriter, _ *http.Request) Nonce: storedTransaction.Nonce, GasPrice: bigint.Wrap(storedTransaction.GasPrice), GasLimit: storedTransaction.GasLimit, + GasFeeCap: bigint.Wrap(storedTransaction.GasFeeCap), + GasTipCap: bigint.Wrap(storedTransaction.GasTipCap), + GasTipBoost: storedTransaction.GasTipBoost, Data: hexutil.Encode(storedTransaction.Data), Created: time.Unix(storedTransaction.Created, 0), Description: storedTransaction.Description, @@ -111,6 +117,9 @@ func (s *Service) transactionDetailHandler(w http.ResponseWriter, r *http.Reques Nonce: storedTransaction.Nonce, GasPrice: bigint.Wrap(storedTransaction.GasPrice), GasLimit: storedTransaction.GasLimit, + GasFeeCap: bigint.Wrap(storedTransaction.GasFeeCap), + GasTipCap: bigint.Wrap(storedTransaction.GasTipCap), + GasTipBoost: storedTransaction.GasTipBoost, Data: hexutil.Encode(storedTransaction.Data), Created: time.Unix(storedTransaction.Created, 0), Description: storedTransaction.Description, diff --git a/pkg/api/transaction_test.go b/pkg/api/transaction_test.go index ddb1cdc5f82..7c202aa9def 100644 --- a/pkg/api/transaction_test.go +++ b/pkg/api/transaction_test.go @@ -31,12 +31,13 @@ func TestTransactionStoredTransaction(t *testing.T) { data := common.Hex2Bytes(dataStr) created := int64(1616451040) recipient := common.HexToAddress("fffe") - gasPrice := big.NewInt(23) + gasPrice := big.NewInt(12) gasLimit := uint64(200) value := big.NewInt(50) nonce := uint64(12) description := "test" - + gasTipBoost := 10 + gasTipCap := new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(gasTipBoost)+100), gasPrice), big.NewInt(100)) t.Run("found", func(t *testing.T) { t.Parallel() @@ -50,6 +51,9 @@ func TestTransactionStoredTransaction(t *testing.T) { Data: data, GasPrice: gasPrice, GasLimit: gasLimit, + GasFeeCap: gasPrice, + GasTipBoost: gasTipBoost, + GasTipCap: gasTipCap, Value: value, Nonce: nonce, Description: description, @@ -66,6 +70,9 @@ func TestTransactionStoredTransaction(t *testing.T) { To: &recipient, GasPrice: bigint.Wrap(gasPrice), GasLimit: gasLimit, + GasFeeCap: bigint.Wrap(gasPrice), + GasTipCap: bigint.Wrap(gasTipCap), + GasTipBoost: gasTipBoost, Value: bigint.Wrap(value), Nonce: nonce, Description: description, @@ -121,12 +128,15 @@ func TestTransactionList(t *testing.T) { storedTransactions := map[common.Hash]*transaction.StoredTransaction{ txHash1: { To: &recipient, - Created: 1, Data: []byte{1, 2, 3, 4}, GasPrice: big.NewInt(12), GasLimit: 5345, + GasTipBoost: 10, + GasTipCap: new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(10)+100), big.NewInt(12)), big.NewInt(100)), + GasFeeCap: big.NewInt(12), Value: big.NewInt(4), Nonce: 3, + Created: 1, Description: "test", }, txHash2: { @@ -134,6 +144,9 @@ func TestTransactionList(t *testing.T) { Created: 2, Data: []byte{3, 2, 3, 4}, GasPrice: big.NewInt(42), + GasTipBoost: 10, + GasTipCap: new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(10)+100), big.NewInt(42)), big.NewInt(100)), + GasFeeCap: big.NewInt(42), GasLimit: 53451, Value: big.NewInt(41), Nonce: 32, @@ -158,25 +171,31 @@ func TestTransactionList(t *testing.T) { PendingTransactions: []api.TransactionInfo{ { TransactionHash: txHash1, - Created: time.Unix(storedTransactions[txHash1].Created, 0), - Data: hexutil.Encode(storedTransactions[txHash1].Data), To: storedTransactions[txHash1].To, + Nonce: storedTransactions[txHash1].Nonce, GasPrice: bigint.Wrap(storedTransactions[txHash1].GasPrice), GasLimit: storedTransactions[txHash1].GasLimit, - Value: bigint.Wrap(storedTransactions[txHash1].Value), - Nonce: storedTransactions[txHash1].Nonce, + GasTipCap: bigint.Wrap(storedTransactions[txHash1].GasTipCap), + GasTipBoost: storedTransactions[txHash1].GasTipBoost, + GasFeeCap: bigint.Wrap(storedTransactions[txHash1].GasPrice), + Data: hexutil.Encode(storedTransactions[txHash1].Data), + Created: time.Unix(storedTransactions[txHash1].Created, 0), Description: storedTransactions[txHash1].Description, + Value: bigint.Wrap(storedTransactions[txHash1].Value), }, { TransactionHash: txHash2, - Created: time.Unix(storedTransactions[txHash2].Created, 0), - Data: hexutil.Encode(storedTransactions[txHash2].Data), To: storedTransactions[txHash2].To, + Nonce: storedTransactions[txHash2].Nonce, GasPrice: bigint.Wrap(storedTransactions[txHash2].GasPrice), GasLimit: storedTransactions[txHash2].GasLimit, - Value: bigint.Wrap(storedTransactions[txHash2].Value), - Nonce: storedTransactions[txHash2].Nonce, + GasTipCap: bigint.Wrap(storedTransactions[txHash2].GasTipCap), + GasTipBoost: storedTransactions[txHash2].GasTipBoost, + GasFeeCap: bigint.Wrap(storedTransactions[txHash2].GasPrice), + Data: hexutil.Encode(storedTransactions[txHash2].Data), + Created: time.Unix(storedTransactions[txHash2].Created, 0), Description: storedTransactions[txHash2].Description, + Value: bigint.Wrap(storedTransactions[txHash2].Value), }, }, }), diff --git a/pkg/node/devnode.go b/pkg/node/devnode.go index fc1a3b4e45d..40817b14733 100644 --- a/pkg/node/devnode.go +++ b/pkg/node/devnode.go @@ -159,6 +159,9 @@ func NewDevBee(logger log.Logger, o *DevOptions) (b *DevBee, err error) { Created: 1, Data: []byte{1, 2, 3, 4}, GasPrice: big.NewInt(12), + GasTipBoost: 10, + GasFeeCap: big.NewInt(12), + GasTipCap: new(big.Int).Div(new(big.Int).Mul(big.NewInt(int64(10)+100), big.NewInt(12)), big.NewInt(100)), GasLimit: 5345, Value: big.NewInt(4), Nonce: 3, diff --git a/pkg/transaction/transaction.go b/pkg/transaction/transaction.go index b77b0384110..682eb5fb657 100644 --- a/pkg/transaction/transaction.go +++ b/pkg/transaction/transaction.go @@ -48,6 +48,7 @@ type TxRequest struct { 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 } @@ -56,8 +57,10 @@ type StoredTransaction struct { To *common.Address // recipient of the transaction Data []byte // transaction data GasPrice *big.Int // used gas price - GasTipBoost int // percentage used to boost the priority fee (eg: tip) GasLimit uint64 // used gas limit + GasTipBoost int // adds a tip for the miner for prioritizing transaction + GasTipCap *big.Int // adds a cap to the tip + GasFeeCap *big.Int // adds a cap to maximum fee user is willing to pay Value *big.Int // amount of wei to send Nonce uint64 // used nonce Created int64 // creation timestamp @@ -177,8 +180,10 @@ func (t *transactionService) Send(ctx context.Context, request *TxRequest, tipCa To: signedTx.To(), Data: signedTx.Data(), GasPrice: signedTx.GasPrice(), - GasTipBoost: tipCapBoostPercent, GasLimit: signedTx.Gas(), + GasTipBoost: tipCapBoostPercent, + GasTipCap: signedTx.GasTipCap(), + GasFeeCap: signedTx.GasFeeCap(), Value: signedTx.Value(), Nonce: signedTx.Nonce(), Created: time.Now().Unix(), @@ -485,6 +490,9 @@ func (t *transactionService) CancelTransaction(ctx context.Context, originalTxHa Data: signedTx.Data(), GasPrice: signedTx.GasPrice(), GasLimit: signedTx.Gas(), + GasFeeCap: signedTx.GasFeeCap(), + GasTipBoost: storedTransaction.GasTipBoost, + GasTipCap: signedTx.GasTipCap(), Value: signedTx.Value(), Nonce: signedTx.Nonce(), Created: time.Now().Unix(),