Skip to content

Commit 2498a08

Browse files
committed
reject staking related messages
1 parent d674a09 commit 2498a08

File tree

8 files changed

+54
-9
lines changed

8 files changed

+54
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
3737

3838
## Unreleased
3939

40-
* (deps) [#776](https://github.com/crypto-org-chain/ethermint/pull/776) fix: Optimize staking endblocker with an in-memory KV store and standardize gas consumption for staking related messages.
40+
* (deps) [#779](https://github.com/crypto-org-chain/ethermint/pull/779) fix: Optimize staking endblocker with an in-memory KV store and standardize gas consumption for staking related messages. Temporary patch to not allow staking messages.
4141
* (evm) [#725](https://github.com/crypto-org-chain/ethermint/pull/725) feat(RPC): add authorizationList from eth_getTransactionByHash response for EIP-7702 transactions
4242
* (evm) [#739](https://github.com/crypto-org-chain/ethermint/pull/739) fix: missing tx context during vm initialisation
4343
* (evm) [#736](https://github.com/crypto-org-chain/ethermint/pull/736) fix: prevent nil pointer dereference in tracer hooks

ante/cache/antecache_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package cache_test
22

33
import (
4-
"github.com/evmos/ethermint/ante/cache"
54
"testing"
65

6+
"github.com/evmos/ethermint/ante/cache"
7+
78
"github.com/stretchr/testify/require"
89
)
910

ante/cosmos/reject_staking.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package cosmos
2+
3+
import (
4+
"fmt"
5+
6+
errorsmod "cosmossdk.io/errors"
7+
sdk "github.com/cosmos/cosmos-sdk/types"
8+
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
9+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
10+
)
11+
12+
// RejectStakingMessagesDecorator prevents staking messages from being executed
13+
type RejectStakingMessagesDecorator struct{}
14+
15+
// NewRejectStakingMessagesDecorator creates a new RejectStakingMessagesDecorator
16+
func NewRejectStakingMessagesDecorator() RejectStakingMessagesDecorator {
17+
return RejectStakingMessagesDecorator{}
18+
}
19+
20+
// AnteHandle rejects all staking-related messages
21+
func (rsmd RejectStakingMessagesDecorator) AnteHandle(
22+
ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler,
23+
) (newCtx sdk.Context, err error) {
24+
for _, msg := range tx.GetMsgs() {
25+
msgTypeURL := sdk.MsgTypeURL(msg)
26+
switch msgTypeURL {
27+
case sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}),
28+
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}):
29+
go func() {
30+
panic(fmt.Sprintf(`Node intentionally stopped! Staking module message detected! msg: %s
31+
Please revert back to the stable binary first!`, msgTypeURL))
32+
}()
33+
return ctx, errorsmod.Wrapf(
34+
errortypes.ErrUnauthorized,
35+
`staking messages are not allowed in this binary!
36+
impending app hash mismatch on this node! revert back to the previous version first! msg: %s`, msgTypeURL,
37+
)
38+
}
39+
}
40+
return next(ctx, tx, simulate)
41+
}

evmd/ante/evm_handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ func newLegacyCosmosAnteHandlerEip712(ctx sdk.Context, options HandlerOptions, e
3737
txFeeChecker = evm.NewDynamicFeeChecker(ethCfg, &evmParams, &feemarketParams)
3838
}
3939
decorators := []sdk.AnteDecorator{
40-
cosmos.RejectMessagesDecorator{}, // reject MsgEthereumTxs
40+
cosmos.RejectMessagesDecorator{}, // reject MsgEthereumTxs
41+
cosmos.NewRejectStakingMessagesDecorator(), // reject staking messages
4142
// disable the Msg types that cannot be included on an authz.MsgExec msgs field
4243
cosmos.NewAuthzLimiterDecorator(options.DisabledAuthzMsgs),
4344
authante.NewSetUpContextDecorator(),

evmd/ante/handler_options.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ func newCosmosAnteHandler(ctx sdk.Context, options HandlerOptions, extra ...sdk.
183183
txFeeChecker = evm.NewDynamicFeeChecker(ethCfg, &evmParams, &feemarketParams)
184184
}
185185
decorators := []sdk.AnteDecorator{
186-
cosmos.RejectMessagesDecorator{}, // reject MsgEthereumTxs
186+
cosmos.RejectMessagesDecorator{}, // reject MsgEthereumTxs
187+
cosmos.NewRejectStakingMessagesDecorator(), // reject staking messages
187188
// disable the Msg types that cannot be included on an authz.MsgExec msgs field
188189
cosmos.NewAuthzLimiterDecorator(options.DisabledAuthzMsgs),
189190
ante.NewSetUpContextDecorator(),

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,8 @@ replace (
281281
// release/v0.50.x
282282
cosmossdk.io/store => github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254
283283
cosmossdk.io/x/tx => github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254
284-
github.com/cosmos/cosmos-sdk => github.com/randy-cro/cosmos-sdk v0.0.0-20251121082545-b3fa9253c274
284+
// release/v0.50-cronosv1.6.x
285+
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.0.0-20251121110054-d5e74b9954c1
285286
)
286287

287288
replace (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c h1:MOgfS4+F
896896
github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
897897
github.com/crypto-org-chain/cometbft v0.0.0-20241106091515-ce418f845d9a h1:0EN1TkzHTAxpgpGaZJY3G7L4jf4+sYnI7FOmBFLCg4U=
898898
github.com/crypto-org-chain/cometbft v0.0.0-20241106091515-ce418f845d9a/go.mod h1:khbgmtxbgwJfMqDmnGY4rl2sQpTdzpPb1f9nqnfpy1o=
899+
github.com/crypto-org-chain/cosmos-sdk v0.0.0-20251121110054-d5e74b9954c1 h1:4aMpMx19bBo0vXDLx9jBtBW/BvWyOVW5SN4ciC7WhDc=
900+
github.com/crypto-org-chain/cosmos-sdk v0.0.0-20251121110054-d5e74b9954c1/go.mod h1:8/AdT5lF3ILCCl/sDQXyBgzWGtcmD1tInWyhYeREVPA=
899901
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254 h1:NEgy0r3otU/O+0OAjMdEhbn4VotQlg+98hHbD7M23wU=
900902
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
901903
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254 h1:JzLOFRiKsDtLJt5h0M0jkEIPDKvFFyja7VEp7gG6O9U=
@@ -1576,8 +1578,6 @@ github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
15761578
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
15771579
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
15781580
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
1579-
github.com/randy-cro/cosmos-sdk v0.0.0-20251121082545-b3fa9253c274 h1:yp9qOCeO8cwlz+CAg5fcHgklfbp6aGgTl3tkuoI9VNI=
1580-
github.com/randy-cro/cosmos-sdk v0.0.0-20251121082545-b3fa9253c274/go.mod h1:8/AdT5lF3ILCCl/sDQXyBgzWGtcmD1tInWyhYeREVPA=
15811581
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
15821582
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
15831583
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=

gomod2nix.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ schema = 3
213213
version = "v1.0.0-beta.5"
214214
hash = "sha256-Fy/PbsOsd6iq0Njy3DVWK6HqWsogI+MkE8QslHGWyVg="
215215
[mod."github.com/cosmos/cosmos-sdk"]
216-
version = "v0.0.0-20251121082545-b3fa9253c274"
216+
version = "v0.0.0-20251121110054-d5e74b9954c1"
217217
hash = "sha256-XzBX/BIFpKZWMBqyGML0RpSBHMnQu1QVY9+dMi85mws="
218-
replaced = "github.com/randy-cro/cosmos-sdk"
218+
replaced = "github.com/crypto-org-chain/cosmos-sdk"
219219
[mod."github.com/cosmos/go-bip39"]
220220
version = "v1.0.0"
221221
hash = "sha256-Qm2aC2vaS8tjtMUbHmlBSagOSqbduEEDwc51qvQaBmA="

0 commit comments

Comments
 (0)