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

Missing r when I was trying to get transactions from block #4635

Open
yarikMyroniuk opened this issue Mar 6, 2024 · 13 comments
Open

Missing r when I was trying to get transactions from block #4635

yarikMyroniuk opened this issue Mar 6, 2024 · 13 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@yarikMyroniuk
Copy link

yarikMyroniuk commented Mar 6, 2024

Ethers Version

6.7.1

Search Terms

I saw the same issue but about missing v

Describe the Problem

I have the same issue but about missing r instead of missing v but only with zkSyncEra

But If I use method getTransaction(hash), I don't receive any errors

version lib: "ethers": "^6.7.1",

UPD: I was trying to do this with latest version ethers 6.11.1

Code Snippet

I was trying to get prefetchedTransactions from block, using method getBlock(block, true)

Contract ABI

No response

Errors

TypeError: missing r (argument="signature", value={ "blockHash": "0xea2f9049921549a11590a77ae13305f83640783b90da382b2446be23db85aaa6", "blockNumber": "0x1af3974", "chainId": "0x144", "from": "0xef1e151d145c49a2c776cade6443b47d71abe441", "gas": "0x60f97", "gasPrice": "0x75ec5cb6", "hash": "0x53e4a8dbd46b3d3604a19d4b007fe9410e94c75b3c17c0d6f0f50f1ef0bf5855", "input": "0x", "l1BatchNumber": "0x6f853", "l1BatchTxIndex": "0x517", "maxFeePerGas": "0x75ec5cb6", "maxPriorityFeePerGas": "0x0", "nonce": "0x0", "to": "0xef1e151d145c49a2c776cade6443b47d71abe441", "transactionIndex": "0x3", "type": "0xff", "value": "0x55db9421dba88956" }, code=INVALID_ARGUMENT, version=6.11.1)

Environment

node.js (v12 or newer)

Environment (Other)

No response

@yarikMyroniuk yarikMyroniuk added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Mar 6, 2024
@mahatotarit
Copy link

@yarikMyroniuk You can try out this code to retrieve all transactions from the latest block

Ethers.js :


const { ethers } = require('ethers');

// set privider
const provider = new ethers.providers.JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/UvV96RRoOF8HQ44Tn_bm7FaAuwcxct2x',);

// Get the latest block number
provider.getBlockNumber().then((blockNumber) => {
    // Get the details of the latest block
    provider.getBlock(blockNumber).then((block) => {
        console.log('Block Number:', block.number);
        console.log('Hash:', block.hash);

        // get all tx from latest block using loop
        if (block.transactions.length > 0) {
          block.transactions.forEach((txHash) => {
            // Get transaction details
            provider.getTransaction(txHash).then((tx) => {
              console.log('Transaction Hash:', tx.hash);
              console.log('From:', tx.from);
              console.log('To:', tx.to);
              console.log('Value:', ethers.utils.formatEther(tx.value), 'ETH');
              console.log('---------------------------');
            });
          });
        }
      })
      .catch((err) => {
        console.error('Error fetching block details:', err);
      });
  })
  .catch((err) => {
    console.error('Error fetching latest block number:', err);
  });

If you want all transaction details from a specific block, just change the 'blockNumber' value to your desired block number, then run the code to get all the transactions.

Ethers.js :

const { ethers } = require('ethers');

// set privider
const provider = new ethers.providers.JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/UvV96RRoOF8HQ44Tn_bm7FaAuwcxct2x',);

let blockNumber = 19489042; // you block number
provider.getBlock(blockNumber).then((block) => {
    console.log('Block Number:', block.number);
    console.log('Hash:', block.hash);

    // get all tx from latest block using loop
    if (block.transactions.length > 0) {
      block.transactions.forEach((txHash) => {
        // Get transaction details
        provider.getTransaction(txHash).then((tx) => {
          console.log('Transaction Hash:', tx.hash);
          console.log('From:', tx.from);
          console.log('To:', tx.to);
          console.log('Value:', ethers.utils.formatEther(tx.value), 'ETH');
          console.log('---------------------------');
        });
      });
    }
  })
.catch((err) => {
  console.error('Error fetching block details:', err);
});
  

@yarikMyroniuk
Copy link
Author

@mahatotarit
Yeah, You are right, I have already done this implementation but for every tx I will need to call method getTransaction that makes some load on the RPC and increases the amount of requests

I wanted to do without method getTransaction by hash

@mahatotarit
Copy link

Could you please explain exactly what you want in detail ? I'm here to help with your work.

@yarikMyroniuk
Copy link
Author

@mahatotarit
Yeah, I need to receive all transactions, by type prefetchedTransactions and not call the method for obtaining a transaction by hash one by one, since this requires a request in rpc and so I need to receive all transactions with one request

@mahatotarit
Copy link

Can you provide example ?

@yarikMyroniuk
Copy link
Author

yarikMyroniuk commented Apr 4, 2024

@mahatotarit

You sent example with this code

if (block.transactions.length > 0) {
  block.transactions.forEach((txHash) => {
    // Get transaction details
    provider.getTransaction(txHash).then((tx) => {
      console.log('Transaction Hash:', tx.hash);
      console.log('From:', tx.from);
      console.log('To:', tx.to);
      console.log('Value:', ethers.utils.formatEther(tx.value), 'ETH');
      console.log('---------------------------');
    });
  });
}

I don't like this implementation because in this case I need to fetch each transaction separately, which leads to additional requests

but this method has a better alternative like getBlock(block, true) which already has transactions in field "prefetchedTransactions", but with zkSync and with zkLinkNova, it doesn't work because I received this error:
"TypeError: missing r (argument="signature", value={ "blockHash": "0xea2f9049921549a11590a77ae13305f83640783b90da382b2446be23db85aaa6", "blockNumber": "0x1af3974", "chainId": "0x144", "from": "0xef1e151d145c49a2c776cade6443b47d71abe441", "gas": "0x60f97", "gasPrice": "0x75ec5cb6", "hash": "0x53e4a8dbd46b3d3604a19d4b007fe9410e94c75b3c17c0d6f0f50f1ef0bf5855", "input": "0x", "l1BatchNumber": "0x6f853", "l1BatchTxIndex": "0x517", "maxFeePerGas": "0x75ec5cb6", "maxPriorityFeePerGas": "0x0", "nonce": "0x0", "to": "0xef1e151d145c49a2c776cade6443b47d71abe441", "transactionIndex": "0x3", "type": "0xff", "value": "0x55db9421dba88956" }, code=INVALID_ARGUMENT, version=6.11.1)"

@yarikMyroniuk
Copy link
Author

@mahatotarit
Hey, What about my issue?

@egorFiNE
Copy link

Same error now after successful transaction on Gnosis. 100% reproducible on our projects.

@mahatotarit
Copy link

@yarikMyroniuk

Please provide your full code.

@egorFiNE
Copy link

Seems reliably reproducible by me on gnosis chain on different wallets (Metamask and Rabby)

@ricmoo
Copy link
Member

ricmoo commented Apr 24, 2024

It looks like they are using a custom type 0xff. Any info on documentation on their transaction format? It doesn't seem to be an Ethereum compatible format, so likely will need a custom plug-in.

@yarikMyroniuk
Copy link
Author

@ricmoo
Yeah, I use the native method from rpc without any library, it looks like it's working

@egorFiNE
Copy link

@ricmoo Gnosis doesn't use any non-standard type but the bug is repeatable about 70% of the time. If you could point me out where to start debugging - I'd love to dive in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

4 participants