Skip to content

Commit

Permalink
Merge branch 'main' into fix_register_type_ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jan 10, 2023
2 parents 3cfbb10 + 57ed355 commit a94e098
Show file tree
Hide file tree
Showing 36 changed files with 4,092 additions and 267 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### State Machine Breaking

* (feemarket) [#1509](https://github.com/evmos/ethermint/pull/1509) Deprecate usage of x/params in x/feemarket
* (evm) [#1472](https://github.com/evmos/ethermint/pull/1472) Deprecate x/params usage in x/evm
* (deps) #[1575](https://github.com/evmos/ethermint/pull/1575) bump ibc-go to [`v6.1.0`]
* (deps) [#1361](https://github.com/evmos/ethermint/pull/1361) Bump ibc-go to [`v5.1.0`](https://github.com/cosmos/ibc-go/releases/tag/v5.1.0)
Expand All @@ -66,6 +67,7 @@ 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
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ func NewEthermintApp(

// Create Ethermint keepers
app.FeeMarketKeeper = feemarketkeeper.NewKeeper(
appCodec, app.GetSubspace(feemarkettypes.ModuleName), keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey],
appCodec, authtypes.NewModuleAddress(govtypes.ModuleName),
keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey],
)

// Set authority to x/gov module account to only expect the module account to update params
Expand Down Expand Up @@ -508,7 +509,7 @@ func NewEthermintApp(
transferModule,
// Ethermint app modules
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, ss),
feemarket.NewAppModule(app.FeeMarketKeeper),
feemarket.NewAppModule(app.FeeMarketKeeper, app.GetSubspace(feemarkettypes.ModuleName)),
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand Down
44 changes: 44 additions & 0 deletions proto/ethermint/evm/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
syntax = "proto3";
package ethermint.evm.v1;

option go_package = "github.com/evmos/ethermint/x/evm/types";

// EventEthereumTx defines the event for an Ethereum transaction
message EventEthereumTx {
// amount
string amount = 1;
// eth_hash is the Ethereum hash of the transaction
string eth_hash = 2;
// index of the transaction in the block
string index = 3;
// gas_used is the amount of gas used by the transaction
string gas_used = 4;
// hash is the Tendermint hash of the transaction
string hash = 5;
// recipient of the transaction
string recipient = 6;
// eth_tx_failed contains a VM error should it occur
string eth_tx_failed = 7;
}

// EventTxLog defines the event for an Ethereum transaction log
message EventTxLog {
// tx_logs is an array of transaction logs
repeated string tx_logs = 1;
}

// EventMessage
message EventMessage {
// module which emits the event
string module = 1;
// sender of the message
string sender = 2;
// tx_type is the type of the message
string tx_type = 3;
}

// EventBlockBloom defines an Ethereum block bloom filter event
message EventBlockBloom {
// bloom is the bloom filter of the block
string bloom = 1;
}
18 changes: 18 additions & 0 deletions proto/ethermint/feemarket/v1/events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";
package ethermint.feemarket.v1;

option go_package = "github.com/evmos/ethermint/x/feemarket/types";

// EventFeeMarket is the event type for the fee market module
message EventFeeMarket {
// base_fee for EIP-1559 blocks
string base_fee = 1;
}

// EventBlockGas defines an Ethereum block gas event
message EventBlockGas {
// height of the block
string height = 1;
// amount of gas wanted by the block
string amount = 2;
}
30 changes: 30 additions & 0 deletions proto/ethermint/feemarket/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
syntax = "proto3";
package ethermint.feemarket.v1;

import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "ethermint/feemarket/v1/feemarket.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/evmos/ethermint/x/feemarket/types";

// Msg defines the erc20 Msg service.
service Msg {
// UpdateParams defined a governance operation for updating the x/feemarket module parameters.
// The authority is hard-coded to the Cosmos SDK x/gov module account
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgUpdateParams defines a Msg for updating the x/feemarket module parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the x/feemarket parameters to update.
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
}

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

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))
}
// 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))
//}

// hash of Hello event
var helloTopic = "0x775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd738898"
Expand Down Expand Up @@ -426,66 +427,68 @@ 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_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)
//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))
//}

require.Equal(t, 1, len(logs))
}
// 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))
//}

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

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

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

// should emit 1 EventTypeBlockBloom event on EndBlock
suite.Require().Equal(1, len(em.Events()))
suite.Require().Equal(evmtypes.EventTypeBlockBloom, em.Events()[0].Type)
suite.Require().Equal("ethermint.evm.v1.EventBlockBloom", em.Events()[0].Type)
}
5 changes: 1 addition & 4 deletions x/evm/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,7 @@ 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: 7 additions & 5 deletions x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ func (k Keeper) ChainID() *big.Int {

// EmitBlockBloomEvent emit block bloom events
func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethtypes.Bloom) {
ctx.EventManager().EmitEvent(
sdk.NewEvent(
types.EventTypeBlockBloom,
sdk.NewAttribute(types.AttributeKeyEthereumBloom, string(bloom.Bytes())),
),
err := ctx.EventManager().EmitTypedEvent(
&types.EventBlockBloom{
Bloom: 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 a94e098

Please sign in to comment.