Skip to content

Commit

Permalink
Fix lockup allowed messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBorst committed Dec 17, 2024
1 parent 89ec113 commit 1137013
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x/lockup/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func (lad LockAnteDecorator) isAcceptable(ctx sdk.Context, msg sdk.Msg) error {
// Check that any locked msg is permissible on a type-case basis
if allow, err := allowMessage(msg, exemptSet, lockedTokenDenomsSet); !allow {
return sdkerrors.Wrap(err, fmt.Sprintf("Transaction blocked because of message %v", msg))
} else {
// The user is exempt, allow it to pass
return nil
}
}
if msgType == "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress" {
Expand All @@ -137,7 +140,11 @@ func (lad LockAnteDecorator) isAcceptable(ctx sdk.Context, msg sdk.Msg) error {
return sdkerrors.Wrap(types.ErrLocked, "The chain is locked, recursively MsgExec-wrapped Msgs are not allowed")
}
if msgType == "/ethermint.evm.v1.MsgEthereumTx" {
return sdkerrors.Wrap(types.ErrLocked, "The chain is locked, only exempt addresses may submit this Msg type")
if allow, err := allowMessage(msg, exemptSet, lockedTokenDenomsSet); !allow {
return sdkerrors.Wrap(err, "The chain is locked, only exempt addresses may submit this Msg type")
} else {
return nil
}
}

return nil
Expand Down Expand Up @@ -222,6 +229,7 @@ func allowMessage(msg sdk.Msg, exemptSet map[string]struct{}, lockedTokenDenomsS
msgEvmTx := msg.(*evmtypes.MsgEthereumTx)
addressBytes := common.HexToAddress(msgEvmTx.From).Bytes()
ethermintAddr := sdk.AccAddress(addressBytes)
fmt.Printf("From: %v Addr: %v\n", msgEvmTx.From, ethermintAddr.String())
if _, present := exemptSet[ethermintAddr.String()]; !present {
return false, sdkerrors.Wrap(types.ErrLocked,
"The chain is locked, only exempt addresses may send a MsgEthereumTx")
Expand Down
4 changes: 4 additions & 0 deletions x/lockup/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"

evmtypes "github.com/evmos/ethermint/x/evm/types"

"github.com/AltheaFoundation/althea-L1/config"
microtxtypes "github.com/AltheaFoundation/althea-L1/x/microtx/types"
)
Expand All @@ -33,6 +35,8 @@ func DefaultParams() *Params {
sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}),
// nolint: exhaustruct
sdk.MsgTypeURL(&microtxtypes.MsgMicrotx{}),
// nolint: exhaustruct
sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}),
},
/* Note: The authoritative way to get the native token of the chain is by calling
mintKeeper.GetParams(ctx).MintDenom, but the context is not available yet
Expand Down

0 comments on commit 1137013

Please sign in to comment.