Skip to content

Commit

Permalink
Merge tag 'v5.2.0' into release/firehose
Browse files Browse the repository at this point in the history
# Conflicts:
#	evmrpc/config.go
#	evmrpc/config_test.go
  • Loading branch information
maoueh committed May 3, 2024
2 parents aa512a8 + adfcc52 commit e6bdc65
Show file tree
Hide file tree
Showing 26 changed files with 356 additions and 265 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ Ref: https://keepachangelog.com/en/1.0.0/
-->

# Changelog
## v5.2.0
sei-chain
* [#1621](https://github.com/sei-protocol/sei-chain/pull/1621) Add websocket metrics
* [#1619](https://github.com/sei-protocol/sei-chain/pull/1619) Limit number of subscriptions
* [#1618](https://github.com/sei-protocol/sei-chain/pull/1618) Fix contract deploy receipts
* [#1615](https://github.com/sei-protocol/sei-chain/pull/1615) Optimize websocket newHead by reusing tendermint subscription
* [#1609](https://github.com/sei-protocol/sei-chain/pull/1609) Add association logic to simulate endpoints
* [#1605](https://github.com/sei-protocol/sei-chain/pull/1605) Disallow sr25519 addresses for evm functions
* [#1606](https://github.com/sei-protocol/sei-chain/pull/1606) SKip evm antehandler on sr25519 signatures

sei-cosmos:
* [#495](https://github.com/sei-protocol/sei-cosmos/pull/495) Fix seid keys list by ignoring evm-addr for sr25519
* [#493](https://github.com/sei-protocol/sei-cosmos/pull/493) Remove non-multiplier gas meter

sei-tendermint:
* [#235](https://github.com/sei-protocol/sei-tendermint/pull/235) Check removed including wrapped tx state

sei-db:
* [#63](https://github.com/sei-protocol/sei-db/pull/63) Fix edge case for iterating over tombstoned value

## v5.0.1
sei-chain
[#1577](https://github.com/sei-protocol/sei-chain/pull/1577) Re-enable Cancun
Expand Down
1 change: 1 addition & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ var upgradesList = []string{
"v5.0.0",
"v5.0.1",
"v5.1.0",
"v5.2.0",
}

// if there is an override list, use that instead, for integration tests
Expand Down
3 changes: 3 additions & 0 deletions cmd/seid/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ max_log_no_block = {{ .EVM.MaxLogNoBlock }}
# max number of blocks to query logs for
max_blocks_for_log = {{ .EVM.MaxBlocksForLog }}
# max number of concurrent NewHead subscriptions
max_subscriptions_new_head = {{ .EVM.MaxSubscriptionsNewHead }}
[eth_replay]
eth_replay_enabled = {{ .ETHReplay.Enabled }}
eth_rpc = "{{ .ETHReplay.EthRPC }}"
Expand Down
21 changes: 11 additions & 10 deletions evmrpc/association.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import (
)

type AssociationAPI struct {
tmClient rpcclient.Client
keeper *keeper.Keeper
ctxProvider func(int64) sdk.Context
txDecoder sdk.TxDecoder
sendAPI *SendAPI
tmClient rpcclient.Client
keeper *keeper.Keeper
ctxProvider func(int64) sdk.Context
txDecoder sdk.TxDecoder
sendAPI *SendAPI
connectionType ConnectionType
}

func NewAssociationAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, txDecoder sdk.TxDecoder, sendAPI *SendAPI) *AssociationAPI {
return &AssociationAPI{tmClient: tmClient, keeper: k, ctxProvider: ctxProvider, txDecoder: txDecoder, sendAPI: sendAPI}
func NewAssociationAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, txDecoder sdk.TxDecoder, sendAPI *SendAPI, connectionType ConnectionType) *AssociationAPI {
return &AssociationAPI{tmClient: tmClient, keeper: k, ctxProvider: ctxProvider, txDecoder: txDecoder, sendAPI: sendAPI, connectionType: connectionType}
}

type AssociateRequest struct {
Expand All @@ -38,7 +39,7 @@ type AssociateRequest struct {

func (t *AssociationAPI) Associate(ctx context.Context, req *AssociateRequest) (returnErr error) {
startTime := time.Now()
defer recordMetrics("sei_associate", startTime, returnErr == nil)
defer recordMetrics("sei_associate", t.connectionType, startTime, returnErr == nil)
rBytes, err := decodeHexString(req.R)
if err != nil {
return err
Expand Down Expand Up @@ -86,7 +87,7 @@ func (t *AssociationAPI) Associate(ctx context.Context, req *AssociateRequest) (

func (t *AssociationAPI) GetSeiAddress(_ context.Context, ethAddress common.Address) (result string, returnErr error) {
startTime := time.Now()
defer recordMetrics("sei_getSeiAddress", startTime, returnErr == nil)
defer recordMetrics("sei_getSeiAddress", t.connectionType, startTime, returnErr == nil)
seiAddress, found := t.keeper.GetSeiAddress(t.ctxProvider(LatestCtxHeight), ethAddress)
if !found {
return "", fmt.Errorf("failed to find Sei address for %s", ethAddress.Hex())
Expand All @@ -97,7 +98,7 @@ func (t *AssociationAPI) GetSeiAddress(_ context.Context, ethAddress common.Addr

func (t *AssociationAPI) GetEVMAddress(_ context.Context, seiAddress string) (result string, returnErr error) {
startTime := time.Now()
defer recordMetrics("sei_getEVMAddress", startTime, returnErr == nil)
defer recordMetrics("sei_getEVMAddress", t.connectionType, startTime, returnErr == nil)
seiAddr, err := sdk.AccAddressFromBech32(seiAddress)
if err != nil {
return "", err
Expand Down
23 changes: 12 additions & 11 deletions evmrpc/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ import (
)

type BlockAPI struct {
tmClient rpcclient.Client
keeper *keeper.Keeper
ctxProvider func(int64) sdk.Context
txConfig client.TxConfig
tmClient rpcclient.Client
keeper *keeper.Keeper
ctxProvider func(int64) sdk.Context
txConfig client.TxConfig
connectionType ConnectionType
}

func NewBlockAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, txConfig client.TxConfig) *BlockAPI {
return &BlockAPI{tmClient: tmClient, keeper: k, ctxProvider: ctxProvider, txConfig: txConfig}
func NewBlockAPI(tmClient rpcclient.Client, k *keeper.Keeper, ctxProvider func(int64) sdk.Context, txConfig client.TxConfig, connectionType ConnectionType) *BlockAPI {
return &BlockAPI{tmClient: tmClient, keeper: k, ctxProvider: ctxProvider, txConfig: txConfig, connectionType: connectionType}
}

func (a *BlockAPI) GetBlockTransactionCountByNumber(ctx context.Context, number rpc.BlockNumber) (result *hexutil.Uint, returnErr error) {
startTime := time.Now()
defer recordMetrics("eth_getBlockTransactionCountByNumber", startTime, returnErr == nil)
defer recordMetrics("eth_getBlockTransactionCountByNumber", a.connectionType, startTime, returnErr == nil)
numberPtr, err := getBlockNumber(ctx, a.tmClient, number)
if err != nil {
return nil, err
Expand All @@ -48,7 +49,7 @@ func (a *BlockAPI) GetBlockTransactionCountByNumber(ctx context.Context, number

func (a *BlockAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash common.Hash) (result *hexutil.Uint, returnErr error) {
startTime := time.Now()
defer recordMetrics("eth_getBlockTransactionCountByHash", startTime, returnErr == nil)
defer recordMetrics("eth_getBlockTransactionCountByHash", a.connectionType, startTime, returnErr == nil)
block, err := blockByHashWithRetry(ctx, a.tmClient, blockHash[:], 1)
if err != nil {
return nil, err
Expand All @@ -58,7 +59,7 @@ func (a *BlockAPI) GetBlockTransactionCountByHash(ctx context.Context, blockHash

func (a *BlockAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fullTx bool) (result map[string]interface{}, returnErr error) {
startTime := time.Now()
defer recordMetrics("eth_getBlockByHash", startTime, returnErr == nil)
defer recordMetrics("eth_getBlockByHash", a.connectionType, startTime, returnErr == nil)
block, err := blockByHashWithRetry(ctx, a.tmClient, blockHash[:], 1)
if err != nil {
return nil, err
Expand All @@ -72,7 +73,7 @@ func (a *BlockAPI) GetBlockByHash(ctx context.Context, blockHash common.Hash, fu

func (a *BlockAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (result map[string]interface{}, returnErr error) {
startTime := time.Now()
defer recordMetrics("eth_getBlockByNumber", startTime, returnErr == nil)
defer recordMetrics("eth_getBlockByNumber", a.connectionType, startTime, returnErr == nil)
numberPtr, err := getBlockNumber(ctx, a.tmClient, number)
if err != nil {
return nil, err
Expand All @@ -90,7 +91,7 @@ func (a *BlockAPI) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber,

func (a *BlockAPI) GetBlockReceipts(ctx context.Context, number rpc.BlockNumber) (result []map[string]interface{}, returnErr error) {
startTime := time.Now()
defer recordMetrics("eth_getBlockReceipts", startTime, returnErr == nil)
defer recordMetrics("eth_getBlockReceipts", a.connectionType, startTime, returnErr == nil)
// Get height from params
heightPtr, err := getBlockNumber(ctx, a.tmClient, number)
if err != nil {
Expand Down
113 changes: 61 additions & 52 deletions evmrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ type Config struct {
// Timeout for EVM call in simulation
SimulationEVMTimeout time.Duration `mapstructure:"simulation_evm_timeout"`

// The EVM tracer to use when doing node synchronization, applies to
// all block produced but traces only EVM transactions.
//
// Refer to x/evm/tracers/registry.go#GlobalLiveTracerRegistry for registered tracers.
LiveEVMTracer string `mapstructure:"live_evm_tracer"`

// list of CORS allowed origins, separated by comma
CORSOrigins string `mapstructure:"cors_origins"`

Expand All @@ -85,52 +79,63 @@ type Config struct {

// max number of blocks to query logs for
MaxBlocksForLog int64 `mapstructure:"max_blocks_for_log"`

// max number of concurrent NewHead subscriptions
MaxSubscriptionsNewHead uint64 `mapstructure:"max_subscriptions_new_head"`

// The EVM tracer to use when doing node synchronization, applies to
// all block produced but traces only EVM transactions.
//
// Refer to x/evm/tracers/registry.go#GlobalLiveTracerRegistry for registered tracers.
LiveEVMTracer string `mapstructure:"live_evm_tracer"`
}

var DefaultConfig = Config{
HTTPEnabled: true,
HTTPPort: 8545,
WSEnabled: true,
WSPort: 8546,
ReadTimeout: rpc.DefaultHTTPTimeouts.ReadTimeout,
ReadHeaderTimeout: rpc.DefaultHTTPTimeouts.ReadHeaderTimeout,
WriteTimeout: rpc.DefaultHTTPTimeouts.WriteTimeout,
IdleTimeout: rpc.DefaultHTTPTimeouts.IdleTimeout,
SimulationGasLimit: 10_000_000, // 10M
SimulationEVMTimeout: 60 * time.Second,
LiveEVMTracer: "",
CORSOrigins: "*",
WSOrigins: "*",
FilterTimeout: 120 * time.Second,
CheckTxTimeout: 5 * time.Second,
MaxTxPoolTxs: 1000,
Slow: false,
DenyList: make([]string, 0),
MaxLogNoBlock: 10000,
MaxBlocksForLog: 2000,
HTTPEnabled: true,
HTTPPort: 8545,
WSEnabled: true,
WSPort: 8546,
ReadTimeout: rpc.DefaultHTTPTimeouts.ReadTimeout,
ReadHeaderTimeout: rpc.DefaultHTTPTimeouts.ReadHeaderTimeout,
WriteTimeout: rpc.DefaultHTTPTimeouts.WriteTimeout,
IdleTimeout: rpc.DefaultHTTPTimeouts.IdleTimeout,
SimulationGasLimit: 10_000_000, // 10M
SimulationEVMTimeout: 60 * time.Second,
CORSOrigins: "*",
WSOrigins: "*",
FilterTimeout: 120 * time.Second,
CheckTxTimeout: 5 * time.Second,
MaxTxPoolTxs: 1000,
Slow: false,
DenyList: make([]string, 0),
MaxLogNoBlock: 10000,
MaxBlocksForLog: 2000,
MaxSubscriptionsNewHead: 10000,
LiveEVMTracer: "",
}

const (
flagHTTPEnabled = "evm.http_enabled"
flagHTTPPort = "evm.http_port"
flagWSEnabled = "evm.ws_enabled"
flagWSPort = "evm.ws_port"
flagReadTimeout = "evm.read_timeout"
flagReadHeaderTimeout = "evm.read_header_timeout"
flagWriteTimeout = "evm.write_timeout"
flagIdleTimeout = "evm.idle_timeout"
flagSimulationGasLimit = "evm.simulation_gas_limit"
flagSimulationEVMTimeout = "evm.simulation_evm_timeout"
flagLiveEVMTracer = "evm.live_evm_tracer"
flagCORSOrigins = "evm.cors_origins"
flagWSOrigins = "evm.ws_origins"
flagFilterTimeout = "evm.filter_timeout"
flagMaxTxPoolTxs = "evm.max_tx_pool_txs"
flagCheckTxTimeout = "evm.checktx_timeout"
flagSlow = "evm.slow"
flagDenyList = "evm.deny_list"
flagMaxLogNoBlock = "evm.max_log_no_block"
flagMaxBlocksForLog = "evm.max_blocks_for_log"
flagHTTPEnabled = "evm.http_enabled"
flagHTTPPort = "evm.http_port"
flagWSEnabled = "evm.ws_enabled"
flagWSPort = "evm.ws_port"
flagReadTimeout = "evm.read_timeout"
flagReadHeaderTimeout = "evm.read_header_timeout"
flagWriteTimeout = "evm.write_timeout"
flagIdleTimeout = "evm.idle_timeout"
flagSimulationGasLimit = "evm.simulation_gas_limit"
flagSimulationEVMTimeout = "evm.simulation_evm_timeout"
flagCORSOrigins = "evm.cors_origins"
flagWSOrigins = "evm.ws_origins"
flagFilterTimeout = "evm.filter_timeout"
flagMaxTxPoolTxs = "evm.max_tx_pool_txs"
flagCheckTxTimeout = "evm.checktx_timeout"
flagSlow = "evm.slow"
flagDenyList = "evm.deny_list"
flagMaxLogNoBlock = "evm.max_log_no_block"
flagMaxBlocksForLog = "evm.max_blocks_for_log"
flagMaxSubscriptionsNewHead = "evm.max_subscriptions_new_head"
flagLiveEVMTracer = "evm.live_evm_tracer"
)

func ReadConfig(opts servertypes.AppOptions) (Config, error) {
Expand Down Expand Up @@ -186,11 +191,6 @@ func ReadConfig(opts servertypes.AppOptions) (Config, error) {
return cfg, err
}
}
if v := opts.Get(flagLiveEVMTracer); v != nil {
if cfg.LiveEVMTracer, err = cast.ToStringE(v); err != nil {
return cfg, err
}
}
if v := opts.Get(flagCORSOrigins); v != nil {
if cfg.CORSOrigins, err = cast.ToStringE(v); err != nil {
return cfg, err
Expand Down Expand Up @@ -236,6 +236,15 @@ func ReadConfig(opts servertypes.AppOptions) (Config, error) {
return cfg, err
}
}

if v := opts.Get(flagMaxSubscriptionsNewHead); v != nil {
if cfg.MaxSubscriptionsNewHead, err = cast.ToUint64E(v); err != nil {
return cfg, err
}
}
if v := opts.Get(flagLiveEVMTracer); v != nil {
if cfg.LiveEVMTracer, err = cast.ToStringE(v); err != nil {
return cfg, err
}
}
return cfg, nil
}
53 changes: 29 additions & 24 deletions evmrpc/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,27 @@ import (
)

type opts struct {
httpEnabled interface{}
httpPort interface{}
wsEnabled interface{}
wsPort interface{}
readTimeout interface{}
readHeaderTimeout interface{}
writeTimeout interface{}
idleTimeout interface{}
simulationGasLimit interface{}
simulationEVMTimeout interface{}
liveEVMTracer interface{}
corsOrigins interface{}
wsOrigins interface{}
filterTimeout interface{}
checkTxTimeout interface{}
maxTxPoolTxs interface{}
slow interface{}
denyList interface{}
maxLogNoBlock interface{}
maxBlocksForLog interface{}
httpEnabled interface{}
httpPort interface{}
wsEnabled interface{}
wsPort interface{}
readTimeout interface{}
readHeaderTimeout interface{}
writeTimeout interface{}
idleTimeout interface{}
simulationGasLimit interface{}
simulationEVMTimeout interface{}
corsOrigins interface{}
wsOrigins interface{}
filterTimeout interface{}
checkTxTimeout interface{}
maxTxPoolTxs interface{}
slow interface{}
denyList interface{}
maxLogNoBlock interface{}
maxBlocksForLog interface{}
maxSubscriptionsNewHead interface{}
liveEVMTracer interface{}
}

func (o *opts) Get(k string) interface{} {
Expand Down Expand Up @@ -63,9 +64,6 @@ func (o *opts) Get(k string) interface{} {
if k == "evm.simulation_evm_timeout" {
return o.simulationEVMTimeout
}
if k == "evm.live_evm_tracer" {
return o.liveEVMTracer
}
if k == "evm.cors_origins" {
return o.corsOrigins
}
Expand Down Expand Up @@ -93,6 +91,12 @@ func (o *opts) Get(k string) interface{} {
if k == "evm.max_blocks_for_log" {
return o.maxBlocksForLog
}
if k == "evm.max_subscriptions_new_head" {
return o.maxSubscriptionsNewHead
}
if k == "evm.live_evm_tracer" {
return o.liveEVMTracer
}
panic(fmt.Errorf("unknown key: %s", k))
}

Expand All @@ -110,14 +114,15 @@ func TestReadConfig(t *testing.T) {
time.Duration(60),
"",
"",
"",
time.Duration(5),
time.Duration(5),
1000,
false,
make([]string, 0),
20000,
1000,
10000,
"",
}
_, err := evmrpc.ReadConfig(&goodOpts)
require.Nil(t, err)
Expand Down
Loading

0 comments on commit e6bdc65

Please sign in to comment.