optimism icon indicating copy to clipboard operation
optimism copied to clipboard

L2geth BatchIndex & L1TxHash

Open artjoma opened this issue 3 years ago • 5 comments

L2 geth: 0.5.27 Different BatchIndex and L1Hash fields: https://optimistic.etherscan.io/tx/0x9010e5b4e8e4b818ee05fdf35c59cfdc0b665187082b102d7557ec312930f99f https://www.oklink.com/en/optimism/tx/0x9010e5b4e8e4b818ee05fdf35c59cfdc0b665187082b102d7557ec312930f99f

Using L2Geth internal API

meta := rawdb.ReadTransactionMeta(api.eth.chainDb, block.Header().Number.Uint64())
rawTx, err := api.eth.syncService.GetClient().GetRawTransaction(*meta.Index, api.eth.syncService.GetBackend())
log.Info("L1Block", "n", rawTx.Batch.BlockNumber) // 15945350
log.Info("Batch", "i", rawTx.Batch.Index) //271065

Where I can get correct BatchIndex & L1BlockNumber using L2Geth internal API ?

artjoma avatar Nov 15 '22 12:11 artjoma

I'm not sure if either of these are accessible inside L2Geth, cc @tynes?

smartcontracts avatar Nov 15 '22 22:11 smartcontracts

Try using block.number - 1 since there are not any transactions in the genesis block

tynes avatar Nov 15 '22 22:11 tynes

@tynes why this logic woks till 16200000 block number? After incorrect batch number. Looks very strange.

meta := rawdb.ReadTransactionMeta(api.eth.chainDb, block.Header().Number.Uint64())
rawTx, err := api.eth.syncService.GetClient().GetRawTransaction(*meta.Index, api.eth.syncService.GetBackend())
log.Info("L1Block", "n", rawTx.Batch.BlockNumber) // 15945350
log.Info("Batch", "i", rawTx.Batch.Index)  //271065

artjoma avatar Nov 16 '22 07:11 artjoma

curl -s http://0.0.0.0:7878/batch/transaction/index/271065?backend=l1|jq > out.log Has transaction input:

    {
      "index": 37000008,
      "batchIndex": 271065,
      "blockNumber": 15945298,
      "timestamp": 1668152471,
      "gasLimit": "0",
      "target": "0x0000000000000000000000000000000000000000",
      "origin": null,
      "data": "0xf903094e830f42408302bb0d9469dd38645f7457be13571a847ffd905f9acbaf6d80b902a4f17a454600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000001fb1cf07000000000000000000000000000000000000000000000000000000001f60abad000000000000000000000000d4a2269719276313aa6ab7b01f91d238eba96433000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000da10009cbd5d07dd0cecc66161fc93d7c9000da100000000000000000000000000000000000000000000001cd6fbad57dbd00000000000000000000000000000d4a2269719276313aa6ab7b01f91d238eba964330000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316070000000000000000000000000000000000000000000000000000000000000001000000000000000000000000abc6080b807feed53e22203caae04ccc4c7087dc0000000000000000000000000000000000000000000000000000000000000048010203000d0101010200ff000000000000000000000000000000000000000000427464d9434f99a3d942c60210ee2376166975ceda10009cbd5d07dd0cecc66161fc93d7c9000da100000000000000000000000000000000000000000000000037a0e35055dbfd6c58d60f83c145bcf62509f7a248ba642951b25d856ad7c005f233a0479d357a42894a55f1dec8ddc82d300508ee2de31ce4faadd5d76df249ea98ae",
      "queueOrigin": "sequencer",
      "value": "0x0",
      "queueIndex": null,
      "decoded": {
        "nonce": "78",
        "gasPrice": "1000000",
        "gasLimit": "178957",
        "value": "0x0",
        "target": "0x69dd38645f7457be13571a847ffd905f9acbaf6d",
        "data": "0xf17a454600000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000001fb1cf07000000000000000000000000000000000000000000000000000000001f60abad000000000000000000000000d4a2269719276313aa6ab7b01f91d238eba96433000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000da10009cbd5d07dd0cecc66161fc93d7c9000da100000000000000000000000000000000000000000000001cd6fbad57dbd00000000000000000000000000000d4a2269719276313aa6ab7b01f91d238eba964330000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316070000000000000000000000000000000000000000000000000000000000000001000000000000000000000000abc6080b807feed53e22203caae04ccc4c7087dc0000000000000000000000000000000000000000000000000000000000000048010203000d0101010200ff000000000000000000000000000000000000000000427464d9434f99a3d942c60210ee2376166975ceda10009cbd5d07dd0cecc66161fc93d7c9000da1000000000000000000000000000000000000000000000000",
        "sig": {
          "v": 0,
          "r": "0xe35055dbfd6c58d60f83c145bcf62509f7a248ba642951b25d856ad7c005f233",
          "s": "0x479d357a42894a55f1dec8ddc82d300508ee2de31ce4faadd5d76df249ea98ae"
        }
      },
      "confirmed": true
    },
    

Batch 271067 not.

artjoma avatar Nov 16 '22 11:11 artjoma

@smartcontracts ^^^

artjoma avatar Nov 22 '22 10:11 artjoma