Skip to content

Commit 821fa55

Browse files
Upgrade go-ethereum api
1 parent d9a20eb commit 821fa55

25 files changed

Lines changed: 3032 additions & 243 deletions

api/ethermint/evm/v1/tx.pulsar.go

Lines changed: 1660 additions & 89 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ethermint/evm/v1/tx.proto

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,47 @@ message DynamicFeeTx {
143143
bytes s = 12;
144144
}
145145

146+
// BlobTx is the data of EIP-4844 blob transactions.
147+
message BlobTx {
148+
option (gogoproto.goproto_getters) = false;
149+
option (cosmos_proto.implements_interface) = "TxData";
150+
151+
// chain_id of the destination EVM chain
152+
string chain_id = 1 [
153+
(gogoproto.customtype) = "cosmossdk.io/math.Int",
154+
(gogoproto.customname) = "ChainID",
155+
(gogoproto.jsontag) = "chainID"
156+
];
157+
// nonce corresponds to the account nonce (transaction sequence).
158+
uint64 nonce = 2;
159+
// gas_tip_cap defines the max value for the gas tip.
160+
string gas_tip_cap = 3 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
161+
// gas_fee_cap defines the max value for the gas fee.
162+
string gas_fee_cap = 4 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
163+
// gas defines the gas limit defined for the transaction.
164+
uint64 gas = 5 [(gogoproto.customname) = "GasLimit"];
165+
// to is the recipient address in hex format.
166+
string to = 6;
167+
// value defines the transaction amount.
168+
string value = 7
169+
[(gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.customname) = "Amount"];
170+
// data is the data payload bytes of the transaction.
171+
bytes data = 8;
172+
// accesses is an array of access tuples.
173+
repeated AccessTuple accesses = 9
174+
[(gogoproto.castrepeated) = "AccessList", (gogoproto.jsontag) = "accessList", (gogoproto.nullable) = false];
175+
// max_fee_per_blob_gas defines the max fee per blob gas.
176+
string max_fee_per_blob_gas = 10 [(gogoproto.customtype) = "cosmossdk.io/math.Int"];
177+
// blob_versioned_hashes are the versioned blob hashes (hex).
178+
repeated string blob_versioned_hashes = 11 [(gogoproto.jsontag) = "blobVersionedHashes"];
179+
// v defines the signature value.
180+
bytes v = 12;
181+
// r defines the signature value.
182+
bytes r = 13;
183+
// s defines the signature value.
184+
bytes s = 14;
185+
}
186+
146187
// ExtensionOptionsEthereumTx is an extension option for ethereum transactions
147188
message ExtensionOptionsEthereumTx {
148189
option (gogoproto.goproto_getters) = false;

x/evm/genesis_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"math/big"
55

66
"github.com/ethereum/go-ethereum/common"
7+
"github.com/ethereum/go-ethereum/core/tracing"
8+
"github.com/holiman/uint256"
79

810
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
911
"github.com/evmos/ethermint/crypto/ethsecp256k1"
@@ -36,7 +38,7 @@ func (suite *EvmTestSuite) TestInitGenesis() {
3638
{
3739
"valid account",
3840
func() {
39-
vmdb.AddBalance(address, big.NewInt(1))
41+
vmdb.AddBalance(address, uint256.MustFromBig(big.NewInt(1)), tracing.BalanceChangeUnspecified)
4042
},
4143
&types.GenesisState{
4244
Params: types.DefaultParams(),

x/evm/handler_test.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -478,19 +478,18 @@ func (suite *EvmTestSuite) deployERC20Contract() common.Address {
478478
nonce := k.GetNonce(suite.ctx, suite.from)
479479
ctorArgs, err := types.ERC20Contract.ABI.Pack("", suite.from, big.NewInt(10000000000))
480480
suite.Require().NoError(err)
481-
msg := ethtypes.NewMessage(
482-
suite.from,
483-
nil,
484-
nonce,
485-
big.NewInt(0),
486-
2000000,
487-
big.NewInt(1),
488-
nil,
489-
nil,
490-
append(types.ERC20Contract.Bin, ctorArgs...),
491-
nil,
492-
true,
493-
)
481+
msg := core.Message{
482+
From: suite.from,
483+
To: nil,
484+
Nonce: nonce,
485+
Value: big.NewInt(0),
486+
GasLimit: 2000000,
487+
GasPrice: big.NewInt(1),
488+
GasFeeCap: big.NewInt(1),
489+
GasTipCap: big.NewInt(1),
490+
Data: append(types.ERC20Contract.Bin, ctorArgs...),
491+
SkipNonceChecks: true,
492+
}
494493
rsp, err := k.ApplyMessage(suite.ctx, msg, nil, true)
495494
suite.Require().NoError(err)
496495
suite.Require().False(rsp.Failed())
@@ -598,7 +597,7 @@ func (suite *EvmTestSuite) TestERC20TransferReverted() {
598597
}
599598

600599
func (suite *EvmTestSuite) TestContractDeploymentRevert() {
601-
intrinsicGas := uint64(134180)
600+
intrinsicGas := uint64(200000)
602601
testCases := []struct {
603602
msg string
604603
gasLimit uint64

x/evm/keeper/abci_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package keeper_test
22

33
import (
4-
"github.com/cometbft/cometbft/abci/types"
54
evmtypes "github.com/evmos/ethermint/x/evm/types"
65
)
76

@@ -10,7 +9,7 @@ func (suite *KeeperTestSuite) TestEndBlock() {
109
suite.Require().Equal(0, len(em.Events()))
1110

1211
res := suite.app.EvmKeeper.EndBlock(suite.ctx)
13-
suite.Require().Equal([]types.ValidatorUpdate{}, res)
12+
suite.Require().Nil(res)
1413

1514
// should emit 1 EventTypeBlockBloom event on EndBlock
1615
suite.Require().Equal(1, len(em.Events()))

x/evm/keeper/grpc_query_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
581581
}
582582
},
583583
true,
584-
1186778,
584+
1187108,
585585
false,
586586
},
587587
// estimate gas of an erc20 transfer, the exact gas number is checked with geth
@@ -657,7 +657,7 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
657657
}
658658
},
659659
true,
660-
1186778,
660+
1187108,
661661
true,
662662
},
663663
{
@@ -1100,7 +1100,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
11001100
}
11011101
},
11021102
expPass: true,
1103-
traceResponse: "[{\"error\":\"rpc error: code = Internal desc = tracer not found\"}]",
1103+
traceResponse: "[{\"error\":\"rpc error: code = Internal desc = ReferenceError: invalid_tracer is not defined at \\u003ceval\\u003e:1:2(0)\"}]",
11041104
},
11051105
{
11061106
msg: "invalid chain id",
@@ -1110,7 +1110,7 @@ func (suite *KeeperTestSuite) TestTraceBlock() {
11101110
chainID = &tmp
11111111
},
11121112
expPass: true,
1113-
traceResponse: "[{\"error\":\"rpc error: code = Internal desc = invalid chain id for signer\"}]",
1113+
traceResponse: "[{\"error\":\"rpc error: code = Internal desc = invalid chain id for signer: have 9000 want 1\"}]",
11141114
},
11151115
}
11161116

