Skip to content

Commit

Permalink
Revert "chore(evm, feemarket) - Migrate Event emitting to TypedEvent (e…
Browse files Browse the repository at this point in the history
…vmos#1544)"

This reverts commit 8886ce3.
  • Loading branch information
mmsqe committed Jan 10, 2023
1 parent a94e098 commit edc97be
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 2,010 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* (evm) [#1544](https://github.com/evmos/ethermint/pull/1544) Migrate deprecated event emitting to new TypedEvent
* (tests) [#1507](https://github.com/evmos/ethermint/pull/1507) Remove legacy sim tests
* (feemarket) [#1508](https://github.com/evmos/ethermint/pull/1508) Remove old x/params migration logic
* (evm) [#1499](https://github.com/evmos/ethermint/pull/1499) Add Shanghai and Cancun block
Expand Down
44 changes: 0 additions & 44 deletions proto/ethermint/evm/v1/events.proto

This file was deleted.

18 changes: 0 additions & 18 deletions proto/ethermint/feemarket/v1/events.proto

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/integration-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ echo "done sleeping"
set +e

if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
time_out=900s
time_out=300s
if [[ $TEST == "pending" ]]; then
time_out=60m0s
fi
Expand Down
179 changes: 88 additions & 91 deletions tests/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,37 +347,36 @@ func TestEth_IncompleteSendTransaction(t *testing.T) {
require.NotEqual(t, err.Error(), "method handler crashed", "no from field dealt with incorrectly")
}

// TODO: Investigate why it's failing
//func TestEth_GetFilterChanges_NoTopics(t *testing.T) {
// rpcRes := call(t, "eth_blockNumber", []string{})
//
// var res hexutil.Uint64
// err := res.UnmarshalJSON(rpcRes.Result)
// require.NoError(t, err)
//
// param := make([]map[string]interface{}, 1)
// param[0] = make(map[string]interface{})
// param[0]["topics"] = []string{}
// param[0]["fromBlock"] = res.String()
//
// // instantiate new filter
// rpcRes = call(t, "eth_newFilter", param)
// require.Nil(t, rpcRes.Error)
// var ID string
// err = json.Unmarshal(rpcRes.Result, &ID)
// require.NoError(t, err)
//
// // deploy contract, emitting some event
// deployTestContract(t)
//
// // get filter changes
// changesRes := call(t, "eth_getFilterChanges", []string{ID})
//
// var logs []*ethtypes.Log
// err = json.Unmarshal(changesRes.Result, &logs)
// require.NoError(t, err)
// require.Equal(t, 1, len(logs))
//}
func TestEth_GetFilterChanges_NoTopics(t *testing.T) {
rpcRes := call(t, "eth_blockNumber", []string{})

var res hexutil.Uint64
err := res.UnmarshalJSON(rpcRes.Result)
require.NoError(t, err)

param := make([]map[string]interface{}, 1)
param[0] = make(map[string]interface{})
param[0]["topics"] = []string{}
param[0]["fromBlock"] = res.String()

// instantiate new filter
rpcRes = call(t, "eth_newFilter", param)
require.Nil(t, rpcRes.Error)
var ID string
err = json.Unmarshal(rpcRes.Result, &ID)
require.NoError(t, err)

// deploy contract, emitting some event
deployTestContract(t)

// get filter changes
changesRes := call(t, "eth_getFilterChanges", []string{ID})

var logs []*ethtypes.Log
err = json.Unmarshal(changesRes.Result, &logs)
require.NoError(t, err)
require.Equal(t, 1, len(logs))
}

// hash of Hello event
var helloTopic = "0x775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd738898"
Expand Down Expand Up @@ -427,68 +426,66 @@ func deployTestContractWithFunction(t *testing.T) hexutil.Bytes {
return hash
}

// TODO: Investigate why it's failing
// Tests topics case where there are topics in first two positions
//func TestEth_GetFilterChanges_Topics_AB(t *testing.T) {
// rpcRes := call(t, "eth_blockNumber", []string{})
//
// var res hexutil.Uint64
// err := res.UnmarshalJSON(rpcRes.Result)
// require.NoError(t, err)
//
// param := make([]map[string]interface{}, 1)
// param[0] = make(map[string]interface{})
// param[0]["topics"] = []string{helloTopic, worldTopic}
// param[0]["fromBlock"] = res.String()
//
// // instantiate new filter
// rpcRes = call(t, "eth_newFilter", param)
// var ID string
// err = json.Unmarshal(rpcRes.Result, &ID)
// require.NoError(t, err, string(rpcRes.Result))
//
// deployTestContractWithFunction(t)
//
// // get filter changes
// changesRes := call(t, "eth_getFilterChanges", []string{ID})
//
// var logs []*ethtypes.Log
// err = json.Unmarshal(changesRes.Result, &logs)
// require.NoError(t, err)
//
// require.Equal(t, 1, len(logs))
//}
func TestEth_GetFilterChanges_Topics_AB(t *testing.T) {
rpcRes := call(t, "eth_blockNumber", []string{})

// TODO: Investigate why it's failing
//func TestEth_GetFilterChanges_Topics_XB(t *testing.T) {
// rpcRes := call(t, "eth_blockNumber", []string{})
//
// var res hexutil.Uint64
// err := res.UnmarshalJSON(rpcRes.Result)
// require.NoError(t, err)
//
// param := make([]map[string]interface{}, 1)
// param[0] = make(map[string]interface{})
// param[0]["topics"] = []interface{}{nil, worldTopic}
// param[0]["fromBlock"] = res.String()
//
// // instantiate new filter
// rpcRes = call(t, "eth_newFilter", param)
// var ID string
// err = json.Unmarshal(rpcRes.Result, &ID)
// require.NoError(t, err)
//
// deployTestContractWithFunction(t)
//
// // get filter changes
// changesRes := call(t, "eth_getFilterChanges", []string{ID})
//
// var logs []*ethtypes.Log
// err = json.Unmarshal(changesRes.Result, &logs)
// require.NoError(t, err)
//
// require.Equal(t, 1, len(logs))
//}
var res hexutil.Uint64
err := res.UnmarshalJSON(rpcRes.Result)
require.NoError(t, err)

param := make([]map[string]interface{}, 1)
param[0] = make(map[string]interface{})
param[0]["topics"] = []string{helloTopic, worldTopic}
param[0]["fromBlock"] = res.String()

// instantiate new filter
rpcRes = call(t, "eth_newFilter", param)
var ID string
err = json.Unmarshal(rpcRes.Result, &ID)
require.NoError(t, err, string(rpcRes.Result))

deployTestContractWithFunction(t)

// get filter changes
changesRes := call(t, "eth_getFilterChanges", []string{ID})

var logs []*ethtypes.Log
err = json.Unmarshal(changesRes.Result, &logs)
require.NoError(t, err)

require.Equal(t, 1, len(logs))
}

func TestEth_GetFilterChanges_Topics_XB(t *testing.T) {
rpcRes := call(t, "eth_blockNumber", []string{})

var res hexutil.Uint64
err := res.UnmarshalJSON(rpcRes.Result)
require.NoError(t, err)

param := make([]map[string]interface{}, 1)
param[0] = make(map[string]interface{})
param[0]["topics"] = []interface{}{nil, worldTopic}
param[0]["fromBlock"] = res.String()

// instantiate new filter
rpcRes = call(t, "eth_newFilter", param)
var ID string
err = json.Unmarshal(rpcRes.Result, &ID)
require.NoError(t, err)

deployTestContractWithFunction(t)

// get filter changes
changesRes := call(t, "eth_getFilterChanges", []string{ID})

var logs []*ethtypes.Log
err = json.Unmarshal(changesRes.Result, &logs)
require.NoError(t, err)

require.Equal(t, 1, len(logs))
}

func TestEth_PendingTransactionFilter(t *testing.T) {
rpcRes := call(t, "eth_newPendingTransactionFilter", []string{})
Expand Down
3 changes: 2 additions & 1 deletion x/evm/keeper/abci_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper_test

import (
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/tendermint/tendermint/abci/types"
)

Expand All @@ -13,5 +14,5 @@ func (suite *KeeperTestSuite) TestEndBlock() {

// should emit 1 EventTypeBlockBloom event on EndBlock
suite.Require().Equal(1, len(em.Events()))
suite.Require().Equal("ethermint.evm.v1.EventBlockBloom", em.Events()[0].Type)
suite.Require().Equal(evmtypes.EventTypeBlockBloom, em.Events()[0].Type)
}
5 changes: 4 additions & 1 deletion x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,10 @@ func (suite *KeeperTestSuite) TestEstimateGas() {
"enough balance",
func() {
args = types.TransactionArgs{To: &common.Address{}, From: &suite.address, Value: (*hexutil.Big)(big.NewInt(100))}
}, false, 0, false,
},
false,
0,
false,
},
// should success, because gas limit lower than 21000 is ignored
{
Expand Down
12 changes: 5 additions & 7 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,12 @@ func (k Keeper) ChainID() *big.Int {

// EmitBlockBloomEvent emit block bloom events
func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethtypes.Bloom) {
err := ctx.EventManager().EmitTypedEvent(
&types.EventBlockBloom{
Bloom: string(bloom.Bytes()),
},
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeBlockBloom,
sdk.NewAttribute(types.AttributeKeyEthereumBloom, string(bloom.Bytes())),
),
)
if err != nil {
k.Logger(ctx).Error(err.Error())
}
}

// GetAuthority returns the x/evm module authority address
Expand Down
Loading

0 comments on commit edc97be

Please sign in to comment.