diff --git a/CHANGELOG.md b/CHANGELOG.md index b6ebc1a76..b04f22813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## 2.0.40beta - 2023-03-10 +* [#646] (https://github.com/sei-protocol/sei-chain/pull/646) Optimizations for FinalizeBlock +* [#644] (https://github.com/sei-protocol/sei-chain/pull/644) [Oak Audit] Add check for non-existent transaction +* [#647] (https://github.com/sei-protocol/sei-chain/pull/647) Fixes to race conditions +* [#638] (https://github.com/sei-protocol/sei-chain/pull/638) Emit Version Related Metrics +* [#636] (https://github.com/sei-protocol/sei-chain/pull/636) Fix deadlock with upgrades +* [#635] (https://github.com/sei-protocol/sei-chain/pull/635) Add event to dex messages + ## 2.0.39beta - 2023-03-06 * [#632](https://github.com/sei-protocol/sei-chain/pull/632) Bump Sei-tendermint to reduce log volume * [#631](https://github.com/sei-protocol/sei-chain/pull/631) Nondeterminism deadlock fixes diff --git a/Makefile b/Makefile index 86cff77c0..531789223 100644 --- a/Makefile +++ b/Makefile @@ -66,7 +66,7 @@ BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' all: lint install install: go.sum - go install -race $(BUILD_FLAGS) ./cmd/seid + go install $(BUILD_FLAGS) ./cmd/seid # In case when running seid fails with nitro issue or if you make changes to nitro, please use install-all install-all: build-nitro install diff --git a/app/antedecorators/gasless_test.go b/app/antedecorators/gasless_test.go index 836add97b..2165030a5 100644 --- a/app/antedecorators/gasless_test.go +++ b/app/antedecorators/gasless_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/accesscontrol" "github.com/cosmos/cosmos-sdk/x/staking" @@ -16,6 +17,9 @@ import ( oracletypes "github.com/sei-protocol/sei-chain/x/oracle/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" ) var output = "" @@ -118,7 +122,12 @@ func TestGaslessDecorator(t *testing.T) { FakeAnteDecoratorThree{}, } chainedHandler, depGen := sdk.ChainAnteDecorators(anteDecorators...) - _, err := chainedHandler(sdk.Context{}, FakeTx{}, false) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + _, err := chainedHandler(ctx, FakeTx{}, false) require.NoError(t, err) require.Equal(t, "onetwothree", output) _, err = depGen([]accesscontrol.AccessOperation{}, FakeTx{}) @@ -171,7 +180,7 @@ func TestDexPlaceOrderGasless(t *testing.T) { // this needs to be updated if its changed from constant true // reset gasless gasless = true - err := CallGaslessDecoratorWithMsg(sdk.Context{}, &types.MsgPlaceOrders{}, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) + err := CallGaslessDecoratorWithMsg(sdk.NewContext(nil, tmproto.Header{}, false, nil), &types.MsgPlaceOrders{}, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) require.NoError(t, err) require.True(t, gasless) } @@ -193,14 +202,14 @@ func TestDexCancelOrderGasless(t *testing.T) { // not whitelisted // reset gasless gasless = true - err := CallGaslessDecoratorWithMsg(sdk.Context{}, &cancelMsg1, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) + err := CallGaslessDecoratorWithMsg(sdk.NewContext(nil, tmproto.Header{}, false, nil), &cancelMsg1, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) require.NoError(t, err) require.False(t, gasless) // whitelisted // reset gasless gasless = true - err = CallGaslessDecoratorWithMsg(sdk.Context{}, &cancelMsg2, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) + err = CallGaslessDecoratorWithMsg(sdk.NewContext(nil, tmproto.Header{}, false, nil), &cancelMsg2, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) require.NoError(t, err) require.True(t, gasless) } @@ -239,7 +248,7 @@ func TestNonGaslessMsg(t *testing.T) { // this needs to be updated if its changed from constant true // reset gasless gasless = true - err := CallGaslessDecoratorWithMsg(sdk.Context{}, &types.MsgRegisterContract{}, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) + err := CallGaslessDecoratorWithMsg(sdk.NewContext(nil, tmproto.Header{}, false, nil), &types.MsgRegisterContract{}, oraclekeeper.Keeper{}, nitrokeeper.Keeper{}) require.NoError(t, err) require.False(t, gasless) } diff --git a/app/antedecorators/priority_test.go b/app/antedecorators/priority_test.go index 0fe7322c3..bc5ceff19 100644 --- a/app/antedecorators/priority_test.go +++ b/app/antedecorators/priority_test.go @@ -10,6 +10,7 @@ import ( "github.com/sei-protocol/sei-chain/x/dex/types" oracletypes "github.com/sei-protocol/sei-chain/x/oracle/types" "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestPriorityAnteDecorator(t *testing.T) { @@ -17,7 +18,7 @@ func TestPriorityAnteDecorator(t *testing.T) { anteDecorators := []sdk.AnteFullDecorator{ sdk.DefaultWrappedAnteDecorator(antedecorators.NewPriorityDecorator()), } - ctx := sdk.Context{} + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil) chainedHandler, _ := sdk.ChainAnteDecorators(anteDecorators...) // test with normal priority newCtx, err := chainedHandler( @@ -34,7 +35,7 @@ func TestPriorityAnteDecoratorTooHighPriority(t *testing.T) { anteDecorators := []sdk.AnteFullDecorator{ sdk.DefaultWrappedAnteDecorator(antedecorators.NewPriorityDecorator()), } - ctx := sdk.Context{} + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil) chainedHandler, _ := sdk.ChainAnteDecorators(anteDecorators...) // test with too high priority, should be auto capped newCtx, err := chainedHandler( @@ -55,7 +56,7 @@ func TestPriorityAnteDecoratorOracleMsg(t *testing.T) { anteDecorators := []sdk.AnteFullDecorator{ sdk.DefaultWrappedAnteDecorator(antedecorators.NewPriorityDecorator()), } - ctx := sdk.Context{} + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil) chainedHandler, _ := sdk.ChainAnteDecorators(anteDecorators...) // test with zero priority, should be bumped up to oracle priority newCtx, err := chainedHandler( diff --git a/app/antedecorators/traced_test.go b/app/antedecorators/traced_test.go index efbca5cc4..8fac2da35 100644 --- a/app/antedecorators/traced_test.go +++ b/app/antedecorators/traced_test.go @@ -7,6 +7,7 @@ import ( "github.com/sei-protocol/sei-chain/app/antedecorators" "github.com/sei-protocol/sei-chain/utils" "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestTracedDecorator(t *testing.T) { @@ -20,6 +21,6 @@ func TestTracedDecorator(t *testing.T) { return sdk.DefaultWrappedAnteDecorator(antedecorators.NewTracedAnteDecorator(d, nil)) }) chainedHandler, _ := sdk.ChainAnteDecorators(tracedDecorators...) - chainedHandler(sdk.Context{}, FakeTx{}, false) + chainedHandler(sdk.NewContext(nil, tmproto.Header{}, false, nil), FakeTx{}, false) require.Equal(t, "onetwothree", output) } diff --git a/app/upgrades.go b/app/upgrades.go index 7fa81f280..aa36e83f2 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -55,6 +55,7 @@ var upgradesList = []string{ "2.0.37beta", "2.0.38beta", "2.0.39beta", + "2.0.40beta", } func (app App) RegisterUpgradeHandlers() { diff --git a/cmd/seid/cmd/root.go b/cmd/seid/cmd/root.go index 5034ef474..3bcf66438 100644 --- a/cmd/seid/cmd/root.go +++ b/cmd/seid/cmd/root.go @@ -6,8 +6,6 @@ import ( "io" "math" "math/rand" - "net/http" - _ "net/http/pprof" "os" "path/filepath" "time" @@ -63,9 +61,6 @@ func (s *rootOptions) apply(options ...Option) { //nolint:unused // I figure thi // NewRootCmd creates a new root command for a Cosmos SDK application func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - go func() { - http.ListenAndServe(":6060", nil) - }() encodingConfig := app.MakeEncodingConfig() initClientCtx := client.Context{}. WithCodec(encodingConfig.Marshaler). diff --git a/go.mod b/go.mod index 08936c595..4e934278e 100644 --- a/go.mod +++ b/go.mod @@ -269,10 +269,10 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.0.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.1-tony-2 - github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.2-tony-3 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.2.2 + github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 - github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.1.177 + github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.1.178 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index 349b6f346..1780ded5b 100644 --- a/go.sum +++ b/go.sum @@ -1066,12 +1066,12 @@ github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod github.com/securego/gosec/v2 v2.11.0 h1:+PDkpzR41OI2jrw1q6AdXZCbsNGNGT7pQjal0H0cArI= github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= -github.com/sei-protocol/sei-cosmos v0.2.1-tony-2 h1:RFs3RZ0VVV9IFTsK/0WX9E/p8axapU51+rtYinU08Lc= -github.com/sei-protocol/sei-cosmos v0.2.1-tony-2/go.mod h1:LUhhplOtRXliV1x17gbOptKPy90xSK0Sxv8zmgsMvTY= -github.com/sei-protocol/sei-iavl v0.1.2-tony-3 h1:udXCIcgpbJjX09c3udk8IlAyTRQyFWhZjw5SAgcuqaI= -github.com/sei-protocol/sei-iavl v0.1.2-tony-3/go.mod h1:7PfkEVT5dcoQE+s/9KWdoXJ8VVVP1QpYYPLdxlkSXFk= -github.com/sei-protocol/sei-tendermint v0.1.177 h1:gn6/z82eGBBdyRgEyd8wpbB0C3/l1BhjzcsiCFoSrvo= -github.com/sei-protocol/sei-tendermint v0.1.177/go.mod h1:+BtDvAwTkE64BlxzpH9ZP7S6vUYT9wRXiZa/WW8/o4g= +github.com/sei-protocol/sei-cosmos v0.2.2 h1:+VtjwsDcHJrxbNfXgZn5vkaQxtVRXC9tMzdyN/YMDDE= +github.com/sei-protocol/sei-cosmos v0.2.2/go.mod h1:LUhhplOtRXliV1x17gbOptKPy90xSK0Sxv8zmgsMvTY= +github.com/sei-protocol/sei-iavl v0.1.3 h1:0hvW1NtmBlZ7ZkerQcM/n+2tFKg0vUlYWK8q/OeuCgw= +github.com/sei-protocol/sei-iavl v0.1.3/go.mod h1:7PfkEVT5dcoQE+s/9KWdoXJ8VVVP1QpYYPLdxlkSXFk= +github.com/sei-protocol/sei-tendermint v0.1.178 h1:7ozXwpCvNrkU7UaaKcbHhtB/nRT0jQC3sC9VZJnK+Ak= +github.com/sei-protocol/sei-tendermint v0.1.178/go.mod h1:+BtDvAwTkE64BlxzpH9ZP7S6vUYT9wRXiZa/WW8/o4g= github.com/sei-protocol/sei-tm-db v0.0.5 h1:3WONKdSXEqdZZeLuWYfK5hP37TJpfaUa13vAyAlvaQY= github.com/sei-protocol/sei-tm-db v0.0.5/go.mod h1:Cpa6rGyczgthq7/0pI31jys2Fw0Nfrc+/jKdP1prVqY= github.com/sei-protocol/sei-wasmd v0.0.1 h1:dRvdapc1sqWxhIB2+DKS5LfilFjOsaFwWkGkSWwQIow= diff --git a/x/dex/exchange/limit_order_fuzz_test.go b/x/dex/exchange/limit_order_fuzz_test.go index abff273a3..2b33718d6 100644 --- a/x/dex/exchange/limit_order_fuzz_test.go +++ b/x/dex/exchange/limit_order_fuzz_test.go @@ -6,15 +6,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sei-protocol/sei-chain/testutil/fuzzing" + keepertest "github.com/sei-protocol/sei-chain/testutil/keeper" "github.com/sei-protocol/sei-chain/utils/datastructures" "github.com/sei-protocol/sei-chain/x/dex/exchange" "github.com/sei-protocol/sei-chain/x/dex/types" "github.com/stretchr/testify/require" - - keepertest "github.com/sei-protocol/sei-chain/testutil/keeper" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) -var TestFuzzLimitCtx = sdk.Context{} +var TestFuzzLimitCtx = sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger()) func FuzzMatchLimitOrders(f *testing.F) { TestFuzzLimitCtx = TestFuzzLimitCtx.WithBlockHeight(1).WithBlockTime(time.Now()) diff --git a/x/dex/exchange/market_order_fuzz_test.go b/x/dex/exchange/market_order_fuzz_test.go index 70ad0a5d0..be7fd5a66 100644 --- a/x/dex/exchange/market_order_fuzz_test.go +++ b/x/dex/exchange/market_order_fuzz_test.go @@ -13,9 +13,11 @@ import ( "github.com/sei-protocol/sei-chain/x/dex/types" dexutils "github.com/sei-protocol/sei-chain/x/dex/utils" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) -var TestFuzzMarketCtx = sdk.Context{} +var TestFuzzMarketCtx = sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger()) func FuzzMatchMarketOrders(f *testing.F) { f.Fuzz(fuzzTargetMatchMarketOrders) diff --git a/x/dex/exchange/settlement_fuzz_test.go b/x/dex/exchange/settlement_fuzz_test.go index e6e1ec4a1..b1ccd6703 100644 --- a/x/dex/exchange/settlement_fuzz_test.go +++ b/x/dex/exchange/settlement_fuzz_test.go @@ -11,9 +11,11 @@ import ( "github.com/sei-protocol/sei-chain/x/dex/exchange" "github.com/sei-protocol/sei-chain/x/dex/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) -var TestFuzzSettleCtx = sdk.Context{} +var TestFuzzSettleCtx = sdk.NewContext(nil, tmproto.Header{}, false, log.NewNopLogger()) func FuzzSettleMarketOrder(f *testing.F) { TestFuzzSettleCtx = TestFuzzSettleCtx.WithBlockHeight(1).WithBlockTime(time.Now()) diff --git a/x/nitro/replay/replay_test.go b/x/nitro/replay/replay_test.go index 88892fcf1..08fc0feb9 100644 --- a/x/nitro/replay/replay_test.go +++ b/x/nitro/replay/replay_test.go @@ -11,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sei-protocol/sei-chain/x/nitro/types" "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func testAccount() *types.Account { @@ -59,7 +60,7 @@ func testTransaction() types.TransactionData { } func TestReplay(t *testing.T) { - ctx := sdk.Context{}.WithBlockHeight(1) + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil).WithBlockHeight(1) tx := testTransaction() txbz, _ := tx.Marshal() _, err := Replay(ctx, [][]byte{txbz}, []*types.Account{}, []*types.Account{testAccount()}, []*types.Account{}) diff --git a/x/oracle/ante_test.go b/x/oracle/ante_test.go index ebc6480ba..4c1ef902b 100644 --- a/x/oracle/ante_test.go +++ b/x/oracle/ante_test.go @@ -9,6 +9,7 @@ import ( "github.com/sei-protocol/sei-chain/x/oracle" oracletypes "github.com/sei-protocol/sei-chain/x/oracle/types" "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) func TestOracleVoteAloneAnteHandler(t *testing.T) { @@ -32,7 +33,7 @@ func TestOracleVoteAloneAnteHandler(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - _, err := anteHandler(sdk.Context{}, tc.tx, false) + _, err := anteHandler(sdk.NewContext(nil, tmproto.Header{}, false, nil), tc.tx, false) if tc.expErr { require.Error(t, err) } else {