Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
fix: calculate block size correctly (#790)
Browse files Browse the repository at this point in the history
fixes #787
  • Loading branch information
davidmurdoch authored Feb 24, 2021
1 parent 6cdc207 commit c8af984
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/chains/ethereum/utils/src/things/runtime-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,15 @@ export class Block {
const deserialized = (rlpDecode(serialized) as any) as [
Buffer[],
Buffer[][],
Buffer[],
Buffer
];
this._raw = deserialized[0];
this._rawTransactions = deserialized[1];
const totalDifficulty = deserialized[2];
// TODO: support actual uncle data (needed for forking!)
// Issue: https://github.com/trufflesuite/ganache-core/issues/786
// const uncles = deserialized[1];
const totalDifficulty = deserialized[3];
this.header = makeHeader(this._raw, totalDifficulty);
this._size = getBlockSize(serialized, totalDifficulty);
}
Expand Down Expand Up @@ -220,9 +224,12 @@ export class RuntimeBlock {
Buffer.allocUnsafe(32).fill(0), // mixHash
Buffer.allocUnsafe(8).fill(0) // nonce
];
// TODO: support actual uncle data (needed for forking!)
// Issue: https://github.com/trufflesuite/ganache-core/issues/786
const uncles = [];
const { totalDifficulty } = header;
const rawTransactions = transactions.map(tx => tx.raw);
const raw = [rawHeader, rawTransactions, totalDifficulty];
const raw = [rawHeader, rawTransactions, uncles, totalDifficulty];

const serialized = rlpEncode(raw);

Expand Down

0 comments on commit c8af984

Please sign in to comment.