Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block: swap withdrawal/opts in constructor #2715

Merged
merged 7 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/block/src/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class Block {

const withdrawals = withdrawalsData?.map(Withdrawal.fromWithdrawalData)

return new Block(header, transactions, uncleHeaders, opts, withdrawals)
return new Block(header, transactions, uncleHeaders, withdrawals, opts)
}

/**
Expand Down Expand Up @@ -212,7 +212,7 @@ export class Block {
}))
?.map(Withdrawal.fromWithdrawalData)

return new Block(header, transactions, uncleHeaders, opts, withdrawals)
return new Block(header, transactions, uncleHeaders, withdrawals, opts)
}

/**
Expand Down Expand Up @@ -370,8 +370,8 @@ export class Block {
header?: BlockHeader,
transactions: TypedTransaction[] = [],
uncleHeaders: BlockHeader[] = [],
opts: BlockOptions = {},
withdrawals?: Withdrawal[]
withdrawals?: Withdrawal[],
opts: BlockOptions = {}
) {
this.header = header ?? BlockHeader.fromHeaderData({}, opts)
this._common = this.header._common
Expand Down
14 changes: 10 additions & 4 deletions packages/block/test/mergeBlock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tape('[Header]: Casper PoS / The Merge Functionality', function (t) {
const header = BlockHeader.fromHeaderData({}, { common })
validateMergeHeader(st, header)

const block = new Block(undefined, undefined, undefined, { common })
const block = new Block(undefined, undefined, undefined, undefined, { common })
validateMergeHeader(st, block.header)

st.end()
Expand Down Expand Up @@ -106,9 +106,15 @@ tape('[Header]: Casper PoS / The Merge Functionality', function (t) {

t.test('test that a PoS block with uncles cannot be produced', function (st) {
try {
new Block(undefined, undefined, [BlockHeader.fromHeaderData(undefined, { common })], {
common,
})
new Block(
undefined,
undefined,
[BlockHeader.fromHeaderData(undefined, { common })],
undefined,
{
common,
}
)
st.fail('should have thrown')
} catch (e: any) {
st.pass('should throw')
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain/src/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class Blockchain implements BlockchainInterface {
try {
const block =
item instanceof BlockHeader
? new Block(item, undefined, undefined, {
? new Block(item, undefined, undefined, undefined, {
common: item._common,
})
: item
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const generateConsecutiveBlock = (
}
)

const block = new Block(header, undefined, undefined, { common })
const block = new Block(header, undefined, undefined, undefined, { common })

return block
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/test/tester/runners/GeneralStateTestsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async function runTestCase(options: any, testData: any, t: tape.Test) {

// Have to create a blockchain with empty block as genesisBlock for Merge
// Otherwise mainnet genesis will throw since this has difficulty nonzero
const genesisBlock = new Block(undefined, undefined, undefined, { common })
const genesisBlock = new Block(undefined, undefined, undefined, undefined, { common })
const blockchain = await Blockchain.create({ genesisBlock, common })
const state = new Trie({ useKeyHashing: true })
const stateManager = new DefaultStateManager({
Expand Down