From a714ba83d9352447ac24ddaa5ad3408910490d1c Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Thu, 28 May 2026 21:32:23 -0700 Subject: [PATCH] Add support for Tempo T4 --- calculate.js | 7 +++++++ calculate.test.js | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/calculate.js b/calculate.js index dca0e42..daf1ae2 100644 --- a/calculate.js +++ b/calculate.js @@ -96,6 +96,13 @@ function calculate(block) { ]; } + // Tempo T4 + // https://github.com/tempoxyz/tempo/blob/main/tips/tip-1031.md + if (block?.consensusContext) { + const { epoch, view, parentView, proposer } = block.consensusContext; + header.push([epoch, view, parentView, proposer]); + } + const rlp = RLP.encode(header); const hash = keccak256(rlp); diff --git a/calculate.test.js b/calculate.test.js index e6611ac..2d6b213 100644 --- a/calculate.test.js +++ b/calculate.test.js @@ -1582,4 +1582,45 @@ suite('Tempo', { concurrency: true }, () => { }); deepStrictEqual(hash, '0x6599e1fe537ebf615f53225bc33069c3023184a5d4bc223855308d974e3927f8'); }); + + test('Block number 22474189 (T4)', { concurrency: true }, () => { + const { hash } = calculate({ + "mainBlockGeneralGasLimit": "0x1c9c380", + "sharedGasLimit": "0x0", + "timestampMillisPart": "0x241", + "parentHash": "0x33c637371efa8fb4245a2524824be7c7c0ffd8fac5571abce52e258742ba8ac6", + "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", + "miner": "0xeb2359cfe9f3f8afd7dcc140c2500ab348406dcc", + "stateRoot": "0x00781f66933bec6248e3cc07bbeb4819104ce26d6956043d07a1fe9d93add3ab", + "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "difficulty": "0x0", + "number": "0x156edcd", + "gasLimit": "0x1dcd6500", + "gasUsed": "0x0", + "timestamp": "0x6a1914f2", + "extraData": "0x", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "nonce": "0x0000000000000000", + "baseFeePerGas": "0x4a817c800", + "withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "blobGasUsed": "0x0", + "excessBlobGas": "0x0", + "parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000", + "requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "consensusContext": { + "epoch": 1040, + "view": 10190, + "parentView": 10189, + "proposer": "0x82bb74d4a1461bbc72bfdb6988f47fac5e21c36d33c6d84a72e3edf8995d4316" + }, + "size": "0x2a4", + "timestampMillis": "0x19e71f9d391", + "uncles": [], + "transactions": [], + "withdrawals": [] + }); + deepStrictEqual(hash, '0xc8fffc6d30293207eed42bcc2816dac0219bcbe87deeb95b92ad7801551cd8d7'); + }); }); -- 2.47.3