alexhooketh / blobs-toolkit

Small scripts related to blobs & rollups using them
3 stars 2 forks source link

Script is not working anymore #2

Open PabloCastellano opened 2 weeks ago

PabloCastellano commented 2 weeks ago

Hello. At blobscan we're interested in displaying decoded data for Optimism blobs. Your script is very useful to understand how the decoding works. However I've been doing some tests and it doesn't work anymore.

This seems to be related to the Fjord network upgrade last July 10th 2024.

I have uploaded some scripts I have used in our fork that you might find useful.

So for the example transaction:

$ poetry run ./retrieve_blob.py 0x353c6f31903147f8d490c28e556caafd7a9fad8b3bc4fd210ae800ee24749adb
Transaction contains 6 blobs
Retrieving blob index=0 0x01cd867a4f2a376316434be31f33383accc04c99ba1c422de69ecd5a445cc428
Retrieving blob index=1 0x01ded5b35b631958007efe3913758a25c2ec2bbdcf22d90fcffe5b82b050cb2d
Retrieving blob index=2 0x017f3a05e20c6e57496c9fbbf323f92d4ae11c9bcb2e3994ec0099125b0a846f
Retrieving blob index=3 0x01a415aebb34ef9b50c4135703ca35a0a84965d26744aabe2911b80969cbc04e
Retrieving blob index=4 0x01640c5ed5927238e025f53c9a93247104f9fc942f0ea3ae7af2cec20e0a2874
Retrieving blob index=5 0x0163254cc46bb45c98ac199957c5228fbc3210a5456577a9e4c12491b61ca424
Written 0x353c6f31903147f8d490c28e556caafd7a9fad8b3bc4fd210ae800ee24749adb.blob
$ poetry run ./decode_opstack_blob.py 0x353c6f31903147f8d490c28e556caafd7a9fad8b3bc4fd210ae800ee24749adb.blob
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 128609
remaining data bytes: 130043
channel: 1405357279b77226a3260d3fe227fb8a
frame num: 0
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 1405357279b77226a3260d3fe227fb8a
frame num: 1
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 1405357279b77226a3260d3fe227fb8a
frame num: 2
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 1405357279b77226a3260d3fe227fb8a
frame num: 3
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 1405357279b77226a3260d3fe227fb8a
frame num: 4
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 128608
channel: 1405357279b77226a3260d3fe227fb8a
frame num: 5
frame data length: 128585
is_last: b'\x01'
result of 2155075 bytes: 01f4e09c0cd3c7a80904f77f137bf3d52e7fe827254134b0540bc9206e297e7aabd7deb7db3475f56dcecf3bb3dca6aefb8a...

timestamp since L2 genesis: 25636980
last L1 origin number: 19538899
parent L2 block hash: 04f77f137bf3d52e7fe827254134b0540bc9206e
L1 origin block hash: 297e7aabd7deb7db3475f56dcecf3bb3dca6aefb
number of L2 blocks: 138
how many were changed by L1 origin: 22
total txs: 2713
contract creation txs number: 0
legacy txs number: 669
total gas limit in txs: 2589220470
number of EIP-155 protected legacy txs: 666

This worked, decode_opstack_blob.py ended correctly.

However for the latest Optimism transaction:

$ poetry run ./retrieve_blob.py 0x8211875011c456e5f21b0fb945aa83e1e09f0d303648ea1f67ba634871e85715
Transaction contains 5 blobs
Retrieving blob index=0 0x01ea25dcf654a55c5207dc93f34b394e1c967134ea7f3a6eb1eb2f0e0e87c3ad
Retrieving blob index=1 0x01341ad92f71bff77e4ad87c79765edfec08877fd0c2a097bba37de80ac43907
Retrieving blob index=2 0x012aad14097e47d78253d776033d7c163af97484c52f24627dd3f0706fdb7281
Retrieving blob index=3 0x013abd3c47a87b1250b90f6aa028c6f57af481dbebfad3dd50f1a190b924087c
Retrieving blob index=4 0x01a1260e130cfd1834323762d8646b0da0e92f686e1af16c066b3fac939c359f
Written 0x8211875011c456e5f21b0fb945aa83e1e09f0d303648ea1f67ba634871e85715.blob
$ poetry run ./decode_opstack_blob.py 0x8211875011c456e5f21b0fb945aa83e1e09f0d303648ea1f67ba634871e85715.blob
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 128392
remaining data bytes: 130043
channel: 48b71f59c880310a3d1fb1b10cbea189
frame num: 0
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 48b71f59c880310a3d1fb1b10cbea189
frame num: 1
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 48b71f59c880310a3d1fb1b10cbea189
frame num: 2
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 48b71f59c880310a3d1fb1b10cbea189
frame num: 3
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 128391
channel: 48b71f59c880310a3d1fb1b10cbea189
frame num: 4
frame data length: 128368
is_last: b'\x01'
Traceback (most recent call last):
  File "./decode_opstack_blob.py", line 98, in <module>
    result = rlp.decode(decomp.decompress(channel))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
zlib.error: Error -3 while decompressing data: incorrect header check

For other transactions:

$ ./retrieve_and_decode.sh  0xa679e7d0f7f8646638863a4e5e5f8305b9cf897ad26873b8245dc3150192a6eb
Transaction contains 5 blobs
Retrieving blob index=0 0x016a21b10a8c854a8766148a1c179b985a7a2669e1847af76e4f6b7cfd738b2c
Retrieving blob index=1 0x01b9c7ee82b4c489b24b00fbda29f90efffe96621add85ed0da4e155373512ae
Retrieving blob index=2 0x0196e959df6d8c82ff70003614ae730b1ba9cfedc98a47fee5fcbcd5969de104
Retrieving blob index=3 0x01592fa4163588afe1f7503cec9f05c200ee3b49cb2aac10b6b98edab1c63dc4
Retrieving blob index=4 0x01b7f07d10ff2f1cd0b0056e761a69f7876c4d411d09d9b13d841dfff3f32a50
Written 0xa679e7d0f7f8646638863a4e5e5f8305b9cf897ad26873b8245dc3150192a6eb.blob
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 130044
found version 0 blob, declared length: 126577
remaining data bytes: 130043
channel: 63652893616d0412730e49b5614d3bef
frame num: 0
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 63652893616d0412730e49b5614d3bef
frame num: 1
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 63652893616d0412730e49b5614d3bef
frame num: 2
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 130043
channel: 63652893616d0412730e49b5614d3bef
frame num: 3
frame data length: 130020
is_last: b'\x00'
remaining data bytes: 126576
channel: 63652893616d0412730e49b5614d3bef
frame num: 4
frame data length: 126553
is_last: b'\x01'
result of 1748764 bytes: 01b296b710cb8ed50988b3200b58b6cda7bfb1d99e003ab9e920cd1041711be1221f1f330bad8fb8fa1cab9895023307fa6e...

timestamp since L2 genesis: 34458418
last L1 origin number: 20268875
parent L2 block hash: 88b3200b58b6cda7bfb1d99e003ab9e920cd1041
L1 origin block hash: 711be1221f1f330bad8fb8fa1cab9895023307fa
number of L2 blocks: 110
how many were changed by L1 origin: 18
total txs: 1923
contract creation txs number: 1
Traceback (most recent call last):
  File "./decode_opstack_blob.py", line 118, in <module>
    assert sum([int.from_bytes(to) == 0 for to in tx_tos]) == contract_creation_txs_number
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
alexhooketh commented 2 weeks ago

Hey @PabloCastellano! Thanks for the report. This script was made for my very old article, and I didn't really update it since then.

I believe it might have something to do with new OP Stack's compression or just the fact that my script is unflexible af haha. I'll add a note in the README that the script is not updated. Or, if you want, you can create a PR and I'd happily merge it.

PabloCastellano commented 2 weeks ago

After some more investigation this seems to be related to the Fjord network upgrade last July 10th 2024.

@alexhooketh Thanks for answering! I will try to fix it.