Skip to content

Commit

Permalink
Problem: don't support blocking addresses
Browse files Browse the repository at this point in the history
Solution:
- support block addresses in mempool
  • Loading branch information
yihuang committed Jul 17, 2023
1 parent abe3d64 commit d950c4e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Features

* (rpc) [#1682](https://github.com/evmos/ethermint/pull/1682) Add config for maximum number of bytes returned from eth_call.
* (ante) [#]() Support blocking list of addresses in mempool.

### Bug Fixes

Expand Down
16 changes: 16 additions & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
return nil, err
}

blacklist := make(map[string]struct{}, len(options.Blacklist))
for _, str := range options.Blacklist {
addr, err := sdk.AccAddressFromBech32(str)
if err != nil {
return nil, fmt.Errorf("invalid bech32 address: %s", str)
}

blacklist[string(addr)] = struct{}{}
}

return func(
ctx sdk.Context, tx sdk.Tx, sim bool,
) (newCtx sdk.Context, err error) {
Expand All @@ -48,6 +58,12 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
"vesting messages are not supported",
)
}

for _, signer := range msg.GetSigners() {
if _, ok := blacklist[string(signer)]; ok {
return ctx, fmt.Errorf("signer is blocked: %s", signer.String())
}
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type HandlerOptions struct {
MaxTxGasWanted uint64
ExtensionOptionChecker ante.ExtensionOptionChecker
TxFeeChecker ante.TxFeeChecker
Blacklist []string
}

func (options HandlerOptions) validate() error {
Expand Down

0 comments on commit d950c4e

Please sign in to comment.