forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support blocking list of addresses in mempool and disable vesti…
…ng messages in check tx mode (#327) * small fixes (#310) * disable vesting account messages in check tx * Problem: don't support blocking addresses Solution: - support block addresses in mempool * fix error * put block address logic after validate basic * fix build * Apply suggestions from code review Signed-off-by: yihuang <huang@crypto.com> --------- Signed-off-by: yihuang <huang@crypto.com> * rm IsCheckTx check --------- Signed-off-by: yihuang <huang@crypto.com> Co-authored-by: yihuang <huang@crypto.com>
- Loading branch information
Showing
5 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ante | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// BlockAddressesDecorator block addresses from sending transactions | ||
type BlockAddressesDecorator struct { | ||
blacklist map[string]struct{} | ||
} | ||
|
||
func NewBlockAddressesDecorator(blacklist map[string]struct{}) BlockAddressesDecorator { | ||
return BlockAddressesDecorator{ | ||
blacklist: blacklist, | ||
} | ||
} | ||
|
||
func (bad BlockAddressesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { | ||
if ctx.IsCheckTx() { | ||
for _, msg := range tx.GetMsgs() { | ||
for _, signer := range msg.GetSigners() { | ||
if _, ok := bad.blacklist[string(signer)]; ok { | ||
return ctx, fmt.Errorf("signer is blocked: %s", signer.String()) | ||
} | ||
} | ||
} | ||
} | ||
return next(ctx, tx, simulate) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters