Skip to content

Commit

Permalink
Merge pull request #24 from Peersyst/fix/disable-authz-staking-msgs
Browse files Browse the repository at this point in the history
[FIX] Disable authz staking messages
  • Loading branch information
AdriaCarrera authored May 3, 2024
2 parents 99a18b2 + ac5bf1b commit a3a472c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,10 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64) {
MaxTxGasWanted: maxGasWanted,
TxFeeChecker: ethante.NewDynamicFeeChecker(app.EvmKeeper),
ExtraDecorator: poaante.NewPoaDecorator(),
AuthzDisabledMsgTypes: []string{
sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}),
sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}),
},
}

if err := options.Validate(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ replace (
// use Evmos geth fork
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
// use exrp Evmos fork
github.com/evmos/evmos/v15 => github.com/Peersyst/evmos/v15 v15.0.0-exrp.2
github.com/evmos/evmos/v15 => github.com/Peersyst/evmos/v15 v15.0.0-exrp.3
// Security Advisory https://github.com/advisories/GHSA-h395-qcrw-5vmq
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.1
// replace broken goleveldb
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2y
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/Peersyst/evmos/v15 v15.0.0-exrp.2 h1:tvBzN2PbH+zH6mW3TI2oJs4SE6qdubXCWc+vtN/q95c=
github.com/Peersyst/evmos/v15 v15.0.0-exrp.2/go.mod h1:15ZOo7jqFRe5elw2ipTb3oHq3x7rebUjwq4y2vJEj4Q=
github.com/Peersyst/evmos/v15 v15.0.0-exrp.3 h1:aPaHhkx1YTZ7gl/fTXjhXFP4wYWf/n4ecSWiB333Gas=
github.com/Peersyst/evmos/v15 v15.0.0-exrp.3/go.mod h1:15ZOo7jqFRe5elw2ipTb3oHq3x7rebUjwq4y2vJEj4Q=
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/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
Expand Down
5 changes: 3 additions & 2 deletions x/poa/ante/poa.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ante
import (
"errors"
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

type PoaDecorator struct{}
Expand All @@ -14,8 +15,8 @@ func NewPoaDecorator() PoaDecorator {
func (cbd PoaDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
// loop through all the messages and check if the message type is allowed
for _, msg := range tx.GetMsgs() {
if sdk.MsgTypeURL(msg) == "/cosmos.staking.v1beta1.MsgUndelegate" ||
sdk.MsgTypeURL(msg) == "/cosmos.staking.v1beta1.MsgBeginRedelegate" {
if sdk.MsgTypeURL(msg) == sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}) ||
sdk.MsgTypeURL(msg) == sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}) {
return ctx, errors.New("tx type not allowed")
}
}
Expand Down

0 comments on commit a3a472c

Please sign in to comment.