From c1e13b292dd31f34c2d564fd5fa2cebc2d67182d Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Fri, 27 Dec 2024 09:41:05 +0800 Subject: [PATCH 1/3] integrate with MinTxsInBlock --- app/app.go | 11 +++++++---- go.mod | 4 ++-- go.sum | 8 ++------ scripts/initialize_local_chain.sh | 1 + 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/app.go b/app/app.go index 8a2b30231e..0a7ee66349 100644 --- a/app/app.go +++ b/app/app.go @@ -1703,8 +1703,9 @@ func (app *App) getFinalizeBlockResponse(appHash []byte, events []abci.Event, tx }), ConsensusParamUpdates: &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ - MaxBytes: endBlockResp.ConsensusParamUpdates.Block.MaxBytes, - MaxGas: endBlockResp.ConsensusParamUpdates.Block.MaxGas, + MaxBytes: endBlockResp.ConsensusParamUpdates.Block.MaxBytes, + MaxGas: endBlockResp.ConsensusParamUpdates.Block.MaxGas, + MinTxsInBlock: endBlockResp.ConsensusParamUpdates.Block.MinTxsInBlock, }, Evidence: &tmproto.EvidenceParams{ MaxAgeNumBlocks: endBlockResp.ConsensusParamUpdates.Evidence.MaxAgeNumBlocks, @@ -1910,8 +1911,10 @@ func (app *App) checkTotalBlockGasWanted(ctx sdk.Context, txs [][]byte) bool { totalGasWanted += gasWanted if totalGasWanted > uint64(ctx.ConsensusParams().Block.MaxGas) { - // early return - return false + if len(txs) > int(ctx.ConsensusParams().Block.MinTxsInBlock) { + // early return + return false + } } } return true diff --git a/go.mod b/go.mod index 164c2cda88..9e3528c94d 100644 --- a/go.mod +++ b/go.mod @@ -347,7 +347,7 @@ replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.3.0 github.com/CosmWasm/wasmvm => github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.48 + github.com/cosmos/cosmos-sdk => ../sei-cosmos // github.com/sei-protocol/sei-cosmos v0.3.48 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.4 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96 @@ -355,7 +355,7 @@ replace ( github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.46 // 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.4.3 + github.com/tendermint/tendermint => ../sei-tendermint // github.com/sei-protocol/sei-tendermint v0.4.3 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 b858b854c7..875e59b147 100644 --- a/go.sum +++ b/go.sum @@ -1345,16 +1345,12 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96 github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= -github.com/sei-protocol/sei-cosmos v0.3.48 h1:kSDweeTaLZ4TByLqAD6/hmtgAhAJHwXU1beyqsVXJkQ= -github.com/sei-protocol/sei-cosmos v0.3.48/go.mod h1:XC417pB6NwxP/cQ2XTSZLzVnP8dMZ//4uCXS3SxFgoM= github.com/sei-protocol/sei-db v0.0.46 h1:naXfSp1I3UgJJm/iSvXpdFzr9nofEOxp/EekcAVj7wY= github.com/sei-protocol/sei-db v0.0.46/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= -github.com/sei-protocol/sei-ibc-go/v3 v3.3.4 h1:M1r1B2yzogs7RyXdCPgaNJlxqSC/rU2goqtfnUTXS/M= -github.com/sei-protocol/sei-ibc-go/v3 v3.3.4/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= -github.com/sei-protocol/sei-tendermint v0.4.3 h1:/Nx3Q309B4N61P3e6ScYiVuHgBRdapc3Taedz7a6/7k= -github.com/sei-protocol/sei-tendermint v0.4.3/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4= +github.com/sei-protocol/sei-ibc-go/v3 v3.3.3 h1:0kg1giMHiKMLXOCFLqH/9kqdl5bH+unzI8qRF6qwXzw= +github.com/sei-protocol/sei-ibc-go/v3 v3.3.3/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= 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= diff --git a/scripts/initialize_local_chain.sh b/scripts/initialize_local_chain.sh index ff17168f17..82c134c475 100755 --- a/scripts/initialize_local_chain.sh +++ b/scripts/initialize_local_chain.sh @@ -59,6 +59,7 @@ cat ~/.sei/config/genesis.json | jq '.app_state["oracle"]["params"]["vote_period cat ~/.sei/config/genesis.json | jq '.app_state["oracle"]["params"]["whitelist"]=[{"name": "ueth"},{"name": "ubtc"},{"name": "uusdc"},{"name": "uusdt"},{"name": "uosmo"},{"name": "uatom"},{"name": "usei"}]' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json cat ~/.sei/config/genesis.json | jq '.app_state["distribution"]["params"]["community_tax"]="0.000000000000000000"' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json cat ~/.sei/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="35000000"' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json +cat ~/.sei/config/genesis.json | jq '.consensus_params["block"]["min_txs_in_block"]="2"' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json cat ~/.sei/config/genesis.json | jq '.app_state["staking"]["params"]["max_voting_power_ratio"]="1.000000000000000000"' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json cat ~/.sei/config/genesis.json | jq '.app_state["bank"]["denom_metadata"]=[{"denom_units":[{"denom":"usei","exponent":0,"aliases":["USEI"]}],"base":"usei","display":"usei","name":"USEI","symbol":"USEI"}]' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json From a39aba4ff6ac1c509c260855791964bf2cc40cfb Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Mon, 6 Jan 2025 11:35:45 +0800 Subject: [PATCH 2/3] rebase --- go.sum | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/go.sum b/go.sum index 875e59b147..6617c6c6ef 100644 --- a/go.sum +++ b/go.sum @@ -1349,8 +1349,8 @@ github.com/sei-protocol/sei-db v0.0.46 h1:naXfSp1I3UgJJm/iSvXpdFzr9nofEOxp/EekcA github.com/sei-protocol/sei-db v0.0.46/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= -github.com/sei-protocol/sei-ibc-go/v3 v3.3.3 h1:0kg1giMHiKMLXOCFLqH/9kqdl5bH+unzI8qRF6qwXzw= -github.com/sei-protocol/sei-ibc-go/v3 v3.3.3/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= +github.com/sei-protocol/sei-ibc-go/v3 v3.3.4 h1:M1r1B2yzogs7RyXdCPgaNJlxqSC/rU2goqtfnUTXS/M= +github.com/sei-protocol/sei-ibc-go/v3 v3.3.4/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= 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= From 9269c53d7464a2e676b00a9fbc84fff06e6312dd Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Mon, 6 Jan 2025 20:10:43 +0800 Subject: [PATCH 3/3] update deps --- app/app.go | 7 ++++++- go.mod | 4 ++-- go.sum | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/app.go b/app/app.go index 0a7ee66349..ea048a614b 100644 --- a/app/app.go +++ b/app/app.go @@ -1865,6 +1865,7 @@ func RegisterSwaggerAPI(rtr *mux.Router) { func (app *App) checkTotalBlockGasWanted(ctx sdk.Context, txs [][]byte) bool { totalGasWanted := uint64(0) + nonzeroTxsCnt := 0 for _, tx := range txs { decodedTx, err := app.txDecoder(tx) if err != nil { @@ -1909,9 +1910,13 @@ func (app *App) checkTotalBlockGasWanted(ctx sdk.Context, txs [][]byte) bool { return false } + if gasWanted > 0 { + nonzeroTxsCnt++ + } + totalGasWanted += gasWanted if totalGasWanted > uint64(ctx.ConsensusParams().Block.MaxGas) { - if len(txs) > int(ctx.ConsensusParams().Block.MinTxsInBlock) { + if nonzeroTxsCnt > int(ctx.ConsensusParams().Block.MinTxsInBlock) { // early return return false } diff --git a/go.mod b/go.mod index 9e3528c94d..679f6e23b5 100644 --- a/go.mod +++ b/go.mod @@ -347,7 +347,7 @@ replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.3.0 github.com/CosmWasm/wasmvm => github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => ../sei-cosmos // github.com/sei-protocol/sei-cosmos v0.3.48 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.51 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.4 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96 @@ -355,7 +355,7 @@ replace ( github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.46 // 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 => ../sei-tendermint // github.com/sei-protocol/sei-tendermint v0.4.3 + github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.4.5 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 6617c6c6ef..f9c0d9a79b 100644 --- a/go.sum +++ b/go.sum @@ -1345,12 +1345,16 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96 github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= +github.com/sei-protocol/sei-cosmos v0.3.51 h1:Lw4L+pJXa0bvq48q4mH9Mmr378EZg1pUgiRzex55yk0= +github.com/sei-protocol/sei-cosmos v0.3.51/go.mod h1:zdKiFj5Cobfd30/cVz7CgQlxUtrK2Msjk6Gf6y/hl8g= github.com/sei-protocol/sei-db v0.0.46 h1:naXfSp1I3UgJJm/iSvXpdFzr9nofEOxp/EekcAVj7wY= github.com/sei-protocol/sei-db v0.0.46/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= github.com/sei-protocol/sei-ibc-go/v3 v3.3.4 h1:M1r1B2yzogs7RyXdCPgaNJlxqSC/rU2goqtfnUTXS/M= github.com/sei-protocol/sei-ibc-go/v3 v3.3.4/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA= +github.com/sei-protocol/sei-tendermint v0.4.5 h1:vdibojcaBb+OCNeoGmU8daL41U+Sc7AHCBkDqSS7knQ= +github.com/sei-protocol/sei-tendermint v0.4.5/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=