Skip to content

Commit 85447b9

Browse files
committed
feat: Support more transaction types
1 parent 2440a50 commit 85447b9

File tree

10 files changed

+556
-28
lines changed

10 files changed

+556
-28
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
github.com/btcsuite/btcd/btcutil v1.1.6
1818
github.com/bygui86/multi-profile/v2 v2.1.0
1919
github.com/coder/websocket v1.8.13
20+
github.com/consensys/gnark-crypto v0.19.0
2021
github.com/dgraph-io/ristretto v0.2.0
2122
github.com/dgryski/go-clockpro v0.0.0-20140817124034-edc6d3eeb96e
2223
github.com/dustin/go-humanize v1.0.1
@@ -85,7 +86,6 @@ require (
8586
github.com/bits-and-blooms/bitset v1.22.0 // indirect
8687
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
8788
github.com/cespare/xxhash/v2 v2.3.0 // indirect
88-
github.com/consensys/gnark-crypto v0.18.0 // indirect
8989
github.com/containerd/log v0.1.0 // indirect
9090
github.com/containerd/platforms v0.2.1 // indirect
9191
github.com/cpuguy83/dockercfg v0.3.2 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAK
116116
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
117117
github.com/coder/websocket v1.8.13 h1:f3QZdXy7uGVz+4uCJy2nTZyM0yTBj8yANEHhqlXZ9FE=
118118
github.com/coder/websocket v1.8.13/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3CKoDBB2gs=
119-
github.com/consensys/gnark-crypto v0.18.0 h1:vIye/FqI50VeAr0B3dx+YjeIvmc3LWz4yEfbWBpTUf0=
120-
github.com/consensys/gnark-crypto v0.18.0/go.mod h1:L3mXGFTe1ZN+RSJ+CLjUt9x7PNdx8ubaYfDROyp2Z8c=
119+
github.com/consensys/gnark-crypto v0.19.0 h1:zXCqeY2txSaMl6G5wFpZzMWJU9HPNh8qxPnYJ1BL9vA=
120+
github.com/consensys/gnark-crypto v0.19.0/go.mod h1:rT23F0XSZqE0mUA0+pRtnL56IbPxs6gp4CeRsBk4XS0=
121121
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
122122
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
123123
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=

packages/evm/evmutil/signer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func Signer(chainID *big.Int) types.Signer {
16-
return types.NewEIP155Signer(chainID)
16+
return types.NewPragueSigner(chainID)
1717
}
1818

1919
func GetSender(tx *types.Transaction) (common.Address, error) {

packages/evm/jsonrpc/evmchain.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,27 @@ func (e *EVMChain) SendTransaction(tx *types.Transaction) error {
202202
}
203203

204204
gasFeePolicy := e.GasFeePolicy()
205-
if err := evmutil.CheckGasPrice(tx.GasPrice(), gasFeePolicy); err != nil {
206-
return err
205+
206+
// Validate gas pricing based on transaction type
207+
if tx.Type() == types.LegacyTxType {
208+
// For legacy and access list transactions, use the gas price
209+
if err := evmutil.CheckGasPrice(tx.GasPrice(), gasFeePolicy); err != nil {
210+
return err
211+
}
212+
} else {
213+
// For EIP-1559-family (0x02, 0x03, 0x04) transactions, validate the fee cap
214+
if err := evmutil.CheckGasPrice(tx.GasTipCap(), gasFeePolicy); err != nil {
215+
return err
216+
}
217+
}
218+
219+
// extra check for blob transaction, we use the same min gas fee for blob gas too
220+
if tx.Type() == types.BlobTxType {
221+
if err := evmutil.CheckGasPrice(tx.BlobGasFeeCap(), gasFeePolicy); err != nil {
222+
return err
223+
}
207224
}
225+
208226
if err := e.checkEnoughL2FundsForGasBudget(sender, tx, gasFeePolicy); err != nil {
209227
return err
210228
}
@@ -495,6 +513,11 @@ func (e *EVMChain) GasPrice() *big.Int {
495513
return e.GasFeePolicy().DefaultGasPriceFullDecimals(parameters.BaseTokenDecimals)
496514
}
497515

516+
func (e *EVMChain) PriorityFeePerGas() *big.Int {
517+
e.log.LogDebugf("PriorityFeePerGas()")
518+
return e.GasFeePolicy().DefaultGasPriceFullDecimals(parameters.BaseTokenDecimals)
519+
}
520+
498521
func (e *EVMChain) StorageAt(address common.Address, key common.Hash, blockNumberOrHash *rpc.BlockNumberOrHash) (common.Hash, error) {
499522
e.log.LogDebugf("StorageAt(address=%v, key=%v, blockNumberOrHash=%v)", address, key, blockNumberOrHash)
500523
chainState, err := e.iscStateFromEVMBlockNumberOrHash(blockNumberOrHash)

0 commit comments

Comments
 (0)