From 0f2dffbeed8a1087ec1f393d90b698992bb1b969 Mon Sep 17 00:00:00 2001 From: Karl Bartel Date: Mon, 10 Jul 2023 16:48:06 +0200 Subject: [PATCH] Update header hash calc in slashing test (#10397) * Using gasLimit in hash if present to make the slasher test work when gasLimit is added to the header in https://github.com/celo-org/celo-blockchain/pull/2062. This function will change again as part of https://github.com/celo-org/celo-blockchain-planning/issues/100. * Use constant header fields in hash if present Related to https://github.com/celo-org/celo-blockchain/pull/2124 * Update header hashing for eth compat Required to support both old headers and Eth-compatible headers. See https://github.com/celo-org/celo-blockchain-planning/issues/100 --- .../celotool/src/e2e-tests/slashing_tests.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/celotool/src/e2e-tests/slashing_tests.ts b/packages/celotool/src/e2e-tests/slashing_tests.ts index d6e3bcbd233..25303a7834e 100644 --- a/packages/celotool/src/e2e-tests/slashing_tests.ts +++ b/packages/celotool/src/e2e-tests/slashing_tests.ts @@ -18,17 +18,38 @@ const TMP_PATH = '/tmp/e2e' const safeMarginBlocks = 4 function headerArray(block: any) { + if (!block.nonce) { + // Before Gingerbread fork + return [ + block.parentHash, + block.miner, + block.stateRoot, + block.transactionsRoot, + block.receiptsRoot, + block.logsBloom, + block.number, + block.gasUsed, + block.timestamp, + block.extraData, + ] + } return [ block.parentHash, + block.sha3Uncles, block.miner, block.stateRoot, block.transactionsRoot, block.receiptsRoot, block.logsBloom, + new BigNumber(block.difficulty).toNumber(), block.number, + block.gasLimit, block.gasUsed, block.timestamp, block.extraData, + block.mixHash, + block.nonce, + block.baseFee, ] }