0xPolygonHermez / cdk-erigon

Ethereum implementation on the efficiency frontier
GNU Lesser General Public License v3.0
32 stars 30 forks source link

RPCDaemon CDK Erigon does not initialize certain buckets when started with datadir={dirpath} #848

Open indanielo opened 2 months ago

indanielo commented 2 months ago

System information

Erigon version: v.1.1.5.9

Erigon Command (with flags/config):

/build/bin/rpcdaemon --datadir={dirpath} --txpool.api.addr=localhost:9091 --private.api.addr=localhost:9092 --http.port=8550 --http.api=eth,erigon,web3,net,debug,trace,txpool,zkevm

Chain/Network: Mainnet/Cardona

Expected behaviour

Correct "to", "gasUsed" and other fields

{"jsonrpc":"2.0","id":1,"result":{"from":"0x72e5de45588aa6597826c23eeff329778e35723b","gas":"0x223260","gasUsed":"0x2229d6","to":"0xe4319073c941a770b026ee86e2611c66363cb54f", ...

Actual behaviour

Wrong "to", "gasUsed" and other fields

{"jsonrpc":"2.0","id":1,"result":{"from":"0x72e5de45588aa6597826c23eeff329778e35723b","gas":"0x223260","gasUsed":"0x223260","to":"0x0000000000000000000000000000000000000000", ...

Steps to reproduce the behaviour

curl http://localhost:8550/ -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0x57be14ec39ab53a838d8a58ebc0967ada7b9af6f6dc923b7c5c816bd41261142",{"disableMemory":true,"disableStack":true,"disableStorage":true,"enableReturnData":false,"tracer":"callTracer","tracerConfig":{"onlyTopCall":false,"withLog":true}}],"id":1}'

Possible solution

Update https://github.com/gateway-fm/cdk-erigon-lib adding this patch that I have created before: https://github.com/gateway-fm/cdk-erigon-lib/pull/5

raulpuente commented 1 month ago

Are someone looking into this issue? It is important for us.

Thank you

indanielo commented 1 month ago

Can you please take a look at this issue? Basically, what's happening is that the RPCs are not working as they should because some database buckets don't exist when the datadir is passed, and the system is using the local database. If the connection is remote via protobuf, then there's no issue because the database is properly initialized. I understand this is a very serious problem that affects anyone working with RPC on the same machine as the node, since the speed is significantly faster. Thank you.

indanielo commented 3 weeks ago

I checked your latest version, v1.2.15.7, and noticed that even though you updated the github.com/gateway-fm/cdk-erigon-lib library to version v0.0.0-20240805074757-5e3196248fde (5/8/2024), the issue still persists.

To resolve the problem, you need to incorporate the bucket changes introduced after commit c69f9871e8c9c1ca8f107270acf745e0623ca33c (29/8/2024). However, the current version of the library has additional buckets that prevent cdk-erigon from being properly initialized.

If needed, I've provided the necessary modifications to the library in the following link so you can use the latest version: Library Changes.

Currently, cdk breaks when starting with datadir, resulting in a lot of incorrect returned data.

V-Staykov commented 18 hours ago

@indanielo This should be fixed on latest version. Please retry and let me know. I just tested it and is fine on my side.