From 18ae9cebe5658e31d57b83f78c10f67cea36ccb2 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Thu, 8 Aug 2024 18:00:40 -0700 Subject: [PATCH 1/3] fix TestMempoolEthTxsAppGossipHandling --- plugin/evm/gossiper_eth_gossiping_test.go | 18 ++++-------------- plugin/evm/vm_test.go | 1 - 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/plugin/evm/gossiper_eth_gossiping_test.go b/plugin/evm/gossiper_eth_gossiping_test.go index 21b9bc6620..75ac815295 100644 --- a/plugin/evm/gossiper_eth_gossiping_test.go +++ b/plugin/evm/gossiper_eth_gossiping_test.go @@ -21,14 +21,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/rlp" "github.com/stretchr/testify/assert" "github.com/ava-labs/coreth/core" "github.com/ava-labs/coreth/core/types" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/plugin/evm/message" ) func fundAddressByGenesis(addrs []common.Address) (string, error) { @@ -115,22 +113,14 @@ func TestMempoolEthTxsAppGossipHandling(t *testing.T) { // prepare a tx tx := getValidEthTxs(key, 1, common.Big1)[0] - // show that unknown coreth hashes is requested - txBytes, err := rlp.EncodeToBytes([]*types.Transaction{tx}) - assert.NoError(err) - msg := message.EthTxsGossip{ - Txs: txBytes, - } - msgBytes, err := message.BuildGossipMessage(vm.networkCodec, msg) - assert.NoError(err) - - nodeID := ids.GenerateTestNodeID() - err = vm.AppGossip(context.Background(), nodeID, msgBytes) + // Txs must be submitted over the API to be included in push gossip. + // (i.e., txs received via p2p are not included in push gossip) + err = vm.eth.APIBackend.SendTx(context.Background(), tx) assert.NoError(err) assert.False(txRequested, "tx should not be requested") // wait for transaction to be re-gossiped - attemptAwait(t, &wg, 5*time.Second) + attemptAwait(t, &wg, 5*time.Hour) } func attemptAwait(t *testing.T, wg *sync.WaitGroup, delay time.Duration) { diff --git a/plugin/evm/vm_test.go b/plugin/evm/vm_test.go index 1137774f1e..05574fdbf8 100644 --- a/plugin/evm/vm_test.go +++ b/plugin/evm/vm_test.go @@ -311,7 +311,6 @@ func GenesisVMWithClock( *enginetest.Sender, ) { vm := &VM{clock: clock} - vm.p2pSender = &enginetest.SenderStub{} ctx, dbManager, genesisBytes, issuer, m := setupGenesis(t, genesisJSON) appSender := &enginetest.Sender{T: t} appSender.CantSendAppGossip = true From 3cee3d6c76b4f375c64979da176c0de9dc7321b6 Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Thu, 8 Aug 2024 18:01:23 -0700 Subject: [PATCH 2/3] Update plugin/evm/gossiper_eth_gossiping_test.go Signed-off-by: Darioush Jalali --- plugin/evm/gossiper_eth_gossiping_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/evm/gossiper_eth_gossiping_test.go b/plugin/evm/gossiper_eth_gossiping_test.go index 75ac815295..dfcf80666f 100644 --- a/plugin/evm/gossiper_eth_gossiping_test.go +++ b/plugin/evm/gossiper_eth_gossiping_test.go @@ -120,7 +120,7 @@ func TestMempoolEthTxsAppGossipHandling(t *testing.T) { assert.False(txRequested, "tx should not be requested") // wait for transaction to be re-gossiped - attemptAwait(t, &wg, 5*time.Hour) + attemptAwait(t, &wg, 5*time.Second) } func attemptAwait(t *testing.T, wg *sync.WaitGroup, delay time.Duration) { From 6c7eaa8e5f65a14e03485a81679b938c566c1caf Mon Sep 17 00:00:00 2001 From: Darioush Jalali Date: Thu, 8 Aug 2024 18:38:57 -0700 Subject: [PATCH 3/3] fix atomic test too --- plugin/evm/gossiper_atomic_gossiping_test.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/plugin/evm/gossiper_atomic_gossiping_test.go b/plugin/evm/gossiper_atomic_gossiping_test.go index c2aadeb575..6ab4b429b9 100644 --- a/plugin/evm/gossiper_atomic_gossiping_test.go +++ b/plugin/evm/gossiper_atomic_gossiping_test.go @@ -170,19 +170,13 @@ func TestMempoolAtmTxsAppGossipHandlingDiscardedTx(t *testing.T) { assert.False(mempool.has(txID)) - // Gossip the transaction that conflicts with the originally - // discarded tx and ensure it is accepted into the mempool and gossipped - // to the network. - nodeID = ids.GenerateTestNodeID() - msg = message.AtomicTxGossip{ - Tx: conflictingTx.SignedBytes(), - } - msgBytes, err = message.BuildGossipMessage(vm.networkCodec, msg) - assert.NoError(err) - vm.ctx.Lock.Unlock() - assert.NoError(vm.AppGossip(context.Background(), nodeID, msgBytes)) + // Conflicting tx must be submitted over the API to be included in push gossip. + // (i.e., txs received via p2p are not included in push gossip) + // This test adds it directly to the mempool + gossiper to simulate that. + vm.mempool.AddTx(conflictingTx) + vm.atomicTxPushGossiper.Add(&GossipAtomicTx{conflictingTx}) time.Sleep(500 * time.Millisecond) vm.ctx.Lock.Lock()