0xPolygonHermez / cdk-erigon

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

[RPC] Method "zkevm_getBatchByNumber" not working when requesting against rpcdaemon on Cardona after update #698

Closed Damantino closed 2 weeks ago

Damantino commented 3 months ago

System information

output of git branch

* (HEAD detached at v1.1.5.3)
  zkevm

Config File

datadir: /path/to/my/cdk-erigon/datadir
chain: hermez-cardona
http: true
private.api.addr: localhost:9092
zkevm.l2-chain-id: 2442
zkevm.l2-sequencer-rpc-url: https://rpc.cardona.zkevm-rpc.com/
zkevm.l2-datastreamer-url: datastream.cardona.zkevm-rpc.com:6900
zkevm.l1-chain-id: 11155111
zkevm.l1-rpc-url: http://my-spolia-node.com:my-sepolia-port/

zkevm.address-sequencer: "0x761d53b47334bee6612c0bd1467fb881435375b2"
zkevm.address-zkevm: "0xA13Ddb14437A8F34897131367ad3ca78416d6bCa"
zkevm.address-admin: "0xff6250d0e86a2465b0c1bf8e36409503d6a26963"
zkevm.address-rollup: "0x32d33d5137a7cffb54c5bf8371172bcec5f310ff"
zkevm.address-ger-manager: "0xAd1490c248c5d3CbAE399Fd529b79B42984277DF"

zkevm.default-gas-price: 1
zkevm.max-gas-price: 0
zkevm.gas-price-factor: 0.12

zkevm.l1-rollup-id: 1
zkevm.l1-block-range: 20000
zkevm.l1-query-delay: 6000
zkevm.l1-first-block: 4789190
zkevm.rpc-ratelimit: 250
txpool.disable: true
torrent.port: 42070
zkevm.datastream-version: 2

externalcl: true
http.api: [eth, debug, net, trace, web3, erigon, zkevm]
http.addr: 0.0.0.0
http.vhosts: any
http.corsdomain: any
ws: true

Erigon Command (with flags/config):

./build/bin/cdk-erigon --config="/mnt/ethereum/cdk-erigon/hermezconfig-cardona.yaml" --ws

Erigon RPC

./build/bin/rpcdaemon --datadir=/path/to/cdk-erigon/data --txpool.api.addr=localhost:9092 --private.api.addr=localhost:9092 --http.api=eth,erigon,web3,net,debug,trace,txpool,zkevm --ws --ws.compression

Expected behaviour

When I curl to get batch info it gets delivered.

> curl --request POST      --url http://localhost:8545/    --header 'accept: application/json'      --header 'content-type: application/json'      --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "zkevm_getBatchByNumber",
  "params": [
    "103195"
  ]
}
'
< {"jsonrpc":"2.0","id":1,"result":"The batch info"}

Actual behaviour

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": null
}

Steps to reproduce the behaviour

  1. Launch node, wait until synchronises
  2. Build rpcdaemon
  3. Launch rpcdaemon
  4. Launch petition

Backtrace

When I curl against the node it returns the correct response

> curl --request POST      --url http://localhost:8550/    --header 'accept: application/json'      --header 'content-type: application/json'      --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "zkevm_getBatchByNumber",
  "params": [
    "103195"
  ]
}

< {"jsonrpc":"2.0","id":1,"result":"batch info"}

The issue I posted on #680 carries on on Cardona aswell with latest version and sequencer updated. It seems to be a misalignment on method SeekExact at kv_mdbx.go specifically at

                 k, v, err := c.set(key)
                if err != nil {
           if mdbx.IsNotFound(err) {
            return nil, nil, nil
           }
           return []byte{}, nil, err
           }

When called on rpc inside set fn, getVal1 on cursor.go holds diferent values.

// getVal1 retrieves items from the database using key data for reference
// (Set, SetRange, etc).
//
// See mdb_cursor_get.
func (c *Cursor) getVal1(setkey []byte, op uint) error {
    var k *C.char
    if len(setkey) > 0 {
        k = (*C.char)(unsafe.Pointer(&setkey[0]))
    }
    ret := C.mdbxgo_cursor_get1( <--- Here holds diferent values
        c._c,
        k, C.size_t(len(setkey)),
        c.txn.key,
        c.txn.val,
        C.MDBX_cursor_op(op),
    )
    return operrno("mdbx_cursor_get", ret)
}
raulpuente commented 3 months ago

Is there no more information about this topic?