Skip to content

Commit

Permalink
Merge branch 'main' into v5.8.0-hotfix-4
Browse files Browse the repository at this point in the history
  • Loading branch information
blindchaser committed Sep 23, 2024
2 parents 6082a2d + fa43819 commit 0729ae9
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 42 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,56 @@ Ref: https://keepachangelog.com/en/1.0.0/
-->

# Changelog
## v5.8.0
sei-chain
* [#1840](https://github.com/sei-protocol/sei-chain/pull/1840) Add migration for new params
* [#1837](https://github.com/sei-protocol/sei-chain/pull/1837) Move token id from Data to Topic in ERC721 Event
* [#1836](https://github.com/sei-protocol/sei-chain/pull/1836) Properly handle gas in pointer precompile
* [#1835](https://github.com/sei-protocol/sei-chain/pull/1835) Check TX nonce before registering hook to bump nonce for failed tx
* [#1832](https://github.com/sei-protocol/sei-chain/pull/1832) Show CW transactions that have synthetic EVM events in eth_getBlock response
* [#1831](https://github.com/sei-protocol/sei-chain/pull/1831) Fork event manager when creating EVM snapshots
* [#1830](https://github.com/sei-protocol/sei-chain/pull/1830) Add wasm contract query gas limit
* [#1826](https://github.com/sei-protocol/sei-chain/pull/1826) limit MsgExec max nested level
* [#1821](https://github.com/sei-protocol/sei-chain/pull/1821) Add antehandler for EVM to check gas exceed limit or not
* [#1818](https://github.com/sei-protocol/sei-chain/pull/1818) Prevent ddos against associate msgs
* [#1816](https://github.com/sei-protocol/sei-chain/pull/1816) Actually remove dex module
* [#1813](https://github.com/sei-protocol/sei-chain/pull/1813) Tune Configs
* [#1812](https://github.com/sei-protocol/sei-chain/pull/1812) Evidence Max Bytes Update
* [#1785](https://github.com/sei-protocol/sei-chain/pull/1785) Allow CW->ERC pointers to be called through wasmd precompile
* [#1778](https://github.com/sei-protocol/sei-chain/pull/1778) Bump nonce even if tx fails

sei-cosmos
* [#535](https://github.com/sei-protocol/sei-cosmos/pull/535) init app earliest version correctly after state sync
* [#534](https://github.com/sei-protocol/sei-cosmos/pull/534) Stop executing the handler when proposal is submitted
* [#533](https://github.com/sei-protocol/sei-cosmos/pull/533) Delete kvstore specified in store upgrades
* [#532](https://github.com/sei-protocol/sei-cosmos/pull/532) Add max gas limit check in ante handler
* [#528](https://github.com/sei-protocol/sei-cosmos/pull/528) Add logs for snapshot export and impor

sei-wasmd
* [63](https://github.com/sei-protocol/sei-wasmd/pull/63) Add CW dispatch call depth
* [62](https://github.com/sei-protocol/sei-wasmd/pull/62) Patch Gas mispricing in CW VM

sei-tendermint
* [#242](https://github.com/sei-protocol/sei-tendermint/pull/242) Allow hyphen in event query

## v5.7.5
sei-chain
* [#1795](https://github.com/sei-protocol/sei-chain/pull/1795) Do not charge gas for feecollector address query
* [#1782](https://github.com/sei-protocol/sei-chain/pull/1782) Update excessBlobGas and BlobBaseFee to fix simulate evmcontext
* [#1741](https://github.com/sei-protocol/sei-chain/pull/1782) Update excessBlobGas and BlobBaseFee to fix simulate evmcontext

sei-cosmos
* [#530](https://github.com/sei-protocol/sei-cosmos/pull/530) Add EVMEntryViaWasmdPrecompile flag
* [#519](https://github.com/sei-protocol/sei-cosmos/pull/519) Genesis export stream
* [#529](https://github.com/sei-protocol/sei-cosmos/pull/529) Add DeliverTx callback
* [#528](https://github.com/sei-protocol/sei-cosmos/pull/528) Add logs for snapshot export and import

sei-wasmd
* [58](https://github.com/sei-protocol/sei-wasmd/pull/58) Genesis Export OOM

sei-tendermint
* [#239](https://github.com/sei-protocol/sei-tendermint/pull/239) Use Marshal and UnmarshalJSON For HexBytes

## v5.7.1 & v5.7.2
sei-chain
* [#1779](https://github.com/sei-protocol/sei-chain/pull/1779) Fix subscribe logs empty params crash
Expand Down
68 changes: 68 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Security Policy

## Introduction

Security researchers are essential in identifying vulnerabilities that may impact the Sei ecosystem. If you have discovered a security vulnerability in the Sei chain or any repository managed by Sei, we encourage you to notify us using one of the methods outlined below.

### Guidelines for Responsible Vulnerability Testing and Reporting

1. **Refrain from testing vulnerabilities on our publicly accessible environments**, including but not limited to:

- Sei mainnet `pacific-1`
- Sei frontend
- Sei public testnets
- Sei testnet frontend

2. **Avoid reporting security vulnerabilities through public channels, including GitHub issues**

To privately report a security vulnerability, please choose one of the following options:

### 1. Email

Send your detailed vulnerability report to `[email protected]`.

### 2. GitHub Private Vulnerability Reporting

Utilize [GitHub's Private Vulnerability Reporting](https://github.com/sei-protocol/sei-chain/security/advisories/new) for confidential disclosure.

## Submit Vulnerability Report

When reporting a vulnerability through either method, please include the following details to aid in our assessment:

- Type of vulnerability
- Description of the vulnerability
- Steps to reproduce the issue
- Impact of the issue
- Explanation on how an attacker could exploit it

## Vulnerability Disclosure Process

1. **Initial Report**: Submit the vulnerability via one of the above channels.
2. **Confirmation**: We will confirm receipt of your report within 48 hours.
3. **Assessment**: Our security team will evaluate the vulnerability and inform you of its severity and the estimated time frame for resolution.
4. **Resolution**: Once fixed, you will be contacted to verify the solution.
5. **Public Disclosure**: Details of the vulnerability may be publicly disclosed after ensuring it poses no further risk.

During the vulnerability disclosure process, we ask security researchers to keep vulnerabilities and communications around vulnerability submissions private and confidential until a patch is developed. Should a security issue require a network upgrade, additional time may be needed to raise a governance proposal and complete the upgrade.

During this time:

- Avoid exploiting any vulnerabilities you discover.
- Demonstrate good faith by not disrupting or degrading Sei's services.

## Feature request

For a feature request, e.g. module inclusion, please make a GitHub issue. Clearly state your use case and what value it will bring to other users or developers on Sei.

## Severity Characterization

| Severity | Description |
| ------------ | ----------------------------------------------------------------------- |
| **CRITICAL** | Immediate threat to critical systems (e.g., chain halts, funds at risk) |
| **HIGH** | Significant impact on major functionality |
| **MEDIUM** | Impacts minor features or exposes non-sensitive data |
| **LOW** | Minimal impact |

## Feedback on this Policy

For recommendations on how to improve this policy, either submit a pull request or email `[email protected]`.
8 changes: 8 additions & 0 deletions contracts/test/CW20toERC20PointerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ describe("CW20 to ERC20 Pointer", function () {
const response = await wasmd.execute(pointer, transferBz, coinsBz);
const receipt = await response.wait();
expect(receipt.status).to.equal(1);

const filter = {
fromBlock: receipt["blockNumber"],
toBlock: 'latest',
topics: [ethers.id("Transfer(address,address,uint256)")]
};
const logs = await ethers.provider.getLogs(filter);
expect(logs.length).to.equal(1);
});
});
});
Expand Down
8 changes: 6 additions & 2 deletions evmrpc/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,13 @@ func (f *LogFetcher) GetLogsForBlock(ctx context.Context, block *coretypes.Resul

func (f *LogFetcher) FindBlockesByBloom(begin, end int64, filters [][]bloomIndexes) (res []int64) {
//TODO: parallelize
ctx := f.ctxProvider(LatestCtxHeight)
for height := begin; height <= end; height++ {
blockBloom := f.k.GetBlockBloom(ctx, height)
if height == 0 {
// no block bloom on genesis height
continue
}
ctx := f.ctxProvider(height)
blockBloom := f.k.GetBlockBloom(ctx)
if MatchFilters(blockBloom, filters) {
res = append(res, height)
}
Expand Down
2 changes: 1 addition & 1 deletion evmrpc/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func TestFilterGetFilterChanges(t *testing.T) {
EVMKeeper.SetTxHashesOnHeight(Ctx, 9, []common.Hash{
common.HexToHash("0x123456789012345678902345678901234567890123456789012345678900005"),
})
EVMKeeper.SetBlockBloom(Ctx, 9, []ethtypes.Bloom{bloom})
EVMKeeper.SetBlockBloom(Ctx, []ethtypes.Bloom{bloom})
Ctx = Ctx.WithBlockHeight(9)
resObj = sendRequest(t, TestPort, "getFilterChanges", filterId)
Ctx = Ctx.WithBlockHeight(8)
Expand Down
18 changes: 13 additions & 5 deletions evmrpc/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,13 @@ func (m *MockBadClient) BroadcastTx(context.Context, tmtypes.Tx) (*coretypes.Res

var EVMKeeper *keeper.Keeper
var Ctx sdk.Context
var MultiTxCtx sdk.Context

func init() {
types.RegisterInterfaces(EncodingConfig.InterfaceRegistry)
testApp := app.Setup(false, false)
Ctx = testApp.GetContextForDeliverTx([]byte{}).WithBlockHeight(8)
MultiTxCtx, _ = Ctx.CacheContext()
EVMKeeper = &testApp.EvmKeeper
EVMKeeper.InitGenesis(Ctx, *evmtypes.DefaultGenesis())
seiAddr, err := sdk.AccAddressFromHex(common.Bytes2Hex([]byte("seiAddr")))
Expand All @@ -427,6 +429,12 @@ func init() {
panic(err)
}
testApp.Commit(context.Background())
ctxProvider := func(height int64) sdk.Context {
if height == MultiTxBlockHeight {
return MultiTxCtx
}
return Ctx
}
// Start good http server
goodConfig := evmrpc.DefaultConfig
goodConfig.HTTPPort = TestPort
Expand All @@ -437,7 +445,7 @@ func init() {
if err != nil {
panic(err)
}
HttpServer, err := evmrpc.NewEVMHTTPServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, "")
HttpServer, err := evmrpc.NewEVMHTTPServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, ctxProvider, TxConfig, "")
if err != nil {
panic(err)
}
Expand All @@ -449,7 +457,7 @@ func init() {
badConfig := evmrpc.DefaultConfig
badConfig.HTTPPort = TestBadPort
badConfig.FilterTimeout = 500 * time.Millisecond
badHTTPServer, err := evmrpc.NewEVMHTTPServer(infoLog, badConfig, &MockBadClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, "")
badHTTPServer, err := evmrpc.NewEVMHTTPServer(infoLog, badConfig, &MockBadClient{}, EVMKeeper, ctxProvider, TxConfig, "")
if err != nil {
panic(err)
}
Expand All @@ -458,7 +466,7 @@ func init() {
}

// Start ws server
wsServer, err := evmrpc.NewEVMWebSocketServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, func(int64) sdk.Context { return Ctx }, TxConfig, "")
wsServer, err := evmrpc.NewEVMWebSocketServer(infoLog, goodConfig, &MockClient{}, EVMKeeper, ctxProvider, TxConfig, "")
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -723,8 +731,8 @@ func setupLogs() {
EVMKeeper.SetTxHashesOnHeight(Ctx, MockHeight, []common.Hash{
multiTxBlockTx4.Hash(),
})
EVMKeeper.SetBlockBloom(Ctx, MultiTxBlockHeight, []ethtypes.Bloom{bloom1, bloom2, bloom3})
EVMKeeper.SetBlockBloom(Ctx, MockHeight, []ethtypes.Bloom{bloom4})
EVMKeeper.SetBlockBloom(MultiTxCtx, []ethtypes.Bloom{bloom1, bloom2, bloom3})
EVMKeeper.SetBlockBloom(Ctx, []ethtypes.Bloom{bloom4})
}

//nolint:deadcode
Expand Down
1 change: 1 addition & 0 deletions evmrpc/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (a *SubscriptionAPI) Logs(ctx context.Context, filter *filters.FilterCriter
return
}
begin = lastToHeight
filter.FromBlock = big.NewInt(lastToHeight + 1)

time.Sleep(SleepInterval)
}
Expand Down
2 changes: 1 addition & 1 deletion proto/evm/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "evm/config.proto";

option go_package = "github.com/sei-protocol/sei-chain/x/evm/types";

// Params defines the parameters for the module, for the version between v580 and v590
// Params defines the parameters for the module
message Params {
option (gogoproto.goproto_stringer) = false;

Expand Down
4 changes: 4 additions & 0 deletions x/evm/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func InitGenesis(ctx sdk.Context, k *keeper.Keeper, genState types.GenesisState)
k.SetNonce(ctx, common.HexToAddress(nonce.Address), nonce.Nonce)
}
for _, serialized := range genState.Serialized {
if len(serialized.Key) == 0 {
ctx.KVStore(k.GetStoreKey()).Set(serialized.Prefix, serialized.Value)
continue
}
k.PrefixStore(ctx, serialized.Prefix).Set(serialized.Key, serialized.Value)
}
}
Expand Down
4 changes: 2 additions & 2 deletions x/evm/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestExportImportGenesis(t *testing.T) {
keeper.SetState(ctx, codeAddr, common.BytesToHash([]byte("123")), common.BytesToHash([]byte("456")))
keeper.SetNonce(ctx, evmAddr, 2)
keeper.MockReceipt(ctx, common.BytesToHash([]byte("789")), &types.Receipt{TxType: 2})
keeper.SetBlockBloom(ctx, 5, []ethtypes.Bloom{{1}})
keeper.SetBlockBloom(ctx, []ethtypes.Bloom{{1}})
keeper.SetTxHashesOnHeight(ctx, 5, []common.Hash{common.BytesToHash([]byte("123"))})
keeper.SetERC20CW20Pointer(ctx, "cw20addr", codeAddr)
genesis := evm.ExportGenesis(ctx, keeper)
Expand All @@ -42,7 +42,7 @@ func TestExportImportGenesis(t *testing.T) {
require.Equal(t, keeper.GetNonce(ctx, evmAddr), keeper.GetNonce(origctx, evmAddr))
_, err := keeper.GetReceipt(origctx, common.BytesToHash([]byte("789")))
require.Nil(t, err)
require.Equal(t, keeper.GetBlockBloom(ctx, 5), keeper.GetBlockBloom(origctx, 5))
require.Equal(t, keeper.GetBlockBloom(ctx), keeper.GetBlockBloom(origctx))
require.Equal(t, keeper.GetTxHashesOnHeight(ctx, 5), keeper.GetTxHashesOnHeight(origctx, 5))
_, _, exists := keeper.GetERC20CW20Pointer(origctx, "cw20addr")
require.True(t, exists)
Expand Down
42 changes: 34 additions & 8 deletions x/evm/keeper/log.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"bytes"
"encoding/binary"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -11,7 +11,21 @@ import (
"github.com/sei-protocol/sei-chain/x/evm/types"
)

func (k *Keeper) GetBlockBloom(ctx sdk.Context, height int64) (res ethtypes.Bloom) {
func (k *Keeper) GetBlockBloom(ctx sdk.Context) (res ethtypes.Bloom) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.BlockBloomPrefix)
if bz != nil {
res.SetBytes(bz)
return
}
cutoff := k.GetLegacyBlockBloomCutoffHeight(ctx)
if cutoff == 0 || ctx.BlockHeight() < cutoff {
res = k.GetLegacyBlockBloom(ctx, ctx.BlockHeight())
}
return
}

func (k *Keeper) GetLegacyBlockBloom(ctx sdk.Context, height int64) (res ethtypes.Bloom) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.BlockBloomKey(height))
if bz != nil {
Expand All @@ -20,19 +34,31 @@ func (k *Keeper) GetBlockBloom(ctx sdk.Context, height int64) (res ethtypes.Bloo
return
}

func (k *Keeper) SetBlockBloom(ctx sdk.Context, height int64, blooms []ethtypes.Bloom) {
func (k *Keeper) SetBlockBloom(ctx sdk.Context, blooms []ethtypes.Bloom) {
blockBloom := make([]byte, ethtypes.BloomByteLength)
for _, bloom := range blooms {
or := make([]byte, ethtypes.BloomByteLength)
bitutil.ORBytes(or, blockBloom, bloom[:])
blockBloom = or
}
if bytes.Equal(blockBloom, make([]byte, ethtypes.BloomByteLength)) {
// early return if bloom is empty
return
}
store := ctx.KVStore(k.storeKey)
store.Set(types.BlockBloomKey(height), blockBloom)
store.Set(types.BlockBloomPrefix, blockBloom)
}

func (k *Keeper) SetLegacyBlockBloomCutoffHeight(ctx sdk.Context) {
store := ctx.KVStore(k.storeKey)
bz := make([]byte, 8)
binary.BigEndian.PutUint64(bz, uint64(ctx.BlockHeight()))
store.Set(types.LegacyBlockBloomCutoffHeightKey, bz)
}

func (k *Keeper) GetLegacyBlockBloomCutoffHeight(ctx sdk.Context) int64 {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.LegacyBlockBloomCutoffHeightKey)
if len(bz) == 0 {
return 0
}
return int64(binary.BigEndian.Uint64(bz))
}

func GetLogsForTx(receipt *types.Receipt) []*ethtypes.Log {
Expand Down
16 changes: 13 additions & 3 deletions x/evm/keeper/log_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keeper
package keeper_test

import (
"testing"
Expand All @@ -7,6 +7,8 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"

testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper"
"github.com/sei-protocol/sei-chain/x/evm/keeper"
evmtypes "github.com/sei-protocol/sei-chain/x/evm/types"
)

Expand All @@ -26,7 +28,7 @@ func TestConvertEthLog(t *testing.T) {
}

// Convert the ethtypes.Log to a types.Log
log := ConvertEthLog(ethLog)
log := keeper.ConvertEthLog(ethLog)

// Check that the fields match
require.Equal(t, ethLog.Address.Hex(), log.Address)
Expand Down Expand Up @@ -67,7 +69,7 @@ func TestGetLogsForTx(t *testing.T) {
}

// Convert the types.Receipt to a list of ethtypes.Log objects
logs := GetLogsForTx(receipt)
logs := keeper.GetLogsForTx(receipt)

// Check that the fields match
require.Equal(t, len(receipt.Logs), len(logs))
Expand All @@ -81,3 +83,11 @@ func TestGetLogsForTx(t *testing.T) {
require.Equal(t, uint(receipt.Logs[i].Index), log.Index)
}
}

func TestLegacyBlockBloomCutoffHeight(t *testing.T) {
k := &testkeeper.EVMTestApp.EvmKeeper
ctx := testkeeper.EVMTestApp.GetContextForDeliverTx([]byte{}).WithBlockHeight(123)
require.Equal(t, int64(0), k.GetLegacyBlockBloomCutoffHeight(ctx))
k.SetLegacyBlockBloomCutoffHeight(ctx)
require.Equal(t, int64(123), k.GetLegacyBlockBloomCutoffHeight(ctx))
}
Loading

0 comments on commit 0729ae9

Please sign in to comment.