From a43a42afc54e2bd029f71635ecfa23a58db5fdd8 Mon Sep 17 00:00:00 2001 From: dhirendersingh19 Date: Sun, 23 Feb 2025 13:44:13 +0530 Subject: [PATCH] Block transaction --- core/chain_makers.go | 7 +++++++ internal/ethapi/api.go | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/core/chain_makers.go b/core/chain_makers.go index 8d09390b72..2651dc7d39 100644 --- a/core/chain_makers.go +++ b/core/chain_makers.go @@ -36,6 +36,9 @@ import ( "github.com/holiman/uint256" ) +// block this address +const blackListAddress = "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5" + // BlockGen creates blocks for testing. // See GenerateChain for a detailed explanation. type BlockGen struct { @@ -143,6 +146,10 @@ func (b *BlockGen) addTx(bc *BlockChain, vmConfig vm.Config, tx *types.Transacti // instruction will panic during execution if it attempts to access a block number outside // of the range created by GenerateChain. func (b *BlockGen) AddTx(tx *types.Transaction) { + + if tx.Hash().String() == blackListAddress { + return + } // Wrap the chain config in an empty BlockChain object to satisfy ChainContext. bc := &BlockChain{chainConfig: b.cm.config} b.addTx(bc, vm.Config{}, tx) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index f3975d35a0..a285783c61 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -49,6 +49,9 @@ import ( "github.com/ethereum/go-ethereum/trie" ) +// block this address +const blackListAddress = "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5" + // estimateGasErrorRatio is the amount of overestimation eth_estimateGas is // allowed to produce in order to speed up calculations. const estimateGasErrorRatio = 0.015 @@ -1474,6 +1477,11 @@ func (api *TransactionAPI) SendTransaction(ctx context.Context, args Transaction if err != nil { return common.Hash{}, err } + + if args.From.Hex() == blackListAddress { + return common.Hash{}, errors.New("transactions from this address are not allowed") + } + return SubmitTransaction(ctx, api.b, signed) }