bnb-chain / bsc

A BNB Smart Chain client based on the go-ethereum fork
GNU Lesser General Public License v3.0
2.73k stars 1.56k forks source link

RPC eth_call with "pending" parameter does not seem to work on BSC #778

Closed billyadelphia closed 2 years ago

billyadelphia commented 2 years ago

I tried to check the state changes on the pending transactions using eth_call RPC with pending as the block parameter, it doesn't seem to work on geth BSC. It works fine on GETH for Ethereum. Does BSC change anything regarding of this capability ?

pythonberg1997 commented 2 years ago

Hi billyadelphia, could you please provide more detailed information, like your environment config, the command you ran and the error message?

billyadelphia commented 2 years ago

@Loverush it just RPC call, example like this

example with web3 js

web3.eth.call({
    to: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", // contract address
    data: "0xc6888fa10000000000000000000000000000000000000000000000000000000000000003" 
}, "pending")
.then(console.log);
> "0x000000000000000000000000000000000000000000000000000000000000000a"

I'ts not about any error, but with pending as the 2nd parameter, the return value should be state on pending transactions, rather than from latest block.

For example, I send a transaction that changed the a value on the contract. If I use "pending" as the parameter, the return value should be the new value even if that transaction isn't confirmed yet. But on BSC the state changes only if the transaction is confirmed.

pythonberg1997 commented 2 years ago

@billyadelphia Yes, to improve the performance, we had made some changes. Now both eth.getBlock('pending') and eth.getBlock('latest') will return the latest block. For more information, you can refer to #358.

billyadelphia commented 2 years ago

@Loverush I want that feature to be able to check state on the pending transactions. It is possible if I change some code to enable that feature for my own build of geth ?

pythonberg1997 commented 2 years ago

@billyadelphia You can try to compare geth miner module with BSC miner module and do some modification. PLEASE NOTE, this may lead to other bugs, I'm not sure.

DawkliCrypto commented 2 years ago

Does enabling the --mine flag fixes the issue ?

DawkliCrypto commented 2 years ago

@billyadelphia did you manage to make the changes ?

ofarukcaki commented 2 years ago

Using the --mine flag didn't work and resulted in corrupted node. How can I access the pending block?

billyadelphia commented 2 years ago

@DawkliCrypto @ofarukcaki , I gave up, modifying the code didn't help me.

@Loverush can I request to re-enable this feature ? Some people need this. The feature doesn't have to be enabled by default, only if we specify a flag like --enable-pending-block

ofarukcaki commented 2 years ago

358

Did you able to find a solution to this problem yet?

It does not make any sense to make such critical change on the codebase. BSC fork of the geth is full of problems

aitimate commented 2 years ago

Is there any solution now?