Skip to content

Commit

Permalink
Merge branch 'feature/firehose-tracer-at-latest-release-tag' into rel…
Browse files Browse the repository at this point in the history
…ease/firehose
  • Loading branch information
maoueh committed Jul 10, 2024
2 parents 7ae491f + 8a8244d commit 7780d40
Show file tree
Hide file tree
Showing 112 changed files with 3,417 additions and 4,224 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ jobs:
matrix:
test: [
{
name: "Dex & Wasm Module",
name: "Wasm Module",
scripts: [
"docker exec sei-node-0 integration_test/contracts/deploy_dex_contract.sh mars",
"python3 integration_test/scripts/runner.py integration_test/dex_module/place_order_test.yaml",
"python3 integration_test/scripts/runner.py integration_test/dex_module/cancel_order_test.yaml",
"docker exec sei-node-0 integration_test/contracts/deploy_timelocked_token_contract.sh",
"python3 integration_test/scripts/runner.py integration_test/wasm_module/timelocked_token_delegation_test.yaml",
"python3 integration_test/scripts/runner.py integration_test/wasm_module/timelocked_token_admin_test.yaml",
Expand Down
37 changes: 36 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,42 @@ Types of changes (Stanzas):
Ref: https://keepachangelog.com/en/1.0.0/
-->

# Changelog## v5.5.5
# Changelog

## v5.6.0
sei-chain
* [#1690](https://github.com/sei-protocol/sei-chain/pull/1690) Use transient store for EVM deferred info
* [#1742](https://github.com/sei-protocol/sei-chain/pull/1742) \[EVM\] Add transient receipts with eventual flush to store
* [#1744](https://github.com/sei-protocol/sei-chain/pull/1744) Only emit cosmos events if no error in precompiles
* [#1737](https://github.com/sei-protocol/sei-chain/pull/1737) Only send unlocked tokens upon address association
* [#1740](https://github.com/sei-protocol/sei-chain/pull/1740) Update Random to Hash of Block Timestamp
* [#1734](https://github.com/sei-protocol/sei-chain/pull/1734) Add migration to unwind dex state
* [#1736](https://github.com/sei-protocol/sei-chain/pull/1736) Create account for sendNative receiver
* [#1738](https://github.com/sei-protocol/sei-chain/pull/1738) Reduce Default TTL configs
* [#1733](https://github.com/sei-protocol/sei-chain/pull/1733) Update getBlockReceipts to accept block hash
* [#1732](https://github.com/sei-protocol/sei-chain/pull/1732) Show empty trace on insufficient funds error
* [#1727](https://github.com/sei-protocol/sei-chain/pull/1727) \[EVM\] Add association error metric
* [#1728](https://github.com/sei-protocol/sei-chain/pull/1728) Make occ caused evm panics less noisy
* [#1719](https://github.com/sei-protocol/sei-chain/pull/1719) Fixes local network in /scripts/run-node.py


sei-cosmos
* [#521](https://github.com/sei-protocol/sei-cosmos/pull/521) add DeliverTx hook
* [#520](https://github.com/sei-protocol/sei-cosmos/pull/520) Add callback for receipt storage
* [#517](https://github.com/sei-protocol/sei-cosmos/pull/517) Fix metric name for chain state size
* [#516](https://github.com/sei-protocol/sei-cosmos/pull/516) add EVM event manager to context


sei-wasmd
* [#54](https://github.com/sei-protocol/sei-wasmd/pull/54) Update wasm query behavior upon error


sei-tendermint
* [238](https://github.com/sei-protocol/sei-tendermint/pull/238) Make RPC timeout configurable
* [219](https://github.com/sei-protocol/sei-tendermint/pull/219) Add metrics for mempool change


## v5.5.5
sei-chain
* [#1726](https://github.com/sei-protocol/sei-chain/pull/1726) Handle VM error code properly
* [#1713](https://github.com/sei-protocol/sei-chain/pull/1713) RPC Get Evm Hash
Expand Down
9 changes: 5 additions & 4 deletions aclmapping/dex/mappings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
acltypes "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"
"github.com/k0kubun/pp/v3"
dexacl "github.com/sei-protocol/sei-chain/aclmapping/dex"
Expand Down Expand Up @@ -135,13 +136,13 @@ func (suite *KeeperTestSuite) TestMsgPlaceOrder() {
{
name: "default place order",
msg: suite.msgPlaceOrders,
expectedError: nil,
expectedError: sdkerrors.Wrapf(sdkerrors.ErrNotSupported, "deprecated"),
dynamicDep: true,
},
{
name: "dont check synchronous",
msg: suite.msgPlaceOrders,
expectedError: nil,
expectedError: sdkerrors.Wrapf(sdkerrors.ErrNotSupported, "deprecated"),
dynamicDep: false,
},
}
Expand Down Expand Up @@ -191,13 +192,13 @@ func (suite *KeeperTestSuite) TestMsgCancelOrder() {
{
name: "default cancel order",
msg: suite.msgCancelOrders,
expectedError: nil,
expectedError: sdkerrors.Wrapf(sdkerrors.ErrNotSupported, "deprecated"),
dynamicDep: true,
},
{
name: "dont check synchronous",
msg: suite.msgCancelOrders,
expectedError: nil,
expectedError: sdkerrors.Wrapf(sdkerrors.ErrNotSupported, "deprecated"),
dynamicDep: false,
},
}
Expand Down
1 change: 0 additions & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ func NewAnteHandlerAndDepGenerator(options HandlerOptions) (sdk.AnteHandler, sdk
sdk.DefaultWrappedAnteDecorator(evmante.NewGasLimitDecorator(options.EVMKeeper)),
}
evmAnteHandler, evmAnteDepGenerator := sdk.ChainAnteDecorators(evmAnteDecorators...)
evmAnteHandler = evmante.NewAnteErrorHandler(evmAnteHandler, options.EVMKeeper).Handle

router := evmante.NewEVMRouterDecorator(anteHandler, evmAnteHandler, anteDepGenerator, evmAnteDepGenerator)

Expand Down
2 changes: 2 additions & 0 deletions app/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ func TestEvmAnteErrorHandler(t *testing.T) {
require.NotEqual(t, 0, res.Code)
testkeeper.EVMTestApp.EvmKeeper.SetTxResults([]*abci.ExecTxResult{{
Code: res.Code,
Log: "nonce too high",
}})
testkeeper.EVMTestApp.EvmKeeper.SetMsgs([]*evmtypes.MsgEVMTransaction{req})
deferredInfo := testkeeper.EVMTestApp.EvmKeeper.GetEVMTxDeferredInfo(ctx)
require.Equal(t, 1, len(deferredInfo))
require.Contains(t, deferredInfo[0].Error, "nonce too high")
Expand Down
111 changes: 84 additions & 27 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import (
"sync"
"time"

"github.com/cosmos/cosmos-sdk/server"
ethcommon "github.com/ethereum/go-ethereum/common"
ethhexutil "github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/sei-protocol/sei-db/ss"

"github.com/ethereum/go-ethereum/ethclient"
ethrpc "github.com/ethereum/go-ethereum/rpc"
Expand All @@ -31,14 +33,6 @@ import (

storetypes "github.com/cosmos/cosmos-sdk/store/types"

"github.com/sei-protocol/sei-chain/aclmapping"
aclutils "github.com/sei-protocol/sei-chain/aclmapping/utils"
appparams "github.com/sei-protocol/sei-chain/app/params"
"github.com/sei-protocol/sei-chain/app/upgrades"
v0upgrade "github.com/sei-protocol/sei-chain/app/upgrades/v0"
"github.com/sei-protocol/sei-chain/utils"
"github.com/sei-protocol/sei-chain/wasmbinding"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -52,27 +46,26 @@ import (
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"

sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
aclmodule "github.com/cosmos/cosmos-sdk/x/accesscontrol"
aclclient "github.com/cosmos/cosmos-sdk/x/accesscontrol/client"
aclconstants "github.com/cosmos/cosmos-sdk/x/accesscontrol/constants"
aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper"
acltypes "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down Expand Up @@ -123,11 +116,13 @@ import (
ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper"
"github.com/sei-protocol/sei-chain/x/mint"
mintclient "github.com/sei-protocol/sei-chain/x/mint/client/cli"
mintkeeper "github.com/sei-protocol/sei-chain/x/mint/keeper"
minttypes "github.com/sei-protocol/sei-chain/x/mint/types"

"github.com/sei-protocol/sei-chain/aclmapping"
aclutils "github.com/sei-protocol/sei-chain/aclmapping/utils"
appparams "github.com/sei-protocol/sei-chain/app/params"
"github.com/sei-protocol/sei-chain/app/upgrades"
v0upgrade "github.com/sei-protocol/sei-chain/app/upgrades/v0"
"github.com/sei-protocol/sei-chain/utils"
"github.com/sei-protocol/sei-chain/wasmbinding"
"github.com/sei-protocol/sei-chain/x/evm"
evmante "github.com/sei-protocol/sei-chain/x/evm/ante"
"github.com/sei-protocol/sei-chain/x/evm/blocktest"
Expand All @@ -137,6 +132,11 @@ import (
evmtracers "github.com/sei-protocol/sei-chain/x/evm/tracers"
"github.com/sei-protocol/sei-chain/x/evm/tracing"
evmtypes "github.com/sei-protocol/sei-chain/x/evm/types"
"github.com/sei-protocol/sei-chain/x/mint"
mintclient "github.com/sei-protocol/sei-chain/x/mint/client/cli"
mintkeeper "github.com/sei-protocol/sei-chain/x/mint/keeper"
minttypes "github.com/sei-protocol/sei-chain/x/mint/types"
seidb "github.com/sei-protocol/sei-db/ss/types"
"github.com/spf13/cast"
abci "github.com/tendermint/tendermint/abci/types"
tmcfg "github.com/tendermint/tendermint/config"
Expand Down Expand Up @@ -173,6 +173,8 @@ import (

// unnamed import of statik for openapi/swagger UI support
_ "github.com/sei-protocol/sei-chain/docs/swagger"

ssconfig "github.com/sei-protocol/sei-db/config"
)

// this line is used by starport scaffolding # stargate/wasm/app/enabledProposals
Expand Down Expand Up @@ -241,7 +243,7 @@ var (
oracletypes.ModuleName: nil,
wasm.ModuleName: {authtypes.Burner},
evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner},
dexmoduletypes.ModuleName: nil,
dexmoduletypes.ModuleName: {authtypes.Burner},
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
// this line is used by starport scaffolding # stargate/app/maccPerms
}
Expand Down Expand Up @@ -271,7 +273,8 @@ var (
// EmptyAclmOpts defines a type alias for a list of wasm options.
EmptyACLOpts []aclkeeper.Option
// EnableOCC allows tests to override default OCC enablement behavior
EnableOCC = true
EnableOCC = true
EmptyAppOptions []AppOption
)

var (
Expand Down Expand Up @@ -390,8 +393,12 @@ type App struct {
evmRPCConfig evmrpc.Config
evmTracer *tracing.Hooks
lightInvarianceConfig LightInvarianceConfig

receiptStore seidb.StateStore
}

type AppOption func(*App)

// New returns a reference to an initialized blockchain app
func New(
logger log.Logger,
Expand All @@ -408,13 +415,15 @@ func New(
appOpts servertypes.AppOptions,
wasmOpts []wasm.Option,
aclOpts []aclkeeper.Option,
appOptions []AppOption,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
appCodec := encodingConfig.Marshaler
cdc := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry

bAppOptions := SetupSeiDB(logger, homePath, appOpts, baseAppOptions)

bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), tmConfig, appOpts, bAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
Expand All @@ -431,8 +440,8 @@ func New(
tokenfactorytypes.StoreKey,
// this line is used by starport scaffolding # stargate/app/storeKey
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, dexmoduletypes.MemStoreKey, banktypes.DeferredCacheStoreKey, evmtypes.MemStoreKey, oracletypes.MemStoreKey)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, dexmoduletypes.MemStoreKey, banktypes.DeferredCacheStoreKey, oracletypes.MemStoreKey)

app := &App{
BaseApp: bApp,
Expand All @@ -448,6 +457,11 @@ func New(
metricCounter: &map[string]float32{},
encodingConfig: encodingConfig,
}

for _, option := range appOptions {
option(app)
}

app.ParamsKeeper = initParamsKeeper(appCodec, cdc, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

// set the BaseApp's parameter store
Expand Down Expand Up @@ -604,9 +618,26 @@ func New(
wasmOpts...,
)

app.EvmKeeper = *evmkeeper.NewKeeper(keys[evmtypes.StoreKey], memKeys[evmtypes.MemStoreKey],
app.GetSubspace(evmtypes.ModuleName), app.BankKeeper, &app.AccountKeeper, &app.StakingKeeper,
app.TransferKeeper, wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper), &app.WasmKeeper)
receiptStorePath := filepath.Join(homePath, "data", "receipt.db")
ssConfig := ssconfig.DefaultStateStoreConfig()
ssConfig.DedicatedChangelog = true
ssConfig.KeepRecent = cast.ToInt(appOpts.Get(server.FlagMinRetainBlocks))
ssConfig.DBDirectory = receiptStorePath
ssConfig.KeepLastVersion = false
if app.receiptStore == nil {
app.receiptStore, err = ss.NewStateStore(logger, receiptStorePath, ssConfig)
if err != nil {
panic(fmt.Sprintf("error while creating receipt store: %s", err))
}
}
app.EvmKeeper = *evmkeeper.NewKeeper(keys[evmtypes.StoreKey],
tkeys[evmtypes.TransientStoreKey], app.GetSubspace(evmtypes.ModuleName), app.receiptStore, app.BankKeeper,
&app.AccountKeeper, &app.StakingKeeper, app.TransferKeeper,
wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper), &app.WasmKeeper)

bApp.SetPreCommitHandler(app.HandlePreCommit)
bApp.SetCloseHandler(app.HandleClose)

app.evmRPCConfig, err = evmrpc.ReadConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error reading EVM config due to %s", err))
Expand Down Expand Up @@ -700,6 +731,7 @@ func New(
app.IBCKeeper.ClientKeeper,
app.IBCKeeper.ConnectionKeeper,
app.IBCKeeper.ChannelKeeper,
app.AccountKeeper,
); err != nil {
panic(err)
}
Expand Down Expand Up @@ -986,6 +1018,19 @@ func New(
return app
}

// HandlePreCommit happens right before the block is committed
func (app *App) HandlePreCommit(ctx sdk.Context) error {
return app.EvmKeeper.FlushTransientReceipts(ctx)
}

// Close closes all items that needs closing (called by baseapp)
func (app *App) HandleClose() error {
if app.receiptStore != nil {
return app.receiptStore.Close()
}
return nil
}

// Add (or remove) keepers when they are introduced / removed in different versions
func (app *App) SetStoreUpgradeHandlers() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
Expand Down Expand Up @@ -1577,6 +1622,7 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ
beginBlockResp := app.BeginBlock(ctx, beginBlockReq)
events = append(events, beginBlockResp.Events...)

evmTxs := make([]*evmtypes.MsgEVMTransaction, len(txs)) // nil for non-EVM txs
txResults = make([]*abci.ExecTxResult, len(txs))
typedTxs := app.DecodeTransactionsConcurrently(ctx, txs)

Expand All @@ -1593,6 +1639,11 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ
prioritizedResults, ctx := app.ExecuteTxsConcurrently(ctx, prioritizedTxs, prioritizedTypedTxs, prioritizedIndices)
for relativePrioritizedIndex, originalIndex := range prioritizedIndices {
txResults[originalIndex] = prioritizedResults[relativePrioritizedIndex]
if emsg := evmtypes.GetEVMTransactionMessage(prioritizedTypedTxs[relativePrioritizedIndex]); emsg != nil && !emsg.IsAssociateTx() {
evmTxs[originalIndex] = emsg
} else {
evmTxs[originalIndex] = nil
}
}

// Finalize all Bank Module Transfers here so that events are included for prioritiezd txs
Expand All @@ -1605,8 +1656,14 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ
otherResults, ctx := app.ExecuteTxsConcurrently(ctx, otherTxs, otherTypedTxs, otherIndices)
for relativeOtherIndex, originalIndex := range otherIndices {
txResults[originalIndex] = otherResults[relativeOtherIndex]
if emsg := evmtypes.GetEVMTransactionMessage(otherTypedTxs[relativeOtherIndex]); emsg != nil && !emsg.IsAssociateTx() {
evmTxs[originalIndex] = emsg
} else {
evmTxs[originalIndex] = nil
}
}
app.EvmKeeper.SetTxResults(txResults)
app.EvmKeeper.SetMsgs(evmTxs)

// Finalize all Bank Module Transfers here so that events are included
lazyWriteEvents := app.BankKeeper.WriteDeferredBalances(ctx)
Expand Down
4 changes: 2 additions & 2 deletions app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func SetTendermintConfigs(config *tmcfg.Config) {
config.Mempool.Size = 1000
config.Mempool.MaxTxsBytes = 10737418240
config.Mempool.MaxTxBytes = 2048576
config.Mempool.TTLDuration = 30 * time.Second
config.Mempool.TTLNumBlocks = 100
config.Mempool.TTLDuration = 15 * time.Second
config.Mempool.TTLNumBlocks = 30
// Consensus Configs
config.Consensus.GossipTransactionKeyOnly = true
config.Consensus.UnsafeProposeTimeoutOverride = 300 * time.Millisecond
Expand Down
Loading

0 comments on commit 7780d40

Please sign in to comment.