Skip to content

Commit

Permalink
Update header hash calc in slashing test (#10397)
Browse files Browse the repository at this point in the history
* Using gasLimit in hash if present

to make the slasher test work when gasLimit is added to the header in
celo-org/celo-blockchain#2062. This function
will change again as part of
celo-org/celo-blockchain-planning#100.

* Use constant header fields in hash if present

Related to celo-org/celo-blockchain#2124

* Update header hashing for eth compat

Required to support both old headers and Eth-compatible headers.
See celo-org/celo-blockchain-planning#100
  • Loading branch information
karlb committed Jul 10, 2023
1 parent 0ed8544 commit 0f2dffb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/celotool/src/e2e-tests/slashing_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
}

Expand Down

0 comments on commit 0f2dffb

Please sign in to comment.