From 248fa5dc82902abc0bfb041598520153c658d1b0 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Wed, 17 Apr 2024 10:26:19 -0400 Subject: [PATCH] Added support for Firehose reader format 2.5 which will be required for `BSC 1.4.5+` --- CHANGELOG.md | 4 ++ codec/console_reader.go | 4 +- codec/console_reader_test.go | 1 + codec/testdata/firehose_format_2.5.dmlog | 4 ++ .../firehose_format_2.5.dmlog.golden.json | 58 +++++++++++++++++++ 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 codec/testdata/firehose_format_2.5.dmlog create mode 100755 codec/testdata/firehose_format_2.5.dmlog.golden.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c37a9b9..3785edc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). See [MAINTAINERS.md](./MAINTAINERS.md) for instructions to keep up to date. +## v2.4.6 + +* Added support for Firehose reader format 2.5 which will be required for `BSC 1.4.5+`. + ## v2.4.5 * Updated block model to add `BalanceChange#Reason.REWARD_BLOB_FEE` for BSC Tycho hard-fork. diff --git a/codec/console_reader.go b/codec/console_reader.go index bcabe2fe..731d9d1e 100644 --- a/codec/console_reader.go +++ b/codec/console_reader.go @@ -1147,7 +1147,7 @@ func (ctx *parseCtx) readInit(line string) error { ctx.normalizationFeatures.ReorderTransactionsAndRenumberOrdinals = true ctx.readTransactionIndex = true ctx.fhMajorVersion = 2 - case "2.4": + case "2.4", "2.5": ctx.blockVersion = 3 ctx.normalizationFeatures.ReorderTransactionsAndRenumberOrdinals = true ctx.readTransactionIndex = true @@ -1157,7 +1157,7 @@ func (ctx *parseCtx) readInit(line string) error { ctx.blockVersion = 3 ctx.fhMajorVersion = 3 default: - return fmt.Errorf("major version of Firehose exchange protocol is unsupported (expected: one of [2.0, 2.1, 2.2, 2.3, 2.4], found %s), you are most probably running an incompatible version of the Firehose instrumented 'geth' client", ctx.fhVersion) + return fmt.Errorf("major version of Firehose exchange protocol is unsupported (expected: one of [2.0, 2.1, 2.2, 2.3, 2.4, 2.5], found %s), you are most probably running an incompatible version of the Firehose instrumented 'geth' client", ctx.fhVersion) } // Firehose 3.0 tracer are outputing directly `pbbstream.Block` messages which means that to diff --git a/codec/console_reader_test.go b/codec/console_reader_test.go index 45d0933d..d51a7915 100644 --- a/codec/console_reader_test.go +++ b/codec/console_reader_test.go @@ -55,6 +55,7 @@ func TestParseFromFile(t *testing.T) { {"testdata/read_transaction_blob.dmlog", nil, nil, true}, {"testdata/read_transaction_blob_no_hashes.dmlog", nil, nil, true}, {"testdata/read_reward_blob_fee_balance_change.dmlog", nil, nil, true}, + {"testdata/firehose_format_2.5.dmlog", nil, nil, true}, {"testdata/system_call.dmlog", nil, nil, false}, {"testdata/polygon_calls_after_finalize.dmlog", nil, nil, false}, {"testdata/polygon_add_log_0.dmlog", nil, nil, false}, diff --git a/codec/testdata/firehose_format_2.5.dmlog b/codec/testdata/firehose_format_2.5.dmlog new file mode 100644 index 00000000..40b4aaa7 --- /dev/null +++ b/codec/testdata/firehose_format_2.5.dmlog @@ -0,0 +1,4 @@ +FIRE INIT 2.5 geth 1.10.17-dm-stable +FIRE BEGIN_APPLY_TRX 74b9554595faea99f11f5310c086acaec4686ef94b30466f966d67071b228b65 79f19a189068a79ec01343b8c70096114f048753 . 29 9b7b4ad21ac016e1766749e203d4776d351ac9c7d56cdd9b3c2d5b4f940c1f7e 5b08a942dbc15ff47f7f40d4519fe2e20948579b0baebaca66a7b651f6f483ed 966000 0ba43b7400 110 f93d3def0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004b7265616c79206c6f6e6720737472696e67206c6172676572207468616e20333220627974657320746f2074657374206f757420736f6c69646974792073706c697474696e67207374756666000000000000000000000000000000000000000000 0312345678901234567890123456789012345678900200000000000000000000000000000000000000000000000000000000000000ab00000000000000000000000000000000000000000000000000000000000000efabcdefabcdefabcdefabcdefabcdefabcdef0910001234567890123456789012345678901234567890010000000000000000000000000000000000000000000000000000000000000012 fe 56 3 1 0 99 ab 0174b9554595faea99f11f5310c086acaec4686ef94b30466f966d67071b228b65,0184b9554595faea99f11f5310c086acaec4686ef94b30466f966d67071b228b64 +FIRE TRX_FROM ab07a50ad459b41fe065f7bbab866d5390e9f705 +FIRE END_APPLY_TRX 23358 . 23358 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 11 0 0 [] diff --git a/codec/testdata/firehose_format_2.5.dmlog.golden.json b/codec/testdata/firehose_format_2.5.dmlog.golden.json new file mode 100755 index 00000000..ad9a212b --- /dev/null +++ b/codec/testdata/firehose_format_2.5.dmlog.golden.json @@ -0,0 +1,58 @@ +[ + { + "accessList": [ + { + "address": "1234567890123456789012345678901234567890", + "storageKeys": [ + "00000000000000000000000000000000000000000000000000000000000000ab", + "00000000000000000000000000000000000000000000000000000000000000ef" + ] + }, + { + "address": "abcdefabcdefabcdefabcdefabcdefabcdef0910" + }, + { + "address": "1234567890123456789012345678901234567890", + "storageKeys": [ + "0000000000000000000000000000000000000000000000000000000000000012" + ] + } + ], + "beginOrdinal": "1", + "blobGas": "99", + "blobGasFeeCap": "ab", + "blobHashes": [ + "0174b9554595faea99f11f5310c086acaec4686ef94b30466f966d67071b228b65", + "0184b9554595faea99f11f5310c086acaec4686ef94b30466f966d67071b228b64" + ], + "calls": [ + { + "address": "79f19a189068a79ec01343b8c70096114f048753", + "callType": "CALL", + "caller": "ab07a50ad459b41fe065f7bbab866d5390e9f705", + "index": 1 + } + ], + "endOrdinal": "11", + "from": "ab07a50ad459b41fe065f7bbab866d5390e9f705", + "gasLimit": "966000", + "gasPrice": "0ba43b7400", + "gasUsed": "23358", + "hash": "74b9554595faea99f11f5310c086acaec4686ef94b30466f966d67071b228b65", + "input": "f93d3def0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004b7265616c79206c6f6e6720737472696e67206c6172676572207468616e20333220627974657320746f2074657374206f757420736f6c69646974792073706c697474696e67207374756666000000000000000000000000000000000000000000", + "maxFeePerGas": "fe", + "maxPriorityFeePerGas": "56", + "nonce": "110", + "r": "9b7b4ad21ac016e1766749e203d4776d351ac9c7d56cdd9b3c2d5b4f940c1f7e", + "receipt": { + "blobGasPrice": "00", + "blobGasUsed": "0", + "cumulativeGasUsed": "23358", + "logsBloom": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + }, + "s": "5b08a942dbc15ff47f7f40d4519fe2e20948579b0baebaca66a7b651f6f483ed", + "to": "79f19a189068a79ec01343b8c70096114f048753", + "type": "TRX_TYPE_BLOB", + "v": "29" + } +] \ No newline at end of file