Skip to content

Commit

Permalink
fix: calculate block size correctly (trufflesuite#790)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch authored and sam committed Apr 15, 2021
1 parent efeaf2b commit 59a20c3
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:/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:/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 59a20c3

Please sign in to comment.