x/evm/keeper/hooks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (suite *KeeperTestSuite) TestEvmHooks() {
8282
TxHash: txHash,
8383
Logs: logs,
8484
}
85-
result := k.PostTxProcessing(ctx, ethtypes.Message{}, receipt)
85+
result := k.PostTxProcessing(ctx, core.Message{}, receipt)
8686

8787
tc.expFunc(hook, result)
8888
}

x/evm/keeper/state_transition.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,29 @@ func (k *Keeper) ApplyMessageWithConfig(ctx sdk.Context,
336336
evm := k.NewEVM(ctx, msg, cfg, tracer, stateDB)
337337

338338
leftoverGas := msg.GasLimit
339+
if tracer != nil && tracer.OnTxStart != nil {
340+
traceTx := ethtypes.NewTx(&ethtypes.LegacyTx{
341+
Nonce: msg.Nonce,
342+
To: msg.To,
343+
Value: msg.Value,
344+
Gas: msg.GasLimit,
345+
GasPrice: msg.GasPrice,
346+
Data: msg.Data,
347+
})
348+
tracer.OnTxStart(&tracing.VMContext{
349+
Coinbase: cfg.CoinBase,
350+
BlockNumber: big.NewInt(ctx.BlockHeight()),
351+
Time: uint64(ctx.BlockTime().Unix()),
352+
Random: nil,
353+
GasPrice: msg.GasPrice,
354+
StateDB: stateDB,
355+
}, traceTx, msg.From)
356+
defer func() {
357+
if tracer.OnTxEnd != nil {
358+
tracer.OnTxEnd(&ethtypes.Receipt{GasUsed: msg.GasLimit - leftoverGas}, vmErr)
359+
}
360+
}()
361+
}
339362

340363
sender := vm.AccountRef(msg.From)
341364
contractCreation := msg.To == nil

x/evm/keeper/state_transition_benchmark_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,16 @@ func newNativeMessage(
145145
data []byte,
146146
accessList ethtypes.AccessList,
147147
) (core.Message, error) {
148-
msgSigner := ethtypes.MakeSigner(cfg, big.NewInt(blockHeight))
148+
msgSigner := ethtypes.MakeSigner(cfg, big.NewInt(blockHeight), 0)
149149

150150
msg, baseFee, err := newEthMsgTx(nonce, blockHeight, address, cfg, krSigner, ethSigner, txType, data, accessList)
151151
if err != nil {
152-
return nil, err
152+
return core.Message{}, err
153153
}
154154

155155
m, err := msg.AsMessage(msgSigner, baseFee)
156156
if err != nil {
157-
return nil, err
157+
return core.Message{}, err
158158
}
159159

160160
return m, nil

x/evm/keeper/state_transition_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (suite *KeeperTestSuite) TestGetEthIntrinsicGas() {
208208
1,
209209
true,
210210
true,
211-
params.TxGas + params.TxDataNonZeroGasFrontier*1,
211+
params.TxGas + params.TxDataNonZeroGasFrontier*1 + 2,
212212
},
213213
{
214214
"no data, one accesslist, not contract creation, not homestead, not istanbul",
@@ -435,15 +435,15 @@ func (suite *KeeperTestSuite) TestRefundGas() {
435435

436436
vmdb.AddRefund(params.TxGas)
437437

438-
if tc.leftoverGas > m.Gas() {
438+
if tc.leftoverGas > m.GasLimit {
439439
return
440440
}
441441

442442
if tc.malleate != nil {
443443
tc.malleate()
444444
}
445445

446-
gasUsed := m.Gas() - tc.leftoverGas
446+
gasUsed := m.GasLimit - tc.leftoverGas
447447
refund := keeper.GasToRefund(vmdb.GetRefund(), gasUsed, tc.refundQuotient)
448448
suite.Require().Equal(tc.expGasRefund, refund)
449449

@@ -667,10 +667,10 @@ func (suite *KeeperTestSuite) TestApplyMessageWithConfig() {
667667
func (suite *KeeperTestSuite) createContractGethMsg(nonce uint64, signer ethtypes.Signer, cfg *params.ChainConfig, gasPrice *big.Int) (core.Message, error) {
668668
ethMsg, err := suite.createContractMsgTx(nonce, signer, cfg, gasPrice)
669669
if err != nil {
670-
return nil, err
670+
return core.Message{}, err
671671
}
672672

673-
msgSigner := ethtypes.MakeSigner(cfg, big.NewInt(suite.ctx.BlockHeight()))
673+
msgSigner := ethtypes.MakeSigner(cfg, big.NewInt(suite.ctx.BlockHeight()), 0)
674674
return ethMsg.AsMessage(msgSigner, nil)
675675
}
676676

0 commit comments

Comments
 (0)