Skip to content

Commit b338cac

Browse files
committed
reject staking related messages
1 parent 0d036fd commit b338cac

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
22+
for _, msg := range tx.GetMsgs() {
23+
msgTypeURL := sdk.MsgTypeURL(msg)
24+
switch msgTypeURL {
25+
case sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}),
26+
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}):
27+
go func() {
28+
panic(fmt.Sprintf(`Node intentionally stopped! Staking module message detected! msg: %s
29+
Please revert back to the stable binary first!`, msgTypeURL))
30+
}()
31+
return ctx, errorsmod.Wrapf(
32+
errortypes.ErrUnauthorized,
33+
`staking messages are not allowed in this binary!
34+
impending app hash mismatch on this node! revert back to the previous version first! msg: %s`, msgTypeURL,
35+
)
36+
}
37+
}
38+
return next(ctx, tx, simulate)
39+
}

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(),

0 commit comments

Comments
 (0)