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

fix: calculate block size correctly #790

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -82,11 +82,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 @@ -226,9 +230,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