Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation for newPendingTransactions (eth_subscribe) #1787

Merged
merged 3 commits into from
Aug 9, 2023

Conversation

stana-miric
Copy link
Contributor

Description

This PR introduces implementation of newPendingTransaction as a parameter of eth_subscribe. User can subscribe to this parameter and receive updates when the new tx is added to the tx pool.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

Manual tests

Custer is run using e2e test which periodically inserts transactions

 func TestE2E_NewTx(t *testing.T) {
	
        sender, err := wallet.GenerateKey()
	require.NoError(t, err)

	cluster := framework.NewTestCluster(t, 4,
		framework.WithNativeTokenConfig(fmt.Sprintf(nativeTokenMintableTestCfg, sender.Address())),
		framework.WithPremine(types.Address(sender.Address())),
	)
	defer cluster.Stop()

	cluster.WaitForReady(t)

	acct, err := wallet.GenerateKey()
	require.NoError(t, err)

	toAddr := acct.Address()

	srv := cluster.Servers[0]
	t.Log("**JSON RPC ADDR", srv.JSONRPCAddr())

	for i := 0; i < 100; i++ {
		txn := cluster.SendTxn(t, sender, &ethgo.Transaction{
			To:       &toAddr,
			Value:    big.NewInt(1),
			GasPrice: 0,
		})
		require.NoError(t, txn.Wait())
		require.True(t, txn.Succeed())
		t.Log("Tx", i, "- hash:", txn.Receipt().TransactionHash.String())
		time.Sleep(5 * time.Second)
	}
}

In a separate console we subscribed to newPendingTransaction events using following command:
wscat -c ws://localhost:12001/ws -x '{"jsonrpc":"2.0", "id": 1, "method":"eth_subscribe", "params": ["newPendingTransactions"]}' -w 120

Documentation update

@DannyS03 if we have documented which json rpc calls we support, then we should add newPendingTransaction as a part of eth_subscribe

@stana-miric stana-miric added the feature New update to Polygon Edge label Aug 7, 2023
@stana-miric stana-miric requested a review from a team August 7, 2023 08:13
@stana-miric stana-miric self-assigned this Aug 7, 2023
Copy link
Collaborator

@Stefan-Ethernal Stefan-Ethernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, leaving some feedback to consider.

jsonrpc/dispatcher_test.go Outdated Show resolved Hide resolved
jsonrpc/dispatcher_test.go Outdated Show resolved Hide resolved
jsonrpc/dispatcher_test.go Outdated Show resolved Hide resolved
jsonrpc/filter_manager_test.go Show resolved Hide resolved
jsonrpc/filter_manager.go Outdated Show resolved Hide resolved
jsonrpc/filter_manager.go Outdated Show resolved Hide resolved
jsonrpc/filter_manager.go Outdated Show resolved Hide resolved
@stana-miric stana-miric merged commit 761bc22 into develop Aug 9, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Aug 9, 2023
@Stefan-Ethernal Stefan-Ethernal deleted the EVM-756-implement-new-pending-transaction branch August 11, 2023 05:47
Copy link
Contributor

@vcastellm vcastellm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New update to Polygon Edge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants