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

Rename consensusFormatValidationFlag #2209

Merged
merged 2 commits into from
Aug 23, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/block/src/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class BlockHeader {
)
}

const validateConsensusFormat = options.consensusFormatValidation ?? true
const skipValidateConsensusFormat = options.skipConsensusFormatValidation ?? false
const defaults = {
parentHash: zeros(32),
uncleHash: KECCAK256_RLP_ARRAY,
Expand Down Expand Up @@ -289,7 +289,7 @@ export class BlockHeader {
}

// Validate consensus format after block is sealed (if applicable) so extraData checks will pass
if (validateConsensusFormat === true) this._consensusFormatValidation()
if (skipValidateConsensusFormat === false) this._consensusFormatValidation()

const freeze = options?.freeze ?? true
if (freeze) {
Expand Down
4 changes: 2 additions & 2 deletions packages/block/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ export interface BlockOptions {
*/
cliqueSigner?: Buffer
/**
* Perform consensus validation checks on header if set. Defaults to true.
* Skip consensus format validation checks on header if set. Defaults to false.
*/
consensusFormatValidation?: boolean
skipConsensusFormatValidation?: boolean
}

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/block/test/header.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ tape('[Block]: Header functions', function (t) {
const extraData = Buffer.concat([Buffer.alloc(1)])

try {
BlockHeader.fromHeaderData({ extraData }, { common, consensusFormatValidation: false })
BlockHeader.fromHeaderData({ extraData }, { common, skipConsensusFormatValidation: true })
st.pass(
'should instantiate header with invalid extraData when consensusFormatValidation === false'
'should instantiate header with invalid extraData when skipConsensusFormatValidation === true'
)
} catch (error: any) {
st.fail('should not throw')
Expand Down Expand Up @@ -323,7 +323,6 @@ tape('[Block]: Header functions', function (t) {
(err: any) => err.message.includes('nonce must be 8 bytes'),
'contains nonce length error message'
)

st.end()
})
/*
Expand Down