diff --git a/Makefile b/Makefile index 1aeab949a2..f89d01834f 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ BUILDDIR ?= $(CURDIR)/build INVARIANT_CHECK_INTERVAL ?= $(INVARIANT_CHECK_INTERVAL:-0) export PROJECT_HOME=$(shell git rev-parse --show-toplevel) export GO_PKG_PATH=$(HOME)/go/pkg +export GO_MOD_CACHE=$(shell go env GOMODCACHE) export GO111MODULE = on # process build tags @@ -52,12 +53,6 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=sei \ -X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" -# go 1.23+ needs a workaround to link memsize (see https://github.com/fjl/memsize). -# NOTE: this is a terribly ugly and unstable way of comparing version numbers, -# but that's what you get when you do anything nontrivial in a Makefile. -ifeq ($(firstword $(sort go1.23 $(shell go env GOVERSION))), go1.23) - ldflags += -checklinkname=0 -endif ifeq ($(LINK_STATICALLY),true) ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static" endif @@ -199,6 +194,12 @@ docker-cluster-start: docker-cluster-stop build-docker-node @mkdir -p $(shell go env GOCACHE) @cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) NUM_ACCOUNTS=10 INVARIANT_CHECK_INTERVAL=${INVARIANT_CHECK_INTERVAL} UPGRADE_VERSION_LIST=${UPGRADE_VERSION_LIST} docker compose up +docker-mev-cluster-start: docker-mev-cluster-stop build-docker-node + @rm -rf $(PROJECT_HOME)/build/generated + @mkdir -p $(shell go env GOPATH)/pkg/mod + @mkdir -p $(shell go env GOCACHE) + @cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) NUM_ACCOUNTS=10 INVARIANT_CHECK_INTERVAL=${INVARIANT_CHECK_INTERVAL} UPGRADE_VERSION_LIST=${UPGRADE_VERSION_LIST} docker compose -f docker-compose.yml -f docker-compose.mev.yml up + .PHONY: localnet-start # Use this to skip the seid build process @@ -210,7 +211,11 @@ docker-cluster-start-skipbuild: docker-cluster-stop build-docker-node # Stop 4-node docker containers docker-cluster-stop: @cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) docker compose down -.PHONY: localnet-stop ddd + +docker-mev-cluster-stop: + @cd docker && USERID=$(shell id -u) GROUPID=$(shell id -g) GOCACHE=$(shell go env GOCACHE) docker compose -f docker-compose.yml -f docker-compose.mev.yml down + +.PHONY: localnet-stop # Implements test splitting and running. This is pulled directly from @@ -233,4 +238,4 @@ $(BUILDDIR)/packages.txt:$(GO_TEST_FILES) $(BUILDDIR) split-test-packages:$(BUILDDIR)/packages.txt split -d -n l/$(NUM_SPLIT) $< $<. test-group-%:split-test-packages - cat $(BUILDDIR)/packages.txt.$* | xargs go test -parallel 4 -mod=readonly -timeout=15m -race -coverprofile=$*.profile.out -covermode=atomic + cat $(BUILDDIR)/packages.txt.$* | xargs go test -parallel 4 -mod=readonly -timeout=10m -race -coverprofile=$*.profile.out -covermode=atomic diff --git a/aclmapping/oracle/mappings_test.go b/aclmapping/oracle/mappings_test.go index 86d034f9df..d6c7178a9d 100644 --- a/aclmapping/oracle/mappings_test.go +++ b/aclmapping/oracle/mappings_test.go @@ -129,7 +129,7 @@ func TestMsgVoteDependencyGenerator(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) oracleVote := oracletypes.MsgAggregateExchangeRateVote{ ExchangeRates: "1usei", @@ -147,7 +147,7 @@ func TestMsgVoteDependencyGeneratorInvalidMsgType(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) _, err := oracleacl.MsgVoteDependencyGenerator(testWrapper.App.AccessControlKeeper, testWrapper.Ctx, &banktypes.MsgSend{}) require.Error(t, err) } diff --git a/aclmapping/staking/mappings_test.go b/aclmapping/staking/mappings_test.go index 3e0332771c..1c70f801f7 100644 --- a/aclmapping/staking/mappings_test.go +++ b/aclmapping/staking/mappings_test.go @@ -279,7 +279,7 @@ func (suite *KeeperTestSuite) TestMsgDelegateDependencies() { func TestGeneratorInvalidMessageTypes(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) stakingDelegate := stakingtypes.MsgDelegate{ DelegatorAddress: "delegator", diff --git a/app/app.go b/app/app.go index aa65d84fc5..8dff86efbc 100644 --- a/app/app.go +++ b/app/app.go @@ -160,6 +160,10 @@ 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" + + mevbase "github.com/sei-protocol/sei-chain/mev" + mev "github.com/sei-protocol/sei-chain/x/mev" + mevtypes "github.com/sei-protocol/sei-chain/x/mev/types" ) // this line is used by starport scaffolding # stargate/wasm/app/enabledProposals @@ -212,6 +216,7 @@ var ( epochmodule.AppModuleBasic{}, tokenfactorymodule.AppModuleBasic{}, ctmodule.AppModuleBasic{}, + mev.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -230,8 +235,8 @@ var ( evmtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, // Confidential Transfers module is not live yet, but we add the permissions for testing - cttypes.ModuleName: nil, - + cttypes.ModuleName: nil, + mevtypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } @@ -342,6 +347,7 @@ type App struct { WasmKeeper wasm.Keeper OracleKeeper oraclekeeper.Keeper EvmKeeper evmkeeper.Keeper + MevKeeper *mevbase.Keeper // pointer as this is used internally only, and synced via Mutex // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper @@ -379,6 +385,7 @@ type App struct { encodingConfig appparams.EncodingConfig evmRPCConfig evmrpc.Config + mevConfig mevbase.Config lightInvarianceConfig LightInvarianceConfig genesisImportConfig genesistypes.GenesisImportConfig @@ -570,6 +577,13 @@ func New( app.AccountKeeper, app.BankKeeper) + keys[mevtypes.StoreKey] = storetypes.NewKVStoreKey(mevtypes.StoreKey) + + app.MevKeeper = mevbase.NewKeeper( + appCodec, + keys[mevtypes.StoreKey], + ) + // The last arguments can contain custom message handlers, and custom query handlers, // if we want to allow any custom callbacks supportedFeatures := "iterator,staking,stargate,sei" @@ -637,6 +651,10 @@ func New( if err != nil { panic(fmt.Sprintf("error reading EVM config due to %s", err)) } + app.mevConfig, err = mevbase.ReadConfig(appOpts) + if err != nil { + panic(fmt.Sprintf("error reading MEV config due to %s", err)) + } evmQueryConfig, err := querier.ReadConfig(appOpts) if err != nil { panic(fmt.Sprintf("error reading evm query config due to %s", err)) @@ -777,6 +795,7 @@ func New( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), ctmodule.NewAppModule(app.ConfidentialTransfersKeeper), // this line is used by starport scaffolding # stargate/app/appModule + mev.NewAppModule(appCodec, app.MevKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -809,6 +828,7 @@ func New( tokenfactorytypes.ModuleName, cttypes.ModuleName, acltypes.ModuleName, + mevtypes.ModuleName, ) app.mm.SetOrderMidBlockers( @@ -841,6 +861,7 @@ func New( tokenfactorytypes.ModuleName, cttypes.ModuleName, acltypes.ModuleName, + mevtypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -874,6 +895,7 @@ func New( wasm.ModuleName, evmtypes.ModuleName, acltypes.ModuleName, + mevtypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -1136,7 +1158,14 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res return app.mm.InitGenesis(ctx, app.appCodec, genesisState, app.genesisImportConfig) } -func (app *App) PrepareProposalHandler(_ sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { +func (app *App) PrepareProposalHandler(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + // Get all pending bundles for this height + ctx.Logger().Debug("Preparing proposal", "height", ctx.BlockHeight()) + + if app.mevConfig.Enabled { + return app.mevPrepareProposalHandler(ctx, req) + } + return &abci.ResponsePrepareProposal{ TxRecords: utils.Map(req.Txs, func(tx []byte) *abci.TxRecord { return &abci.TxRecord{Action: abci.TxRecord_UNMODIFIED, Tx: tx} @@ -1144,6 +1173,96 @@ func (app *App) PrepareProposalHandler(_ sdk.Context, req *abci.RequestPreparePr }, nil } +func (app *App) mevPrepareProposalHandler(ctx sdk.Context, req *abci.RequestPrepareProposal) (*abci.ResponsePrepareProposal, error) { + bundles := app.MevKeeper.PendingBundles(ctx.BlockHeight()) + + if len(bundles) > 0 { + ctx.Logger().Debug("found pending bundles from mevkeeper", "count", len(bundles), "height", ctx.BlockHeight()) + } + + maxTxBytes := req.MaxTxBytes + selectedTxs := make([]*abci.TxRecord, 0) + + var selectedTxsTotalSize = int64(0) + var remainingTxs [][]byte + // map tx hash to index in remainingTxs + var remainingTxsMap = make(map[string]int) + + // First, add any system transactions (governance, etc.) + for _, tx := range req.Txs { + if app.isSystemTx(tx) { + selectedTxs = append(selectedTxs, &abci.TxRecord{ + Action: abci.TxRecord_UNMODIFIED, + Tx: tx, + }) + + selectedTxsTotalSize += int64(len(tx)) + } else { + remainingTxs = append(remainingTxs, tx) + remainingTxsMap[string(tx)] = len(remainingTxs) - 1 + } + } + + // Next, add bundle transactions with the highest priority + for _, bundle := range bundles { + // Skip bundles not meant for this height + if bundle.BlockHeight != uint64(ctx.BlockHeight()) { + continue + } + + // Calculate total size of this bundle + bundleSize := int64(0) + for _, txStr := range bundle.Transactions { + bundleSize += int64(len(txStr)) + } + + // Check if entire bundle fits + if selectedTxsTotalSize+bundleSize <= maxTxBytes { + // Add all transactions from this bundle + for _, tx := range bundle.Transactions { + selectedTxs = append(selectedTxs, &abci.TxRecord{ + Action: abci.TxRecord_UNMODIFIED, + Tx: tx, + }) + + //remove tx from remaining if it was already in a bundle + index, has := remainingTxsMap[string(tx)] + if has { + remainingTxs = append(remainingTxs[:index], remainingTxs[index+1:]...) + delete(remainingTxsMap, string(tx)) + } + } + selectedTxsTotalSize += bundleSize + } + } + + // Finally, add remaining transactions up to size limit + for _, tx := range remainingTxs { + if selectedTxsTotalSize+int64(len(tx)) <= maxTxBytes { + selectedTxs = append(selectedTxs, &abci.TxRecord{ + Action: abci.TxRecord_UNMODIFIED, + Tx: tx, + }) + selectedTxsTotalSize += int64(len(tx)) + if selectedTxsTotalSize >= maxTxBytes { + break + } + } + } + + return &abci.ResponsePrepareProposal{ + TxRecords: selectedTxs, + }, nil +} + +func (app *App) isSystemTx(tx []byte) bool { + // Implement system transaction detection logic + // This could check for specific message types that should always be included + // like governance votes, IBC packets, etc. + // TODO get SEI team input, which tx should be put before bundles in a block + return false +} + func (app *App) GetOptimisticProcessingInfo() *OptimisticProcessingInfo { return app.optimisticProcessingInfo } @@ -1893,6 +2012,14 @@ func (app *App) RegisterTendermintService(clientCtx client.Context) { panic(err) } } + + if app.mevConfig.Enabled { + _, err := mevbase.NewPoller(app.GetCheckCtx().Context(), app.Logger(), app.mevConfig, app.MevKeeper, app.LastBlockHeight) + if err != nil { + panic(err) + } + } + } // RegisterSwaggerAPI registers swagger route with API Server @@ -2018,6 +2145,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(epochmoduletypes.ModuleName) paramsKeeper.Subspace(tokenfactorytypes.ModuleName) paramsKeeper.Subspace(cttypes.ModuleName) + paramsKeeper.Subspace(mevtypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/app/app_mev_test.go b/app/app_mev_test.go new file mode 100644 index 0000000000..fc91440d9b --- /dev/null +++ b/app/app_mev_test.go @@ -0,0 +1,150 @@ +package app_test + +import ( + "testing" + "time" + + types "github.com/SiloMEV/silo-mev-protobuf-go/mev/v1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/sei-protocol/sei-chain/app" + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" +) + +func TestBundleSubmissionSuccess(t *testing.T) { + tm := time.Now().UTC() + valPub := secp256k1.GenPrivKey().PubKey() + secondAcc := secp256k1.GenPrivKey().PubKey() + + testWrapper := app.NewTestWrapper(t, tm, valPub, false, true) + + account := sdk.AccAddress(valPub.Address()).String() + account2 := sdk.AccAddress(secondAcc.Address()).String() + + // Create a bank message (same as TestProcessOracleAndOtherTxsSuccess) + bankMsg := &banktypes.MsgSend{ + FromAddress: account, + ToAddress: account2, + Amount: sdk.NewCoins(sdk.NewInt64Coin("usei", 2)), + } + + // Create transaction (using same pattern as lines 228-244) + txBuilder := app.MakeEncodingConfig().TxConfig.NewTxBuilder() + err := txBuilder.SetMsgs(bankMsg) + require.NoError(t, err) + txBuilder.SetGasLimit(100000) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewInt64Coin("usei", 10000))) + tx, err := app.MakeEncodingConfig().TxConfig.TxEncoder()(txBuilder.GetTx()) + require.NoError(t, err) + + // Create and submit bundle + height := int64(1) + bundle := &types.Bundle{ + Transactions: [][]byte{tx}, + BlockHeight: uint64(height), + } + + res := testWrapper.App.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + + // Verify bundle was stored immediately after submission + queryRes := testWrapper.App.MevKeeper.PendingBundles(height) + require.Equal(t, 1, len(queryRes)) + require.Equal(t, bundle.Transactions, queryRes[0].Transactions) + + // Verify bundle was stored immediately after submission + queryRes2 := testWrapper.App.MevKeeper.PendingBundles(height) + require.Equal(t, 1, len(queryRes2)) + require.Equal(t, bundle.Transactions, queryRes2[0].Transactions) + + // Call PrepareProposal + prepareProposalReq := abci.RequestPrepareProposal{ + MaxTxBytes: 1000000, + Height: height, + Time: testWrapper.Ctx.BlockTime(), + } + + prepareProposalRes, err := testWrapper.App.PrepareProposal(sdk.WrapSDKContext(testWrapper.Ctx), &prepareProposalReq) + require.NoError(t, err) + require.NotNil(t, prepareProposalRes) + + t.Log("prepareProposalRes", prepareProposalRes) + + // Extract tx bytes from TxRecords + txBytes := [][]byte{} + for _, record := range prepareProposalRes.TxRecords { + txBytes = append(txBytes, record.Tx) + } + require.Contains(t, txBytes, tx) + + // Process block (same pattern as lines 251-261) + req := &abci.RequestFinalizeBlock{ + Height: height, + Txs: txBytes, + } + _, txResults, _, _ := testWrapper.App.ProcessBlock( + testWrapper.Ctx.WithBlockHeight(height), + txBytes, + req, + req.DecidedLastCommit, + false, + ) + + t.Log("txResults", txResults) + + // Verify results + require.Equal(t, 1, len(txResults)) + // We expect insufficient funds. + require.Equal(t, uint32(5), txResults[0].Code) +} + +// If tx is in a bundle, it should not be included from the mempool +func TestTransactionDuplicatesRemoved(t *testing.T) { + tm := time.Now().UTC() + valPub := secp256k1.GenPrivKey().PubKey() + testWrapper := app.NewTestWrapper(t, tm, valPub, false, true) + + tx1 := []byte{0x2, 0x1, 0x3, 0x7} + tx2 := []byte("magic_tx") + tx3 := []byte("useless bytes") + + // Create and submit bundle + height := int64(1) + bundle := &types.Bundle{ + Transactions: [][]byte{tx1, tx2, tx3}, + BlockHeight: uint64(height), + } + + res := testWrapper.App.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + + // Verify bundle was stored immediately after submission + queryRes := testWrapper.App.MevKeeper.PendingBundles(height) + require.Equal(t, 1, len(queryRes)) + require.Equal(t, bundle.Transactions, queryRes[0].Transactions) + + // Call PrepareProposal + prepareProposalReq := abci.RequestPrepareProposal{ + Txs: [][]byte{ + tx2, + }, + MaxTxBytes: 10000000, + Height: height, + Time: testWrapper.Ctx.BlockTime(), + } + + prepareProposalRes, err := testWrapper.App.PrepareProposal(sdk.WrapSDKContext(testWrapper.Ctx), &prepareProposalReq) + require.NoError(t, err) + require.NotNil(t, prepareProposalRes) + + t.Log("prepareProposalRes", prepareProposalRes) + + // Extract tx bytes from TxRecords + txBytes := [][]byte{} + for _, record := range prepareProposalRes.TxRecords { + txBytes = append(txBytes, record.Tx) + } + require.Len(t, prepareProposalRes.TxRecords, 3) +} diff --git a/app/app_test.go b/app/app_test.go index e9f9a98c40..bc484ba4a5 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -43,7 +43,7 @@ func TestEmptyBlockIdempotency(t *testing.T) { valPub := secp256k1.GenPrivKey().PubKey() for i := 1; i <= 10; i++ { - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) res, _ := testWrapper.App.FinalizeBlock(context.Background(), &abci.RequestFinalizeBlock{Height: 1}) testWrapper.App.Commit(context.Background()) data := res.AppHash @@ -125,7 +125,7 @@ func TestPartitionPrioritizedTxs(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) account := sdk.AccAddress(valPub.Address()).String() validator := sdk.ValAddress(valPub.Address()).String() @@ -207,7 +207,7 @@ func TestProcessOracleAndOtherTxsSuccess(t *testing.T) { valPub := secp256k1.GenPrivKey().PubKey() secondAcc := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) account := sdk.AccAddress(valPub.Address()).String() account2 := sdk.AccAddress(secondAcc.Address()).String() @@ -295,7 +295,7 @@ func TestInvalidProposalWithExcessiveGasWanted(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) ap := testWrapper.App ctx := testWrapper.Ctx.WithConsensusParams(&types.ConsensusParams{ Block: &types.BlockParams{MaxGas: 10}, @@ -412,7 +412,7 @@ func TestInvalidProposalWithExcessiveGasEstimates(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) ap := testWrapper.App ctx := testWrapper.Ctx.WithConsensusParams(&types.ConsensusParams{ Block: &types.BlockParams{ @@ -474,7 +474,7 @@ func TestOverflowGas(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) ap := testWrapper.App ctx := testWrapper.Ctx.WithConsensusParams(&types.ConsensusParams{ Block: &types.BlockParams{MaxGas: math.MaxInt64}, @@ -501,7 +501,7 @@ func TestDecodeTransactionsConcurrently(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) privKey := testkeeper.MockPrivateKey() testPrivHex := hex.EncodeToString(privKey.Bytes()) key, _ := crypto.HexToECDSA(testPrivHex) @@ -638,7 +638,7 @@ func TestGetDeliverTxEntry(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) ap := testWrapper.App ctx := testWrapper.Ctx.WithConsensusParams(&types.ConsensusParams{ Block: &types.BlockParams{MaxGas: 10}, diff --git a/app/invariance_test.go b/app/invariance_test.go index b40af6c451..025b357f28 100644 --- a/app/invariance_test.go +++ b/app/invariance_test.go @@ -139,7 +139,7 @@ func TestLightInvarianceChecks(t *testing.T) { }, } { fmt.Printf("Running test %d\n", i) - testWrapper := app.NewTestWrapperWithSc(t, tm, valPub, false) + testWrapper := app.NewTestWrapperWithSc(t, tm, valPub, false, false) a, ctx := testWrapper.App, testWrapper.Ctx for i := range tt.preUsei { if tt.preUsei[i] > 0 { diff --git a/app/test_helpers.go b/app/test_helpers.go index 53e21e1807..0da6af0195 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -69,15 +69,15 @@ type TestWrapper struct { Ctx sdk.Context } -func NewTestWrapper(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enableEVMCustomPrecompiles bool, baseAppOptions ...func(*baseapp.BaseApp)) *TestWrapper { - return newTestWrapper(t, tm, valPub, enableEVMCustomPrecompiles, false, baseAppOptions...) +func NewTestWrapper(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enableEVMCustomPrecompiles bool, enableMEV bool, baseAppOptions ...func(*baseapp.BaseApp)) *TestWrapper { + return newTestWrapper(t, tm, valPub, enableEVMCustomPrecompiles, enableMEV, false, baseAppOptions...) } -func NewTestWrapperWithSc(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enableEVMCustomPrecompiles bool, baseAppOptions ...func(*baseapp.BaseApp)) *TestWrapper { - return newTestWrapper(t, tm, valPub, enableEVMCustomPrecompiles, true, baseAppOptions...) +func NewTestWrapperWithSc(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enableEVMCustomPrecompiles bool, enableMEV bool, baseAppOptions ...func(*baseapp.BaseApp)) *TestWrapper { + return newTestWrapper(t, tm, valPub, enableEVMCustomPrecompiles, enableMEV, true, baseAppOptions...) } -func newTestWrapper(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enableEVMCustomPrecompiles bool, useSc bool, baseAppOptions ...func(*baseapp.BaseApp)) *TestWrapper { +func newTestWrapper(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enableEVMCustomPrecompiles bool, enableMEV bool, useSc bool, baseAppOptions ...func(*baseapp.BaseApp)) *TestWrapper { var appPtr *App if useSc { appPtr = SetupWithSc(false, enableEVMCustomPrecompiles, baseAppOptions...) @@ -91,6 +91,10 @@ func newTestWrapper(t *testing.T, tm time.Time, valPub crptotypes.PubKey, enable } wrapper.SetT(t) wrapper.setupValidator(stakingtypes.Unbonded, valPub) + + if enableMEV { + wrapper.App.mevConfig.Enabled = true + } return wrapper } diff --git a/app/upgrade_test.go b/app/upgrade_test.go index 1b1566c3ac..4da25bf676 100644 --- a/app/upgrade_test.go +++ b/app/upgrade_test.go @@ -16,7 +16,7 @@ import ( func TestUpgradesListIsSorted(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) testWrapper.App.RegisterUpgradeHandlers() } @@ -24,7 +24,7 @@ func TestUpgradesListIsSorted(t *testing.T) { func TestDistributionCommunityTaxParamMigration(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) testWrapper.App.RegisterUpgradeHandlers() params := testWrapper.App.DistrKeeper.GetParams(testWrapper.Ctx) testWrapper.Require().Equal(params.CommunityTax, sdk.NewDec(0)) @@ -36,7 +36,7 @@ func TestSkipOptimisticProcessingOnUpgrade(t *testing.T) { t.Run("Test optimistic processing is skipped on upgrade", func(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) // No optimistic processing with upgrade scheduled testCtx := testWrapper.App.BaseApp.NewContext(false, tmproto.Header{Height: 3, ChainID: "sei-test", Time: tm}) @@ -59,7 +59,7 @@ func TestSkipOptimisticProcessingOnUpgrade(t *testing.T) { t.Run("Test optimistic processing if no upgrade", func(t *testing.T) { tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) testCtx := testWrapper.App.BaseApp.NewContext(false, tmproto.Header{Height: 3, ChainID: "sei-test", Time: tm}) testWrapper.App.UpgradeKeeper.ScheduleUpgrade(testWrapper.Ctx, types.Plan{ diff --git a/cmd/seid/cmd/root.go b/cmd/seid/cmd/root.go index 07f9643b1e..78190a5931 100644 --- a/cmd/seid/cmd/root.go +++ b/cmd/seid/cmd/root.go @@ -10,6 +10,8 @@ import ( "path/filepath" "time" + "github.com/sei-protocol/sei-chain/mev" + "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/cosmos/cosmos-sdk/baseapp" @@ -428,6 +430,8 @@ func initAppConfig() (string, interface{}) { EvmQuery querier.Config `mapstructure:"evm_query"` LightInvariance app.LightInvarianceConfig `mapstructure:"light_invariance"` + + MEV mev.Config `mapstructure:"mev"` } // Optionally allow the chain developer to overwrite the SDK's default @@ -472,6 +476,7 @@ func initAppConfig() (string, interface{}) { ETHBlockTest: blocktest.DefaultConfig, EvmQuery: querier.DefaultConfig, LightInvariance: app.DefaultLightInvarianceConfig, + MEV: mev.DefaultConfig, } customAppTemplate := serverconfig.DefaultConfigTemplate + ` @@ -567,6 +572,9 @@ evm_query_gas_limit = {{ .EvmQuery.GasLimit }} [light_invariance] supply_enabled = {{ .LightInvariance.SupplyEnabled }} + +[mev] +enabled = "{{ .MEV.Enabled }}" ` return customAppTemplate, customAppConfig diff --git a/docker/docker-compose.mev.yml b/docker/docker-compose.mev.yml new file mode 100644 index 0000000000..e41ff6dc18 --- /dev/null +++ b/docker/docker-compose.mev.yml @@ -0,0 +1,41 @@ +# intended to be included on top of docker-compose.yml + +services: + silo-server: + platform: linux/amd64 + container_name: silo-server + image: "silo-server:latest" + ports: + - "22137:22137" + networks: + localnet: + ipv4_address: 192.168.10.9 + + node0: +# extends: +# service: node0 +# file: docker-compose.yml + environment: + MEV_SERVER_ADDR: silo-server:22138 + + node1: +# extends: +# service: node1 +# file: docker-compose.yml + environment: + MEV_SERVER_ADDR: silo-server:22138 + + node2: +# extends: +# service: node2 +# file: docker-compose.yml + environment: + MEV_SERVER_ADDR: silo-server:22138 + + node3: +# extends: +# service: node3 +# file: docker-compose.yml + environment: + MEV_SERVER_ADDR: silo-server:22138 + diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 7e197935d6..1ba9b96761 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,4 +1,5 @@ services: + node0: platform: linux/amd64 container_name: sei-node-0 @@ -21,8 +22,9 @@ services: - "${PROJECT_HOME}/../sei-cosmos:/sei-protocol/sei-cosmos:Z" - "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z" - "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z" - - "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z" + - "${GO_MOD_CACHE}:/root/go/pkg/mod:Z" - "${GOCACHE}:/root/.cache/go-build:Z" + - "${PROJECT_HOME}/../../sei-protocol/mev-demo/:/sei-protocol/mev/" networks: localnet: ipv4_address: 192.168.10.10 @@ -48,8 +50,9 @@ services: - "${PROJECT_HOME}/../sei-cosmos:/sei-protocol/sei-cosmos:Z" - "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z" - "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z" - - "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z" + - "${GO_MOD_CACHE}:/root/go/pkg/mod:Z" - "${GOCACHE}:/root/.cache/go-build:Z" + - "${PROJECT_HOME}/../../sei-protocol/mev-demo/:/sei-protocol/mev/" networks: localnet: ipv4_address: 192.168.10.11 @@ -75,8 +78,9 @@ services: - "${PROJECT_HOME}/../sei-cosmos:/sei-protocol/sei-cosmos:Z" - "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z" - "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z" - - "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z" + - "${GO_MOD_CACHE}:/root/go/pkg/mod:Z" - "${GOCACHE}:/root/.cache/go-build:Z" + - "${PROJECT_HOME}/../../sei-protocol/mev-demo/:/sei-protocol/mev/" networks: localnet: ipv4_address: 192.168.10.12 @@ -102,8 +106,9 @@ services: - "${PROJECT_HOME}/../sei-cosmos:/sei-protocol/sei-cosmos:Z" - "${PROJECT_HOME}/../sei-db:/sei-protocol/sei-db:Z" - "${PROJECT_HOME}/../go-ethereum:/sei-protocol/go-ethereum:Z" - - "${GO_PKG_PATH}/mod:/root/go/pkg/mod:Z" + - "${GO_MOD_CACHE}:/root/go/pkg/mod:Z" - "${GOCACHE}:/root/.cache/go-build:Z" + - "${PROJECT_HOME}/../../sei-protocol/mev-demo/:/sei-protocol/mev/" networks: localnet: ipv4_address: 192.168.10.13 diff --git a/docker/localnode/config/app.toml b/docker/localnode/config/app.toml index a11c0c2d84..0a4da29bc1 100644 --- a/docker/localnode/config/app.toml +++ b/docker/localnode/config/app.toml @@ -267,4 +267,10 @@ ss-import-num-workers = 1 [evm] # EnableTestAPI enables the EVM test API -enable_test_api = true \ No newline at end of file +enable_test_api = true + +[mev] +enabled = false +server_addr = "" + +insecure = true \ No newline at end of file diff --git a/docker/localnode/scripts/step1_configure_init.sh b/docker/localnode/scripts/step1_configure_init.sh index 6cbf4fb85b..cf01cecbac 100755 --- a/docker/localnode/scripts/step1_configure_init.sh +++ b/docker/localnode/scripts/step1_configure_init.sh @@ -66,4 +66,11 @@ echo "$PRIV_KEY" >> build/generated/exported_keys/"$SEIVALOPER_INFO".txt sed -i.bak -e "s|^address *=.*|address = \"$GENESIS_ACCOUNT_ADDRESS\"|" $ORACLE_CONFIG_FILE sed -i.bak -e "s|^validator *=.*|validator = \"$SEIVALOPER_INFO\"|" $ORACLE_CONFIG_FILE + +# Override MEV server address +echo "Setting MEV server address to $MEV_SERVER_ADDR" +sed -i'' -e 's/enabled = false/enabled = true/g' "$APP_CONFIG_FILE" +sed -i'' -e 's/server_addr = ""/server_addr = "'"$MEV_SERVER_ADDR"'"/g' "$APP_CONFIG_FILE" + + echo "DONE" >> build/generated/init.complete diff --git a/go.mod b/go.mod index 02bd7b2536..e5965095df 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( github.com/BurntSushi/toml v1.3.2 github.com/CosmWasm/wasmd v0.27.0 github.com/CosmWasm/wasmvm v1.5.4 + github.com/SiloMEV/silo-mev-protobuf-go v0.0.3 github.com/armon/go-metrics v0.4.1 github.com/btcsuite/btcd v0.22.1 github.com/coinbase/kryptology v1.8.0 @@ -47,8 +48,8 @@ require ( golang.org/x/sync v0.9.0 golang.org/x/time v0.3.0 google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 - google.golang.org/grpc v1.68.0 - google.golang.org/protobuf v1.35.2 + google.golang.org/grpc v1.69.2 + google.golang.org/protobuf v1.36.2 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -321,12 +322,12 @@ require ( go.opencensus.io v0.23.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.9.0 // indirect go.opentelemetry.io/otel/sdk v1.9.0 // indirect - golang.org/x/crypto v0.27.0 // indirect + golang.org/x/crypto v0.28.0 // indirect golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/term v0.24.0 // indirect + golang.org/x/net v0.30.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/term v0.25.0 // indirect golang.org/x/text v0.20.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect @@ -365,7 +366,7 @@ replace ( github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.48 // Latest goleveldb is broken, we have to stick to this version github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 - github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.5.4 + github.com/tendermint/tendermint => github.com/SiloMEV/sei-tendermint-prepare-fixed v0.0.0-20250410225018-6ec0a8f12b59 github.com/tendermint/tm-db => github.com/sei-protocol/tm-db v0.0.4 google.golang.org/grpc => google.golang.org/grpc v1.33.2 ) diff --git a/go.sum b/go.sum index eaf28e8deb..8d26687093 100644 --- a/go.sum +++ b/go.sum @@ -127,6 +127,10 @@ github.com/OpenPeeDeeP/depguard v1.1.0/go.mod h1:JtAMzWkmFEzDPyAd+W0NHl1lvpQKTvT github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= +github.com/SiloMEV/sei-tendermint-prepare-fixed v0.0.0-20250410225018-6ec0a8f12b59 h1:a5A98cJF8hYSm8pi2HbAoOe8D/971ioqgahnYzXLE7E= +github.com/SiloMEV/sei-tendermint-prepare-fixed v0.0.0-20250410225018-6ec0a8f12b59/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4= +github.com/SiloMEV/silo-mev-protobuf-go v0.0.3 h1:4AaW6GIoisvA50Y4wYkri0f/Wu7SG9NHAu9+fGikdxQ= +github.com/SiloMEV/silo-mev-protobuf-go v0.0.3/go.mod h1:i6u6A6gne3TRJOqGvkJksK45DsZoK1q5+e2nw4RQ9Z8= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= @@ -1368,8 +1372,6 @@ github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8D github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= github.com/sei-protocol/sei-ibc-go/v3 v3.3.6 h1:HHWvrslBpkXBHUFs+azwl36NuFEJyMo6huvsNPG854c= github.com/sei-protocol/sei-ibc-go/v3 v3.3.6/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= -github.com/sei-protocol/sei-tendermint v0.5.4 h1:4yHUb83jQHfZn5hjfB5XcSgGQJkhl4QZYdVMGXkFp5o= -github.com/sei-protocol/sei-tendermint v0.5.4/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4= 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.3.0 h1:IJabKisvmsstAPsVAk37HxVyQwAe36g1CNYM/QcPisc= @@ -1664,8 +1666,8 @@ golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1805,8 +1807,8 @@ golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1973,8 +1975,8 @@ golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1987,8 +1989,8 @@ golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2293,8 +2295,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= -google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU= +google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/integration_test/mev_module/README.md b/integration_test/mev_module/README.md new file mode 100644 index 0000000000..cb871ba773 --- /dev/null +++ b/integration_test/mev_module/README.md @@ -0,0 +1,2 @@ +This tests uses MEV server, and requires to work with MEV enabled cluster, by using `make docker-mev-cluster-start` +Running cluster with MEV required silo-server docker image already built. Please see it's repo for instructions diff --git a/integration_test/mev_module/mev_test.yaml b/integration_test/mev_module/mev_test.yaml new file mode 100644 index 0000000000..935697a790 --- /dev/null +++ b/integration_test/mev_module/mev_test.yaml @@ -0,0 +1,41 @@ +- name: MEV Submission and inclusion + inputs: + - name: Latest block height + cmd: echo $(( $(seid status | jq -r .SyncInfo.latest_block_height) + 5)) + env: BLOCK_HEIGHT + - name: Submit Bundles + node: silo-server + cmd: | + grpcurl -plaintext -d "{\"height\": $BLOCK_HEIGHT, \"txs\": [{\"data\":\"a29rbw==\"}, {\"data\":\"Y3dpcg==\"}]}" localhost:22137 server.Server.Submit | + grpcurl -plaintext -d "{\"height\": $BLOCK_HEIGHT, \"txs\": [{\"data\":\"a3Vya2k=\"}, {\"data\":\"ZHppdXJraQ==\"}]}" localhost:22137 server.Server.Submit + - name: Wait + cmd: sleep 6 + - name: Get tx on node0 + node: sei-node-0 + cmd: seid query block $BLOCK_HEIGHT | jq ".block.data.txs | any(index(\"a29rbw==\"))" + env: NODE_0_TX + - name: Get tx on node1 + node: sei-node-1 + cmd: seid query block $BLOCK_HEIGHT | jq ".block.data.txs | any(index(\"Y3dpcg==\"))" + env: NODE_1_TX + - name: Get tx on node2 + node: sei-node-2 + cmd: seid query block $BLOCK_HEIGHT | jq ".block.data.txs | any(index(\"a3Vya2k=\"))" + env: NODE_2_TX + - name: Get tx on node3 + node: sei-node-3 + cmd: seid query block $BLOCK_HEIGHT | jq ".block.data.txs | any(index(\"ZHppdXJraQ==\"))" + env: NODE_3_TX + + + verifiers: +# # Add comments for what should the expected result + - type: eval + expr: NODE_0_TX == "true" + - type: eval + expr: NODE_1_TX == "true" + - type: eval + expr: NODE_2_TX == "true" + - type: eval + expr: NODE_3_TX == "true" + diff --git a/mev/config.go b/mev/config.go new file mode 100644 index 0000000000..0d1f034f35 --- /dev/null +++ b/mev/config.go @@ -0,0 +1,66 @@ +package mev + +import ( + "time" + + servertypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/spf13/cast" +) + +type Config struct { + Enabled bool + ServerAddr string + PollInterval time.Duration + CertFile string + Insecure bool +} + +const ( + flagEnabled = "mev.enabled" + flagServerAddr = "mev.server_addr" + flagPollInterval = "mev.poll_interval" + flagCertFile = "mev.cert_file" + flagInsecure = "mev.insecure" +) + +var DefaultConfig = Config{ + Enabled: false, + ServerAddr: "", + PollInterval: 200 * time.Millisecond, + CertFile: "", + Insecure: false, +} + +func ReadConfig(opts servertypes.AppOptions) (Config, error) { + cfg := DefaultConfig // copy + var err error + if v := opts.Get(flagEnabled); v != nil { + if cfg.Enabled, err = cast.ToBoolE(v); err != nil { + return cfg, err + } + } + if !cfg.Enabled { + return cfg, nil + } + if v := opts.Get(flagServerAddr); v != nil { + if cfg.ServerAddr, err = cast.ToStringE(v); err != nil { + return cfg, err + } + } + if v := opts.Get(flagPollInterval); v != nil { + if cfg.PollInterval, err = cast.ToDurationE(v); err != nil { + return cfg, err + } + } + if v := opts.Get(flagCertFile); v != nil { + if cfg.CertFile, err = cast.ToStringE(v); err != nil { + return cfg, err + } + } + if v := opts.Get(flagInsecure); v != nil { + if cfg.Insecure, err = cast.ToBoolE(v); err != nil { + return cfg, err + } + } + return cfg, nil +} diff --git a/mev/grpc_query.go b/mev/grpc_query.go new file mode 100644 index 0000000000..24f1ca7c0d --- /dev/null +++ b/mev/grpc_query.go @@ -0,0 +1 @@ +package mev diff --git a/mev/keeper.go b/mev/keeper.go new file mode 100644 index 0000000000..a1c9d6efc9 --- /dev/null +++ b/mev/keeper.go @@ -0,0 +1,78 @@ +package mev + +import ( + "math" + "sync" + + types "github.com/SiloMEV/silo-mev-protobuf-go/mev/v1" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const minHeightNotSet = math.MaxInt64 + +type Keeper struct { + cdc codec.BinaryCodec + ephemeralMu sync.RWMutex + + // Bundles are always ordered by value + // block height -> []bundle + ephemeral map[int64][]*types.Bundle + + // minHeight is the lowest block height key currently stored in the ephemeral map + // helps to limit puring since map is not ordered + minHeight int64 +} + +func NewKeeper( + cdc codec.BinaryCodec, + _ sdk.StoreKey, // keep parameter to maintain compatibility but don't use it +) *Keeper { + return &Keeper{ + cdc: cdc, + ephemeral: make(map[int64][]*types.Bundle), + minHeight: minHeightNotSet, + } +} + +func (k *Keeper) SetBundles(height int64, bundles []*types.Bundle) bool { + k.ephemeralMu.Lock() + defer k.ephemeralMu.Unlock() + + k.ephemeral[height] = bundles + + if height < k.minHeight { + k.minHeight = height + } + + return true +} + +func (k *Keeper) PendingBundles(height int64) []*types.Bundle { + k.ephemeralMu.RLock() + defer k.ephemeralMu.RUnlock() + + return k.ephemeral[height] +} + +func (k *Keeper) DropBundlesAtAndBelow(height int64) { + k.ephemeralMu.Lock() + defer k.ephemeralMu.Unlock() + + if k.minHeight == minHeightNotSet { + // no bundles at all + return + } + + for i := height; i >= k.minHeight; i-- { + delete(k.ephemeral, i) + } + + if len(k.ephemeral) == 0 { + k.minHeight = minHeightNotSet + } else { + k.minHeight = height + } + +} diff --git a/mev/keeper_test.go b/mev/keeper_test.go new file mode 100644 index 0000000000..5d96ed3dc7 --- /dev/null +++ b/mev/keeper_test.go @@ -0,0 +1,135 @@ +package mev_test + +import ( + types "github.com/SiloMEV/silo-mev-protobuf-go/mev/v1" + "testing" + "time" + + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/sei-protocol/sei-chain/app" +) + +func setupKeeper(t *testing.T) (*app.App, tmproto.Header) { + app := app.Setup(false, false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + return app, ctx.BlockHeader() +} + +func TestKeeper_SubmitAndQueryBundles(t *testing.T) { + app, _ := setupKeeper(t) + + height := int64(100) + + // Submit a bundle + bundle := &types.Bundle{ + Transactions: [][]byte{[]byte("tx1"), []byte("tx2")}, + BlockHeight: uint64(height), + } + + res := app.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + + // Query bundles + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 1) + require.Equal(t, bundle.Transactions[0], pending[0].Transactions[0]) +} + +func TestKeeper_BundlesSetting(t *testing.T) { + app, _ := setupKeeper(t) + + height := int64(100) + + // Submit a bundle + bundle := &types.Bundle{ + Transactions: [][]byte{[]byte("tx1"), []byte("tx2")}, + BlockHeight: uint64(height), + } + + res := app.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + + // Query bundles + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 1) + require.Equal(t, bundle.Transactions[0], pending[0].Transactions[0]) + + //set new bundles for a height + newBundleTx := []byte("tx3") + bundle.Transactions = [][]byte{newBundleTx} + res = app.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + + pending = app.MevKeeper.PendingBundles(height) + require.Equal(t, 1, len(pending)) + require.Equal(t, bundle.Transactions[0], pending[0].Transactions[0]) +} + +func TestKeeper_BundlesPurging(t *testing.T) { + app, _ := setupKeeper(t) + + height := int64(100) + + // empty keeper drops bundles just fine + app.MevKeeper.DropBundlesAtAndBelow(height) + + app.MevKeeper.PendingBundles(height) + require.Equal(t, 0, len(app.MevKeeper.PendingBundles(height))) + + // Submit a bundle + bundle := &types.Bundle{ + Transactions: [][]byte{[]byte("tx1"), []byte("tx2")}, + BlockHeight: uint64(height), + } + + res := app.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + + // Query bundles + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 1) + + // Drop and check if gone + app.MevKeeper.DropBundlesAtAndBelow(height) + require.Equal(t, 0, len(app.MevKeeper.PendingBundles(height))) + + // add series of bundles + for height := int64(100); height < 1000; height += 23 { + bundle := &types.Bundle{ + Transactions: [][]byte{[]byte("tx1"), []byte("tx2")}, + BlockHeight: uint64(height), + } + + res := app.MevKeeper.SetBundles(height, []*types.Bundle{bundle}) + require.True(t, res) + } + + // check series of bundles + for height := int64(100); height < 1000; height += 23 { + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 1) + } + + app.MevKeeper.DropBundlesAtAndBelow(500) + + // check everything below 500 is gone, but above is up + for height := int64(100); height < 500; height += 23 { + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 0) + } + // first bundle above 500 is at 514 + for height := int64(514); height < 1000; height += 23 { + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 1) + } + + app.MevKeeper.DropBundlesAtAndBelow(1000) + + // now everything is gone + for height := int64(100); height < 1000; height += 23 { + pending := app.MevKeeper.PendingBundles(height) + require.Len(t, pending, 0) + } +} diff --git a/mev/poll.go b/mev/poll.go new file mode 100644 index 0000000000..708b9b88b0 --- /dev/null +++ b/mev/poll.go @@ -0,0 +1,88 @@ +package mev + +import ( + "context" + "fmt" + "time" + + "google.golang.org/grpc/credentials" + + types "github.com/SiloMEV/silo-mev-protobuf-go/mev/v1" + "github.com/tendermint/tendermint/libs/log" + "google.golang.org/grpc" +) + +type Poller struct { + client types.BundleProviderClient + keeper *Keeper + lastBlockProvider func() int64 + logger log.Logger + ctx context.Context +} + +func (p *Poller) run() { + + lastHeight := p.lastBlockProvider() + + bundles, err := p.client.GetBundles(context.Background(), &types.GetBundlesRequest{MinBlockHeight: uint64(lastHeight)}) + if err != nil { + p.logger.Error("Error while querying bundle server", "err", err) + return + } + for height, bundles := range bundles.Bundles { + p.keeper.SetBundles(int64(height), bundles.Bundles) + } + + p.keeper.DropBundlesAtAndBelow(lastHeight - 1) +} + +func NewPoller(ctx context.Context, logger log.Logger, config Config, keeper *Keeper, lastBlockProvider func() int64) (*Poller, error) { + + logger.Info("Starting bundle provider poller") + + if config.CertFile == "" && !config.Insecure { + return nil, fmt.Errorf("either certFile or insecure must be set") + } + + var option grpc.DialOption + + if config.CertFile != "" { + creds, err := credentials.NewClientTLSFromFile(config.CertFile, "") + if err != nil { + return nil, fmt.Errorf("error while loading TLS certificate: %w", err) + } + option = grpc.WithTransportCredentials(creds) + } else { + option = grpc.WithInsecure() + } + + grpcConn, err := grpc.DialContext(ctx, config.ServerAddr, option) + if err != nil { + return nil, err + } + + bundleProviderClient := types.NewBundleProviderClient(grpcConn) + + p := &Poller{ + client: bundleProviderClient, + keeper: keeper, + lastBlockProvider: lastBlockProvider, + logger: logger, + ctx: ctx, + } + + ticker := time.NewTicker(config.PollInterval) + + go func() { + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + p.run() + } + } + }() + + return p, nil +} diff --git a/occ_tests/utils/utils.go b/occ_tests/utils/utils.go index ea42d2fde5..b6e73bb559 100644 --- a/occ_tests/utils/utils.go +++ b/occ_tests/utils/utils.go @@ -119,7 +119,7 @@ func addressToValAddress(addr sdk.AccAddress) sdk.ValAddress { // NewTestContext initializes a new TestContext with a new app and a new contract func NewTestContext(t *testing.T, testAccts []TestAcct, blockTime time.Time, workers int, occEnabled bool) *TestContext { contractFile := "../integration_test/contracts/mars.wasm" - wrapper := app.NewTestWrapper(t, blockTime, testAccts[0].PublicKey, false, func(ba *baseapp.BaseApp) { + wrapper := app.NewTestWrapper(t, blockTime, testAccts[0].PublicKey, false, false, func(ba *baseapp.BaseApp) { ba.SetOccEnabled(occEnabled) ba.SetConcurrencyWorkers(workers) }) diff --git a/proto/README.md b/proto/README.md index ade27c1f9d..004fe1b5b7 100644 --- a/proto/README.md +++ b/proto/README.md @@ -1,5 +1,17 @@ # Code generation +## Notes: 1/16/2025 + +To run the repo you need to use go 1.21, but to compile the proto files you need to use go 1.23. This means you need to use gvm to switch between the two versions and then modify the go.mod file to use the correct version. + +Here is the command to do this and then switch back to 1.21 and run the tests: + +``` +git ls-files -m '*.pb.go' '*.pb.gw.go' | xargs git checkout -- && git checkout -- go.mod && git checkout -- go.sum && gvm use go1.23 && sed -i '' 's/^go 1\.21$/go 1.23/' go.mod && ignite generate proto-go -y && gvm use go1.21 && git checkout -- go.mod && git checkout -- go.sum && make install && go test ./... +``` + +## Remaining notes: + To generate the code for the protobuf files, first install the `ignite` tool. We need version v0.23.0, which is outdated, but works with the current version of the codebase. Pull binaries from the [releases page](https://github.com/ignite/cli/releases/tag/v0.23.0) or install from source code diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml index 4e8fb72d63..85fd1f80e3 100644 --- a/proto/buf.gen.gogo.yaml +++ b/proto/buf.gen.gogo.yaml @@ -2,7 +2,7 @@ version: v1 plugins: - name: gocosmos out: .. - opt: plugins=grpc,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1alpha1/orm.proto=github.com/cosmos/cosmos-sdk/api/cosmos/orm/v1alpha1 + opt: plugins=grpc,Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,Mcosmos/orm/v1alpha1/orm.proto=github.com/cosmos/cosmos-sdk/api/cosmos/orm/v1alpha1,goproto_stringer=true - name: grpc-gateway out: .. opt: logtostderr=true,allow_colon_final_segments=true diff --git a/proto/evm/params.proto b/proto/evm/params.proto index fb5067ccdc..81a7900bd6 100644 --- a/proto/evm/params.proto +++ b/proto/evm/params.proto @@ -71,7 +71,7 @@ string minimum_fee_per_gas = 4 [ } message ParamsPreV580 { - option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_stringer) = true; // string base_denom = 1 [ // (gogoproto.moretags) = "yaml:\"base_denom\"", diff --git a/proto/mev/x/genesis.proto b/proto/mev/x/genesis.proto new file mode 100644 index 0000000000..90312170b3 --- /dev/null +++ b/proto/mev/x/genesis.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package seiprotocol.seichain.mev; + +import "gogoproto/gogo.proto"; +import "mev/x/params.proto"; + +option go_package = "github.com/sei-protocol/sei-chain/x/mev/types"; + +// GenesisState defines the mev module's genesis state. +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Params params = 1 [(gogoproto.nullable) = false]; +} \ No newline at end of file diff --git a/proto/mev/x/params.proto b/proto/mev/x/params.proto new file mode 100644 index 0000000000..514983ebbd --- /dev/null +++ b/proto/mev/x/params.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; +package seiprotocol.seichain.mev; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/sei-protocol/sei-chain/x/mev/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = true; +} diff --git a/proto/mev/x/query.proto b/proto/mev/x/query.proto new file mode 100644 index 0000000000..a44be02145 --- /dev/null +++ b/proto/mev/x/query.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package seiprotocol.seichain.mev; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "mev/x/params.proto"; + +option go_package = "github.com/sei-protocol/sei-chain/x/mev/types"; + + +// empty, as there are no on-chain Queries for MEV yet + +service Query { + +} diff --git a/proto/mev/x/tx.proto b/proto/mev/x/tx.proto new file mode 100644 index 0000000000..39b4227ba7 --- /dev/null +++ b/proto/mev/x/tx.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package seiprotocol.seichain.mev; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/sei-protocol/sei-chain/x/mev/types"; + +// empty, as there are no Tendermint-aware transactions for MEV, but it's likely this will be used + +service Msg { + +} + diff --git a/readme.md b/readme.md index 29dd6b34b8..57b3fb6389 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# Sei +# Sei with MEV by MEVVY! Step 2! ![Banner!](assets/SeiLogo.png) diff --git a/wasmbinding/test/query_test.go b/wasmbinding/test/query_test.go index a5757999f9..2d89c27635 100644 --- a/wasmbinding/test/query_test.go +++ b/wasmbinding/test/query_test.go @@ -30,7 +30,7 @@ func SetupWasmbindingTest(t *testing.T) (*app.TestWrapper, func(ctx sdk.Context, tm := time.Now().UTC() valPub := secp256k1.GenPrivKey().PubKey() - testWrapper := app.NewTestWrapper(t, tm, valPub, false) + testWrapper := app.NewTestWrapper(t, tm, valPub, false, false) oh := oraclewasm.NewOracleWasmQueryHandler(&testWrapper.App.OracleKeeper) eh := epochwasm.NewEpochWasmQueryHandler(&testWrapper.App.EpochKeeper) diff --git a/x/evm/types/params.pb.go b/x/evm/types/params.pb.go index ee867aa226..7f5cbf9674 100644 --- a/x/evm/types/params.pb.go +++ b/x/evm/types/params.pb.go @@ -105,8 +105,77 @@ func (m *Params) GetTargetGasUsedPerBlock() uint64 { return 0 } +type ParamsPreV580 struct { + // string base_denom = 1 [ + // + // (gogoproto.moretags) = "yaml:\"base_denom\"", + // (gogoproto.jsontag) = "base_denom" + // + // ]; + PriorityNormalizer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=priority_normalizer,json=priorityNormalizer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"priority_normalizer" yaml:"priority_normalizer"` + BaseFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base_fee_per_gas,json=baseFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_fee_per_gas" yaml:"base_fee_per_gas"` + MinimumFeePerGas github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=minimum_fee_per_gas,json=minimumFeePerGas,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_fee_per_gas" yaml:"minimum_fee_per_gas"` + // ChainConfig chain_config = 5 [(gogoproto.moretags) = "yaml:\"chain_config\"", (gogoproto.nullable) = false]; + // + // string chain_id = 6 [ + // (gogoproto.moretags) = "yaml:\"chain_id\"", + // (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + // (gogoproto.nullable) = false, + // (gogoproto.jsontag) = "chain_id" + // + // ]; + // repeated string whitelisted_codehashes_bank_send = 7 [ + // + // (gogoproto.moretags) = "yaml:\"whitelisted_codehashes_bank_send\"", + // (gogoproto.jsontag) = "whitelisted_codehashes_bank_send" + // + // ]; + WhitelistedCwCodeHashesForDelegateCall [][]byte `protobuf:"bytes,8,rep,name=whitelisted_cw_code_hashes_for_delegate_call,json=whitelistedCwCodeHashesForDelegateCall,proto3" json:"whitelisted_cw_code_hashes_for_delegate_call" yaml:"whitelisted_cw_code_hashes_for_delegate_call"` +} + +func (m *ParamsPreV580) Reset() { *m = ParamsPreV580{} } +func (m *ParamsPreV580) String() string { return proto.CompactTextString(m) } +func (*ParamsPreV580) ProtoMessage() {} +func (*ParamsPreV580) Descriptor() ([]byte, []int) { + return fileDescriptor_9272f3679901ea94, []int{1} +} +func (m *ParamsPreV580) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsPreV580) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsPreV580.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParamsPreV580) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsPreV580.Merge(m, src) +} +func (m *ParamsPreV580) XXX_Size() int { + return m.Size() +} +func (m *ParamsPreV580) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsPreV580.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsPreV580 proto.InternalMessageInfo + +func (m *ParamsPreV580) GetWhitelistedCwCodeHashesForDelegateCall() [][]byte { + if m != nil { + return m.WhitelistedCwCodeHashesForDelegateCall + } + return nil +} + func init() { proto.RegisterType((*Params)(nil), "seiprotocol.seichain.evm.Params") + proto.RegisterType((*ParamsPreV580)(nil), "seiprotocol.seichain.evm.ParamsPreV580") } func init() { proto.RegisterFile("evm/params.proto", fileDescriptor_9272f3679901ea94) } @@ -150,11 +219,11 @@ var fileDescriptor_9272f3679901ea94 = []byte{ 0x41, 0x94, 0x52, 0x67, 0xa6, 0x50, 0xd2, 0x1d, 0x53, 0xe8, 0xe2, 0xad, 0x15, 0x3a, 0x1e, 0x6c, 0x44, 0xa1, 0xe3, 0xce, 0x54, 0xa1, 0x99, 0x75, 0xa8, 0xd0, 0xad, 0xd9, 0x4f, 0x9f, 0x9d, 0x9c, 0x7b, 0xf4, 0x37, 0x5a, 0xcc, 0xe6, 0x6c, 0x55, 0xc0, 0xf3, 0xc7, 0x9b, 0x8f, 0xee, 0xc6, 0xed, - 0xdd, 0xb8, 0xfd, 0x63, 0xe3, 0x36, 0xbb, 0x94, 0xa5, 0xca, 0xf1, 0xa9, 0x6d, 0x9c, 0x9c, 0xda, - 0xc6, 0x8f, 0x53, 0xdb, 0xf8, 0x70, 0x66, 0xe7, 0x4e, 0xce, 0xec, 0xdc, 0xd7, 0x33, 0x3b, 0xf7, - 0xb2, 0x30, 0x52, 0x56, 0x09, 0xb4, 0x70, 0xf9, 0xa4, 0xd0, 0x3f, 0xfa, 0x4d, 0xe1, 0x75, 0xbd, - 0xf4, 0xf1, 0xa1, 0x2b, 0x5c, 0x9b, 0xd3, 0xfe, 0x8d, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x19, - 0x33, 0xf5, 0x29, 0x90, 0x08, 0x00, 0x00, + 0xdd, 0xb8, 0xfd, 0x63, 0xe3, 0x56, 0x5f, 0x4a, 0xa3, 0x54, 0x39, 0x3e, 0xb5, 0x8d, 0x93, 0x53, + 0xdb, 0xf8, 0x71, 0x6a, 0x1b, 0x1f, 0xce, 0xec, 0xdc, 0xc9, 0x99, 0x9d, 0xfb, 0x7a, 0x66, 0xe7, + 0x5e, 0x16, 0x46, 0xca, 0x2a, 0x81, 0x16, 0x2e, 0x9f, 0x14, 0xfa, 0x47, 0xbf, 0x29, 0xbc, 0xae, + 0x97, 0x3e, 0x3e, 0x74, 0x85, 0x6b, 0x73, 0xda, 0xbf, 0xf1, 0x33, 0x00, 0x00, 0xff, 0xff, 0x5c, + 0xd2, 0x94, 0xe0, 0x90, 0x08, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -259,6 +328,68 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ParamsPreV580) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParamsPreV580) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsPreV580) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { + for iNdEx := len(m.WhitelistedCwCodeHashesForDelegateCall) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) + copy(dAtA[i:], m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.WhitelistedCwCodeHashesForDelegateCall[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + { + size := m.MinimumFeePerGas.Size() + i -= size + if _, err := m.MinimumFeePerGas.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.BaseFeePerGas.Size() + i -= size + if _, err := m.BaseFeePerGas.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.PriorityNormalizer.Size() + i -= size + if _, err := m.PriorityNormalizer.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -303,6 +434,27 @@ func (m *Params) Size() (n int) { return n } +func (m *ParamsPreV580) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PriorityNormalizer.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.BaseFeePerGas.Size() + n += 1 + l + sovParams(uint64(l)) + l = m.MinimumFeePerGas.Size() + n += 1 + l + sovParams(uint64(l)) + if len(m.WhitelistedCwCodeHashesForDelegateCall) > 0 { + for _, b := range m.WhitelistedCwCodeHashesForDelegateCall { + l = len(b) + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -633,6 +785,190 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } +func (m *ParamsPreV580) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParamsPreV580: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsPreV580: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PriorityNormalizer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PriorityNormalizer.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseFeePerGas", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BaseFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinimumFeePerGas", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinimumFeePerGas.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WhitelistedCwCodeHashesForDelegateCall", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WhitelistedCwCodeHashesForDelegateCall = append(m.WhitelistedCwCodeHashesForDelegateCall, make([]byte, postIndex-iNdEx)) + copy(m.WhitelistedCwCodeHashesForDelegateCall[len(m.WhitelistedCwCodeHashesForDelegateCall)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/mev/client/cli/query.go b/x/mev/client/cli/query.go new file mode 100644 index 0000000000..90f3a71323 --- /dev/null +++ b/x/mev/client/cli/query.go @@ -0,0 +1,3 @@ +package cli + +//empty for future on-chain MEV commands diff --git a/x/mev/client/cli/tx.go b/x/mev/client/cli/tx.go new file mode 100644 index 0000000000..90f3a71323 --- /dev/null +++ b/x/mev/client/cli/tx.go @@ -0,0 +1,3 @@ +package cli + +//empty for future on-chain MEV commands diff --git a/x/mev/module.go b/x/mev/module.go new file mode 100644 index 0000000000..ba65ce74c6 --- /dev/null +++ b/x/mev/module.go @@ -0,0 +1,187 @@ +package mev + +import ( + "encoding/json" + "fmt" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/sei-protocol/sei-chain/mev" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/sei-protocol/sei-chain/x/mev/types" + abci "github.com/tendermint/tendermint/abci/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the basic application module used by the mev module. +type AppModuleBasic struct { + cdc codec.Codec +} + +func NewAppModuleBasic(cdc codec.Codec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the mev module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the mev module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the mev module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the mev module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return data.Validate() +} + +// ValidateGenesisStream performs genesis state validation for the mev module in a streaming fashion. +func (am AppModuleBasic) ValidateGenesisStream(cdc codec.JSONCodec, config client.TxEncodingConfig, genesisCh <-chan json.RawMessage) error { + for genesis := range genesisCh { + err := am.ValidateGenesis(cdc, config, genesis) + if err != nil { + return err + } + } + return nil +} + +// RegisterRESTRoutes registers the REST routes for the mev module. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mev module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + // Register your routes here if needed + + //_ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewMsgClient(clientCtx)) + +} + +// GetTxCmd returns the root tx command for the mev module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return nil + //return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the mev module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return nil + //return cli.GetQueryCmd() +} + +type AppModule struct { + AppModuleBasic + keeper *mev.Keeper +} + +func NewAppModule(cdc codec.Codec, k *mev.Keeper) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: k, + } +} + +// Name returns the mev module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the mev module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +func NewHandler(k *mev.Keeper) sdk.Handler { + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + + switch msg := msg.(type) { + //supported types here + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} + +// Route returns the message routing key for the mev module. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the mev module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// LegacyQuerierHandler returns the mev module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return nil +} + +// InitGenesis performs genesis initialization for the mev module. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + return nil +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mev module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ExportGenesisStream returns the mev module's exported genesis state as raw JSON bytes in a streaming fashion. +func (am AppModule) ExportGenesisStream(ctx sdk.Context, cdc codec.JSONCodec) <-chan json.RawMessage { + ch := make(chan json.RawMessage) + go func() { + ch <- am.ExportGenesis(ctx, cdc) + close(ch) + }() + return ch +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock returns the begin blocker for the mev module. +func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock returns the end blocker for the mev module. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + // Register services here when needed + // For now, we'll just register a basic migration like other modules + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + _ = cfg.RegisterMigration(types.ModuleName, 1, func(ctx sdk.Context) error { + return nil + }) +} diff --git a/x/mev/module_test.go b/x/mev/module_test.go new file mode 100644 index 0000000000..6bae521647 --- /dev/null +++ b/x/mev/module_test.go @@ -0,0 +1,41 @@ +package mev_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/sei-protocol/sei-chain/app" + "github.com/sei-protocol/sei-chain/x/mev" + "github.com/sei-protocol/sei-chain/x/mev/types" +) + +func TestBasicModule(t *testing.T) { + app := app.Setup(false, false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + module := mev.NewAppModule( + app.AppCodec(), + app.MevKeeper, + ) + + // Test basic module properties + require.Equal(t, types.ModuleName, module.Name()) + require.NotNil(t, module) + + // Test BeginBlock and EndBlock + module.BeginBlock(ctx, abci.RequestBeginBlock{}) + require.Equal(t, []abci.ValidatorUpdate{}, module.EndBlock(ctx, abci.RequestEndBlock{})) +} + +func TestModuleRegistration(t *testing.T) { + app := app.Setup(false, false) + + // Verify the module is properly registered in the app + require.NotNil(t, app.MevKeeper) + + // Test module name matches + require.Equal(t, types.ModuleName, types.ModuleName) +} diff --git a/x/mev/readme.md b/x/mev/readme.md new file mode 100644 index 0000000000..0c520261ff --- /dev/null +++ b/x/mev/readme.md @@ -0,0 +1,6 @@ +# Mev Module! + +This allows users to submit bundles of transactions to the chain. + + + diff --git a/x/mev/types/codec.go b/x/mev/types/codec.go new file mode 100644 index 0000000000..10ff057f28 --- /dev/null +++ b/x/mev/types/codec.go @@ -0,0 +1,18 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + //cdc.RegisterConcrete(&MsgSubmitBundle{}, "mev/SubmitBundle", nil) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterCodec(amino) +} diff --git a/x/mev/types/genesis.go b/x/mev/types/genesis.go new file mode 100644 index 0000000000..49fe06bd5d --- /dev/null +++ b/x/mev/types/genesis.go @@ -0,0 +1,13 @@ +package types + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + Params: DefaultParams(), + } +} + +// Validate performs basic genesis state validation +func (gs GenesisState) Validate() error { + return gs.Params.Validate() +} diff --git a/x/mev/types/genesis.pb.go b/x/mev/types/genesis.pb.go new file mode 100644 index 0000000000..f006fb13a8 --- /dev/null +++ b/x/mev/types/genesis.pb.go @@ -0,0 +1,315 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mev/x/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the mev module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_d5a006ef7688c01a, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "seiprotocol.seichain.mev.GenesisState") +} + +func init() { proto.RegisterFile("mev/x/genesis.proto", fileDescriptor_d5a006ef7688c01a) } + +var fileDescriptor_d5a006ef7688c01a = []byte{ + // 210 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xce, 0x4d, 0x2d, 0xd3, + 0xaf, 0xd0, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, + 0x92, 0x28, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, + 0x33, 0xf3, 0xf4, 0x72, 0x53, 0xcb, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, + 0x16, 0x44, 0xbd, 0x94, 0x10, 0xc4, 0x90, 0x82, 0xc4, 0xa2, 0xc4, 0x5c, 0xa8, 0x19, 0x4a, 0x11, + 0x5c, 0x3c, 0xee, 0x10, 0x43, 0x83, 0x4b, 0x12, 0x4b, 0x52, 0x85, 0xec, 0xb8, 0xd8, 0x20, 0xf2, + 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x0a, 0x7a, 0xb8, 0x2c, 0xd1, 0x0b, 0x00, 0xab, 0x73, + 0x62, 0x39, 0x71, 0x4f, 0x9e, 0x21, 0x08, 0xaa, 0xcb, 0x8a, 0xa3, 0x63, 0x81, 0x3c, 0xc3, 0x8b, + 0x05, 0xf2, 0x0c, 0x4e, 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, + 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, + 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x5f, 0x9c, 0x9a, 0xa9, 0x0b, + 0x33, 0x1e, 0xcc, 0x01, 0x9b, 0xaf, 0x5f, 0xa1, 0x0f, 0x72, 0x6b, 0x49, 0x65, 0x41, 0x6a, 0x71, + 0x12, 0x1b, 0x58, 0xde, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x1a, 0x79, 0x1b, 0x0e, 0x04, 0x01, + 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/mev/types/keys.go b/x/mev/types/keys.go new file mode 100644 index 0000000000..54855509c0 --- /dev/null +++ b/x/mev/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "mev" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName +) diff --git a/x/mev/types/messages.go b/x/mev/types/messages.go new file mode 100644 index 0000000000..bfb65f5c34 --- /dev/null +++ b/x/mev/types/messages.go @@ -0,0 +1,3 @@ +package types + +// empty file, as no Msgs are defined for MEV yet diff --git a/x/mev/types/params.go b/x/mev/types/params.go new file mode 100644 index 0000000000..875bf05774 --- /dev/null +++ b/x/mev/types/params.go @@ -0,0 +1,12 @@ +package types + +// DefaultParams returns default mev module parameters +func DefaultParams() Params { + return Params{} +} + +// Validate validates params +func (p Params) Validate() error { + // Add any validation logic here if needed + return nil +} diff --git a/x/mev/types/params.pb.go b/x/mev/types/params.pb.go new file mode 100644 index 0000000000..6fce22fa5f --- /dev/null +++ b/x/mev/types/params.pb.go @@ -0,0 +1,265 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mev/x/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_1b94018c0a118e0c, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "seiprotocol.seichain.mev.Params") +} + +func init() { proto.RegisterFile("mev/x/params.proto", fileDescriptor_1b94018c0a118e0c) } + +var fileDescriptor_1b94018c0a118e0c = []byte{ + // 158 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xca, 0x4d, 0x2d, 0xd3, + 0xaf, 0xd0, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, + 0x28, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, + 0xf3, 0xf4, 0x72, 0x53, 0xcb, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, + 0x44, 0xbd, 0x12, 0x1f, 0x17, 0x5b, 0x00, 0x58, 0xbf, 0x15, 0xcb, 0x8c, 0x05, 0xf2, 0x8c, 0x4e, + 0xee, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, 0xe3, 0x84, 0xc7, + 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x9b, 0x9e, 0x59, 0x92, + 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x5f, 0x9c, 0x9a, 0xa9, 0x0b, 0xb3, 0x05, 0xcc, 0x01, + 0x5b, 0xa3, 0x5f, 0xa1, 0x0f, 0x72, 0x51, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0x58, 0xde, + 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x18, 0xdc, 0xe1, 0x3a, 0xa5, 0x00, 0x00, 0x00, +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/mev/types/query.pb.go b/x/mev/types/query.pb.go new file mode 100644 index 0000000000..c17d571b4a --- /dev/null +++ b/x/mev/types/query.pb.go @@ -0,0 +1,86 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mev/x/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("mev/x/query.proto", fileDescriptor_35308d56af5b0d0e) } + +var fileDescriptor_35308d56af5b0d0e = []byte{ + // 187 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcc, 0x4d, 0x2d, 0xd3, + 0xaf, 0xd0, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x28, + 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, + 0xf4, 0x72, 0x53, 0xcb, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, + 0xbd, 0x94, 0x4c, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x7e, 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, + 0x5e, 0x7e, 0x49, 0x62, 0x49, 0x66, 0x7e, 0x5e, 0x31, 0x54, 0x56, 0x08, 0x62, 0x41, 0x41, 0x62, + 0x51, 0x62, 0x2e, 0x54, 0xcc, 0x88, 0x9d, 0x8b, 0x35, 0x10, 0x64, 0xa1, 0x93, 0xfb, 0x89, 0x47, + 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, + 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0x17, 0xa7, 0x66, 0xea, 0xc2, 0x1c, 0x04, 0xe6, 0x80, 0x5d, 0xa4, 0x5f, + 0xa1, 0x0f, 0x32, 0xba, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x2c, 0x6f, 0x0c, 0x08, 0x00, + 0x00, 0xff, 0xff, 0x6e, 0x40, 0x03, 0x39, 0xcf, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +// QueryServer is the server API for Query service. +type QueryServer interface { +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "seiprotocol.seichain.mev.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "mev/x/query.proto", +} diff --git a/x/mev/types/tx.pb.go b/x/mev/types/tx.pb.go new file mode 100644 index 0000000000..be04671a6c --- /dev/null +++ b/x/mev/types/tx.pb.go @@ -0,0 +1,85 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: mev/x/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +func init() { proto.RegisterFile("mev/x/tx.proto", fileDescriptor_6ca4b993895e59a6) } + +var fileDescriptor_6ca4b993895e59a6 = []byte{ + // 176 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcb, 0x4d, 0x2d, 0xd3, + 0xaf, 0xd0, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x28, 0x4e, 0xcd, 0x04, + 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x72, 0x53, + 0xcb, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0xbd, 0x94, 0x5c, + 0x72, 0x7e, 0x71, 0x6e, 0x7e, 0xb1, 0x7e, 0x52, 0x62, 0x71, 0xaa, 0x7e, 0x99, 0x61, 0x52, 0x6a, + 0x49, 0xa2, 0xa1, 0x7e, 0x72, 0x7e, 0x66, 0x1e, 0x44, 0xde, 0x88, 0x95, 0x8b, 0xd9, 0xb7, 0x38, + 0xdd, 0xc9, 0xfd, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, + 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd3, 0x33, + 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x8b, 0x53, 0x33, 0x75, 0x61, 0x96, 0x83, + 0x39, 0x60, 0xdb, 0xf5, 0x2b, 0xf4, 0x41, 0x8e, 0x2c, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, + 0xcb, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x20, 0xc1, 0xe4, 0xb8, 0x00, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "seiprotocol.seichain.mev.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "mev/x/tx.proto", +} diff --git a/x/mev/types/types.go b/x/mev/types/types.go new file mode 100644 index 0000000000..75e868c3b1 --- /dev/null +++ b/x/mev/types/types.go @@ -0,0 +1,13 @@ +package types + +import ( + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil)) //&MsgSubmitBundle{}, + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +}