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

Return sender (and chainId) on 'eth_subscribe', ['newPendingTransactions', true] #26030

Closed
geomad opened this issue Oct 22, 2022 · 2 comments · Fixed by #26126
Closed

Return sender (and chainId) on 'eth_subscribe', ['newPendingTransactions', true] #26030

geomad opened this issue Oct 22, 2022 · 2 comments · Fixed by #26126
Labels

Comments

@geomad
Copy link

geomad commented Oct 22, 2022

The new feature added on 5b1a04b returning the full transaction on newPendingTransactions subscription is really useful, but does not return the full information like subscribing for hashes and then using eth_getTransaction with it does.

Please add from and possibly chainId (to make it complete) on the full transaction object.

Example of object returned with 'eth_subscribe', ['newPendingTransactions', true]:

{
  type: '0x2',
  nonce: '0xe',
  gasPrice: null,
  maxPriorityFeePerGas: '0x59682f00',
  maxFeePerGas: '0x8e26dacb2',
  gas: '0x394de',
  value: '0x0',
  input: '0x5ae401dc0000000000000000000000000000000000000000000000000000000063542a0b000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000e4472b43f30000000000000000000000000000000000000000000a17ae76b747b02bc0bb7800000000000000000000000000000000000000000000000007cc4a16fbd8c81e00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000038c15f59f2f14adb24672ea25da111c3f81637a0000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004449404b7c00000000000000000000000000000000000000000000000007cc4a16fbd8c81e000000000000000000000000f9eb81b3807e3e9abc5537af73be2a0c8e6b923900000000000000000000000000000000000000000000000000000000',
  v: '0x1',
  r: '0x5aaf8b6da68451a1ac6fba1a00107179eac97500d4cb0b849d9671462eedd890',
  s: '0x279d7df79cb05c3033de9d963cc9b2a785a43bca9c9b802fe33c2ee955edad09',
  to: '0x68b3465833fb72a70ecdf485e0e4c7bd8665fc45',
  chainId: '0x1',
  accessList: [],
  hash: '0x5ec2a5ae29fab77d7503e8cc5921b7c31d05e72ad2e7602526c6b3ecabbe18d0'
}

Example of object returned with 'eth_subscribe', ['newPendingTransactions'] , and then eth_getTransaction on the result:

{
  blockHash: null,
  blockNumber: null,
  from: '0x97521d509A028b1009F651e14E1e471f3452DE36',
  gas: 69724,
  gasPrice: '32950574540',
  maxFeePerGas: '32950574540',
  maxPriorityFeePerGas: '1000000000',
  hash: '0xf5b75b99b293b20a4029718f165f356d2f3d3b2f5b2d36dfd0d0fd7454cc4968',
  input: '0x095ea7b30000000000000000000000001111111254fb6c44bac0bed2854e76f90643097dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
  nonce: 22,
  to: '0x761D38e5ddf6ccf6Cf7c55759d5210750B5D60F3',
  transactionIndex: null,
  value: '0',
  type: 2,
  accessList: [],
  chainId: '0x1',
  v: '0x0',
  r: '0x608844986b439407a7e49c3c2db9a4b46ff213cef692a4397cf202fea790edb6',
  s: '0x424cce707fe6c5c366a4369d025ae4908def0afec259639f9f70d5dbf26d509b'
}

Note: web3.js (v1.8.0) does not support yet the true argument when subscribing 'newPendingTransactions'. I've opened an issue for it (web3/web3.js#5548).
Workaround for now is to comment out line 70 in \node_modules\web3-core-subscriptions\lib\subscription.js

    if (args.length !== subscription.params) {
        //throw errors.InvalidNumberOfParams(args.length, subscription.params, subscription.subscriptionName);
    }

Note 2: I just noticed that while one method returns hex values, the other returns numbers. I am not sure if that's due to web3.js lack of support but maybe worth taking a look as well.

@kaber2
Copy link

kaber2 commented Oct 31, 2022

Agreed, for consistency it would be nice to send the result of ethapi.newRPCTransaction(tx, ...).

@s1na
Copy link
Contributor

s1na commented Nov 9, 2022

Note 2: I just noticed that while one method returns hex values, the other returns numbers. I am not sure if that's due to web3.js lack of support but maybe worth taking a look as well.

That's because web3.js is post-processing the result. If you getTransactionByHash via curl:

curl -X POST -H "Content-Type: application/json" --data '{"method":"eth_getTransactionByHash","params":["0xfa1c1fe6823ceb6b0c8688e3f690025aaf7188c44fc1a334f47b71013caba2df":15295,"jsonrpc":"2.0"}' http://localhost:8545 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3090    0  2946  100   144   208k  10424 --:--:-- --:--:-- --:--:-- 3017k
{
  "jsonrpc": "2.0",
  "id": 15295,
  "result": {
    "blockHash": "0x7744902ac62296047d47cd68fc89676de31053973bc2cff24d8ba70da0ea585a",
    "blockNumber": "0x72b5d8",
    "from": "0x7351dc227bacc5b33d1e14c778e46439852673b7",
    "gas": "0x1c9c380",
    "gasPrice": "0x95032efe",
    "maxFeePerGas": "0x95032efe",
    "maxPriorityFeePerGas": "0x9502f900",
    "hash": "0xfa1c1fe6823ceb6b0c8688e3f690025aaf7188c44fc1a334f47b71013caba2df",
    "input": "0x2e....",
    "nonce": "0x5c",
    "to": "0x9b0b70edaa3b6ae70389d8514ed65acd86386ef2",
    "transactionIndex": "0x0",
    "value": "0x0",
    "type": "0x2",
    "accessList": [],
    "chainId": "0x5",
    "v": "0x1",
    "r": "0x5556afe935aae3e4f3275b04c8bf7405733cd0c6bdef6aae9dc5c3f8d96a2f9f",
    "s": "0x1c5305e2d9e6068bfdb154b3139c07cd67a98d158c3f0e3e0e01840783df3eff"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants