Skip to content

Commit

Permalink
Problem: evm tx type is not aligned (#396)
Browse files Browse the repository at this point in the history
* Problem: evm tx type is aligned

for more info, https://github.com/ethereum/go-ethereum/blob/v1.11.6/internal/ethapi/transaction_args.go#L284

* fix chainID

* Update CHANGELOG.md

Signed-off-by: mmsqe <[email protected]>

---------

Signed-off-by: mmsqe <[email protected]>
  • Loading branch information
mmsqe authored Jan 12, 2024
1 parent fd9a87e commit e2b1d5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [#386](https://github.com/crypto-org-chain/ethermint/pull/386) Cleanup unused cancel function in filter.
* (rpc) [#388](https://github.com/crypto-org-chain/ethermint/pull/388) Avoid out of bound panic when error message.
* (rpc) [#391](https://github.com/crypto-org-chain/ethermint/pull/391) Align block param with go-ethereum in debug_traceCall.
- (evm) [#396](https://github.com/crypto-org-chain/ethermint/pull/396) Align evm tx type with go-ethereum.

### Improvements

Expand Down
9 changes: 5 additions & 4 deletions x/evm/keeper/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,28 +624,29 @@ func (suite *KeeperTestSuite) CreateTestTx(msg *types.MsgEthereumTx, priv crypto
}

func (suite *KeeperTestSuite) TestAddLog() {
chainID := big.NewInt(9000)
addr, privKey := tests.NewAddrKey()
msg := types.NewTx(big.NewInt(1), 0, &suite.address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil)
msg := types.NewTx(chainID, 0, &suite.address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil)
msg.From = addr.Bytes()

tx := suite.CreateTestTx(msg, privKey)
msg, _ = tx.GetMsgs()[0].(*types.MsgEthereumTx)
txHash := msg.AsTransaction().Hash()

msg2 := types.NewTx(big.NewInt(1), 1, &suite.address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil)
msg2 := types.NewTx(chainID, 1, &suite.address, big.NewInt(1), 100000, big.NewInt(1), nil, nil, []byte("test"), nil)
msg2.From = addr.Bytes()

tx2 := suite.CreateTestTx(msg2, privKey)
msg2, _ = tx2.GetMsgs()[0].(*types.MsgEthereumTx)

msg3 := types.NewTx(big.NewInt(1), 0, &suite.address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil)
msg3 := types.NewTx(chainID, 0, &suite.address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil)
msg3.From = addr.Bytes()

tx3 := suite.CreateTestTx(msg3, privKey)
msg3, _ = tx3.GetMsgs()[0].(*types.MsgEthereumTx)
txHash3 := msg3.AsTransaction().Hash()

msg4 := types.NewTx(big.NewInt(1), 1, &suite.address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil)
msg4 := types.NewTx(chainID, 1, &suite.address, big.NewInt(1), 100000, nil, big.NewInt(1), big.NewInt(1), []byte("test"), nil)
msg4.From = addr.Bytes()

tx4 := suite.CreateTestTx(msg4, privKey)
Expand Down
20 changes: 9 additions & 11 deletions x/evm/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,9 @@ func newMsgEthereumTx(
}

switch {
case accesses == nil:
txData = &LegacyTx{
Nonce: nonce,
To: toAddr,
Amount: amt,
GasLimit: gasLimit,
GasPrice: gp,
Data: input,
}
case accesses != nil && gasFeeCap != nil && gasTipCap != nil:
case gasFeeCap != nil:
gtc := sdkmath.NewIntFromBigInt(gasTipCap)
gfc := sdkmath.NewIntFromBigInt(gasFeeCap)

txData = &DynamicFeeTx{
ChainID: cid,
Nonce: nonce,
Expand All @@ -142,6 +132,14 @@ func newMsgEthereumTx(
Accesses: NewAccessList(accesses),
}
default:
txData = &LegacyTx{
Nonce: nonce,
To: toAddr,
Amount: amt,
GasLimit: gasLimit,
GasPrice: gp,
Data: input,
}
}

dataAny, err := PackTxData(txData)
Expand Down

0 comments on commit e2b1d5e

Please sign in to comment.