diff --git a/rskj-core/src/main/java/co/rsk/RskContext.java b/rskj-core/src/main/java/co/rsk/RskContext.java index 1ad2fc7ed84..aa4d921756f 100644 --- a/rskj-core/src/main/java/co/rsk/RskContext.java +++ b/rskj-core/src/main/java/co/rsk/RskContext.java @@ -1863,7 +1863,7 @@ private EthModuleWallet getEthModuleWallet() { if (wallet == null) { ethModuleWallet = new EthModuleWalletDisabled(); } else { - ethModuleWallet = new EthModuleWalletEnabled(wallet, transactionPool); + ethModuleWallet = new EthModuleWalletEnabled(wallet, getTransactionPool(), getReceivedTxSignatureCache()); } } diff --git a/rskj-core/src/main/java/co/rsk/rpc/modules/eth/EthModuleWalletEnabled.java b/rskj-core/src/main/java/co/rsk/rpc/modules/eth/EthModuleWalletEnabled.java index f326fe3e588..006896464df 100644 --- a/rskj-core/src/main/java/co/rsk/rpc/modules/eth/EthModuleWalletEnabled.java +++ b/rskj-core/src/main/java/co/rsk/rpc/modules/eth/EthModuleWalletEnabled.java @@ -27,9 +27,7 @@ import co.rsk.core.RskAddress; import org.bouncycastle.util.BigIntegers; -import org.ethereum.core.Account; -import org.ethereum.core.Transaction; -import org.ethereum.core.TransactionPool; +import org.ethereum.core.*; import org.ethereum.crypto.ECKey; import org.ethereum.crypto.HashUtil; import org.ethereum.crypto.signature.ECDSASignature; @@ -43,13 +41,14 @@ public class EthModuleWalletEnabled implements EthModuleWallet { private static final Logger LOGGER = LoggerFactory.getLogger("web3"); - private final Wallet wallet; private final TransactionPool transactionPool; + private final SignatureCache signatureCache; - public EthModuleWalletEnabled(Wallet wallet, TransactionPool transactionPool) { + public EthModuleWalletEnabled(Wallet wallet, TransactionPool transactionPool, SignatureCache signatureCache) { this.wallet = wallet; this.transactionPool = transactionPool; + this.signatureCache = signatureCache; } @Override @@ -101,7 +100,7 @@ public List ethPendingTransactions() { List pendingTxs = transactionPool.getPendingTransactions(); List managedAccounts = Arrays.asList(accounts()); return pendingTxs.stream() - .filter(tx -> managedAccounts.contains(tx.getSender().toJsonString())) + .filter(tx -> managedAccounts.contains(tx.getSender(signatureCache).toJsonString())) .collect(Collectors.toList()); } } \ No newline at end of file diff --git a/rskj-core/src/test/java/co/rsk/mine/TransactionModuleTest.java b/rskj-core/src/test/java/co/rsk/mine/TransactionModuleTest.java index 69f39bc16cc..1d2f6641773 100644 --- a/rskj-core/src/test/java/co/rsk/mine/TransactionModuleTest.java +++ b/rskj-core/src/test/java/co/rsk/mine/TransactionModuleTest.java @@ -643,7 +643,7 @@ private Web3Impl internalCreateEnvironment(Blockchain blockchain, EthModule ethModule = new EthModule( config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, reversibleTransactionExecutor1, new ExecutionBlockRetriever(blockchain, null, null), - repositoryLocator, new EthModuleWalletEnabled(wallet, transactionPool), transactionModule, + repositoryLocator, new EthModuleWalletEnabled(wallet, transactionPool, signatureCache), transactionModule, new BridgeSupportFactory( btcBlockStoreFactory, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig(), signatureCache), diff --git a/rskj-core/src/test/java/co/rsk/rpc/modules/eth/EthModuleTest.java b/rskj-core/src/test/java/co/rsk/rpc/modules/eth/EthModuleTest.java index 95a47af19b1..b8b740adec1 100644 --- a/rskj-core/src/test/java/co/rsk/rpc/modules/eth/EthModuleTest.java +++ b/rskj-core/src/test/java/co/rsk/rpc/modules/eth/EthModuleTest.java @@ -778,7 +778,7 @@ void testEthPendingTransactionsWithNoTransactions() { void pendingTransactionsWithMultipleManagedAccounts() { Wallet wallet = mock(Wallet.class); TransactionPool transactionPoolMock = mock(TransactionPool.class); - EthModuleWalletEnabled ethModuleWallet = new EthModuleWalletEnabled(wallet, transactionPoolMock); + EthModuleWalletEnabled ethModuleWallet = new EthModuleWalletEnabled(wallet, transactionPoolMock, signatureCache); ExecutionBlockRetriever retriever = mock(ExecutionBlockRetriever.class); Blockchain blockchain = mock(Blockchain.class); ReversibleTransactionExecutor reversibleTransactionExecutor = mock(ReversibleTransactionExecutor.class); @@ -814,7 +814,7 @@ void pendingTransactionsWithMultipleManagedAccounts() { void pendingTransactionsWithNoManagedAccounts() { Wallet wallet = mock(Wallet.class); TransactionPool transactionPoolMock = mock(TransactionPool.class); - EthModuleWalletEnabled ethModuleWallet = new EthModuleWalletEnabled(wallet, transactionPoolMock); + EthModuleWalletEnabled ethModuleWallet = new EthModuleWalletEnabled(wallet, transactionPoolMock, signatureCache); ExecutionBlockRetriever retriever = mock(ExecutionBlockRetriever.class); Blockchain blockchain = mock(Blockchain.class); ReversibleTransactionExecutor reversibleTransactionExecutor = mock(ReversibleTransactionExecutor.class); @@ -877,7 +877,7 @@ private Transaction createMockTransaction(String fromAddress) { Transaction transaction = mock(Transaction.class); RskAddress address = new RskAddress(fromAddress); System.out.println("mock address: " + address); - when(transaction.getSender()).thenReturn(address); + when(transaction.getSender(any(SignatureCache.class))).thenReturn(address); byte[] mockHashBytes = new byte[32]; Arrays.fill(mockHashBytes, (byte) 1); diff --git a/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplLogsTest.java b/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplLogsTest.java index d9cc47dc524..6afe3b19df5 100644 --- a/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplLogsTest.java +++ b/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplLogsTest.java @@ -1092,7 +1092,7 @@ private Web3Impl createWeb3() { EthModule ethModule = new EthModule( config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockChain, transactionPool, null, new ExecutionBlockRetriever(blockChain, null, null), - null, new EthModuleWalletEnabled(wallet, transactionPool), null, + null, new EthModuleWalletEnabled(wallet, transactionPool, signatureCache), null, new BridgeSupportFactory( null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig(), new BlockTxSignatureCache(new ReceivedTxSignatureCache())), config.getGasEstimationCap(), diff --git a/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplScoringTest.java b/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplScoringTest.java index 76260141ec2..a31a8fc3af0 100644 --- a/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplScoringTest.java +++ b/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplScoringTest.java @@ -393,7 +393,7 @@ private static Web3Impl createWeb3(PeerScoringManager peerScoringManager) { EthModule em = new EthModule( config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), world.getBlockChain(), null, null, new ExecutionBlockRetriever(world.getBlockChain(), null, null), - null, new EthModuleWalletEnabled(wallet, world.getTransactionPool()), null, + null, new EthModuleWalletEnabled(wallet, world.getTransactionPool(), world.getBlockTxSignatureCache()), null, new BridgeSupportFactory( null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig(), new BlockTxSignatureCache(new ReceivedTxSignatureCache())), config.getGasEstimationCap(), diff --git a/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplTest.java b/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplTest.java index e62d94e4542..8637b277cad 100644 --- a/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplTest.java +++ b/rskj-core/src/test/java/org/ethereum/rpc/Web3ImplTest.java @@ -2684,7 +2684,7 @@ private Web3Impl createWeb3(SimpleEthereum eth, PeerServer peerServer) { EthModule ethModule = new EthModule( config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, null, new ExecutionBlockRetriever(blockchain, null, null), - null, new EthModuleWalletEnabled(wallet, transactionPool), null, + null, new EthModuleWalletEnabled(wallet, transactionPool, signatureCache), null, new BridgeSupportFactory( null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig(), signatureCache), config.getGasEstimationCap(), @@ -2801,7 +2801,7 @@ private Web3Impl createWeb3( TransactionGateway transactionGateway = new TransactionGateway(new SimpleChannelManager(), transactionPool); EthModule ethModule = new EthModule( config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, executor, - new ExecutionBlockRetriever(blockchain, null, null), repositoryLocator, new EthModuleWalletEnabled(wallet, transactionPool), + new ExecutionBlockRetriever(blockchain, null, null), repositoryLocator, new EthModuleWalletEnabled(wallet, transactionPool, signatureCache), new EthModuleTransactionBase(config.getNetworkConstants(), wallet, transactionPool, transactionGateway), new BridgeSupportFactory( null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig(), signatureCache), @@ -2865,7 +2865,7 @@ private Web3Impl createWeb3CallNoReturn( EthModule ethModule = new EthModule( config.getNetworkConstants().getBridgeConstants(), config.getNetworkConstants().getChainId(), blockchain, transactionPool, executor, new ExecutionBlockRetriever(blockchain, null, null), repositoryLocator, - new EthModuleWalletEnabled(wallet, transactionPool), + new EthModuleWalletEnabled(wallet, transactionPool, signatureCache), new EthModuleTransactionBase(config.getNetworkConstants(), wallet, transactionPool, null), new BridgeSupportFactory( null, config.getNetworkConstants().getBridgeConstants(), config.getActivationConfig(), signatureCache),