Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethereumjs/block

Package Overview
Dependencies
Maintainers
3
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/block - npm Package Compare versions

Comparing version 3.5.1 to 3.6.0

18

dist.browser/block.d.ts

@@ -150,9 +150,2 @@ /// <reference types="node" />

/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_error(msg: string): Error;
/**
* The following rules are checked in this method:

@@ -168,2 +161,13 @@ * Uncle Header is a valid header.

private _getBlockByHash;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string): string;
}

@@ -105,6 +105,8 @@ "use strict";

if (this._common.consensusType() === common_1.ConsensusType.ProofOfAuthority) {
throw new Error('Block initialization with uncleHeaders on a PoA network is not allowed');
var msg = this._errorMsg('Block initialization with uncleHeaders on a PoA network is not allowed');
throw new Error(msg);
}
if (this._common.consensusType() === common_1.ConsensusType.ProofOfStake) {
throw new Error('Block initialization with uncleHeaders on a PoS network is not allowed');
var msg = this._errorMsg('Block initialization with uncleHeaders on a PoS network is not allowed');
throw new Error(msg);
}

@@ -152,6 +154,5 @@ }

// Disable this option here (all other options carried over), since this overwrites the provided Difficulty to an incorrect value
calcDifficultyFromHeader: undefined });
if (uncleOpts.hardforkByTD) {
delete uncleOpts.hardforkByBlockNumber;
}
calcDifficultyFromHeader: undefined,
// Uncles are obsolete post-merge (no use for hardforkByTD)
hardforkByTD: undefined });
try {

@@ -404,3 +405,3 @@ for (var _e = __values(uhsData !== null && uhsData !== void 0 ? uhsData : []), _f = _e.next(); !_f.done; _f = _e.next()) {

return __awaiter(this, void 0, void 0, function () {
var txErrors, msg, validateTxTrie;
var txErrors, msg, validateTxTrie, msg, msg;
return __generator(this, function (_a) {

@@ -411,6 +412,8 @@ switch (_a.label) {

if (txErrors.length > 0) {
msg = "invalid transactions: " + txErrors.join(' ');
throw this.header._error(msg);
msg = this._errorMsg("invalid transactions: " + txErrors.join(' '));
throw new Error(msg);
}
if (!!onlyHeader) return [3 /*break*/, 2];
if (onlyHeader) {
return [2 /*return*/];
}
return [4 /*yield*/, this.validateTransactionsTrie()];

@@ -420,9 +423,10 @@ case 1:

if (!validateTxTrie) {
throw new Error('invalid transaction trie');
msg = this._errorMsg('invalid transaction trie');
throw new Error(msg);
}
if (!this.validateUnclesHash()) {
throw new Error('invalid uncle hash');
msg = this._errorMsg('invalid uncle hash');
throw new Error(msg);
}
_a.label = 2;
case 2: return [2 /*return*/];
return [2 /*return*/];
}

@@ -457,3 +461,3 @@ });

return __awaiter(this, void 0, void 0, function () {
var uncleHashes;
var msg, uncleHashes, msg;
return __generator(this, function (_a) {

@@ -467,7 +471,9 @@ switch (_a.label) {

if (this.uncleHeaders.length > 2) {
throw new Error('too many uncle headers');
msg = this._errorMsg('too many uncle headers');
throw new Error(msg);
}
uncleHashes = this.uncleHeaders.map(function (header) { return header.hash().toString('hex'); });
if (!(new Set(uncleHashes).size === uncleHashes.length)) {
throw new Error('duplicate uncles');
msg = this._errorMsg('duplicate uncles');
throw new Error(msg);
}

@@ -518,11 +524,2 @@ return [4 /*yield*/, this._validateUncleHeaders(this.uncleHeaders, blockchain)];

/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
Block.prototype._error = function (msg) {
return this.header._error(msg);
};
/**
* The following rules are checked in this method:

@@ -538,3 +535,3 @@ * Uncle Header is a valid header.

return __awaiter(this, void 0, void 0, function () {
var canonicalBlockMap, lowestUncleNumber, canonicalChainHashes, includedUncles, getBlocks, parentHash, i, parentBlock;
var canonicalBlockMap, lowestUncleNumber, canonicalChainHashes, includedUncles, getBlocks, parentHash, i, parentBlock, msg;
var _this = this;

@@ -574,3 +571,4 @@ return __generator(this, function (_a) {

if (!parentBlock) {
throw new Error('could not find parent block');
msg = this._errorMsg('could not find parent block');
throw new Error(msg);
}

@@ -598,9 +596,12 @@ canonicalBlockMap.push(parentBlock);

if (!canonicalChainHashes[parentHash]) {
throw new Error('The parent hash of the uncle header is not part of the canonical chain');
var msg = _this._errorMsg('The parent hash of the uncle header is not part of the canonical chain');
throw new Error(msg);
}
if (includedUncles[uncleHash]) {
throw new Error('The uncle is already included in the canonical chain');
var msg = _this._errorMsg('The uncle is already included in the canonical chain');
throw new Error(msg);
}
if (canonicalChainHashes[uncleHash]) {
throw new Error('The uncle is a canonical block');
var msg = _this._errorMsg('The uncle is a canonical block');
throw new Error(msg);
}

@@ -638,2 +639,35 @@ });

};
/**
* Return a compact error string representation of the object
*/
Block.prototype.errorStr = function () {
var _a;
var hash = '';
try {
hash = (0, ethereumjs_util_1.bufferToHex)(this.hash());
}
catch (e) {
hash = 'error';
}
var hf = '';
try {
hf = this._common.hardfork();
}
catch (e) {
hf = 'error';
}
var errorStr = "block number=" + this.header.number + " hash=" + hash + " ";
errorStr += "hf=" + hf + " baseFeePerGas=" + ((_a = this.header.baseFeePerGas) !== null && _a !== void 0 ? _a : 'none') + " ";
errorStr += "txs=" + this.transactions.length + " uncles=" + this.uncleHeaders.length;
return errorStr;
};
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
Block.prototype._errorMsg = function (msg) {
return msg + " (" + this.errorStr() + ")";
};
return Block;

@@ -640,0 +674,0 @@ }());

@@ -12,9 +12,3 @@ "use strict";

function blockHeaderFromRpc(blockParams, options) {
var parentHash = blockParams.parentHash, sha3Uncles = blockParams.sha3Uncles, miner = blockParams.miner, stateRoot = blockParams.stateRoot, transactionsRoot = blockParams.transactionsRoot, receiptRoot = blockParams.receiptRoot, receiptsRoot = blockParams.receiptsRoot, logsBloom = blockParams.logsBloom, difficulty = blockParams.difficulty, number = blockParams.number, gasLimit = blockParams.gasLimit, gasUsed = blockParams.gasUsed, timestamp = blockParams.timestamp, extraData = blockParams.extraData, mixHash = blockParams.mixHash, nonce = blockParams.nonce;
var baseFeePerGas;
// Check if the field baseFeePerGas is present in the block.
// This field was introduced after: https://eips.ethereum.org/EIPS/eip-1559
if ('baseFeePerGas' in blockParams) {
baseFeePerGas = blockParams.baseFeePerGas;
}
var parentHash = blockParams.parentHash, sha3Uncles = blockParams.sha3Uncles, miner = blockParams.miner, stateRoot = blockParams.stateRoot, transactionsRoot = blockParams.transactionsRoot, receiptRoot = blockParams.receiptRoot, receiptsRoot = blockParams.receiptsRoot, logsBloom = blockParams.logsBloom, difficulty = blockParams.difficulty, number = blockParams.number, gasLimit = blockParams.gasLimit, gasUsed = blockParams.gasUsed, timestamp = blockParams.timestamp, extraData = blockParams.extraData, mixHash = blockParams.mixHash, nonce = blockParams.nonce, baseFeePerGas = blockParams.baseFeePerGas;
var blockHeader = header_1.BlockHeader.fromHeaderData({

@@ -27,3 +21,3 @@ parentHash: parentHash,

receiptTrie: receiptRoot || receiptsRoot,
bloom: logsBloom,
logsBloom: logsBloom,
difficulty: (0, helpers_1.numberToHex)(difficulty),

@@ -30,0 +24,0 @@ number: number,

@@ -16,3 +16,3 @@ /// <reference types="node" />

readonly receiptTrie: Buffer;
readonly bloom: Buffer;
readonly logsBloom: Buffer;
readonly difficulty: BN;

@@ -28,5 +28,10 @@ readonly number: BN;

readonly _common: Common;
_errorPostfix: string;
private cache;
/**
* Backwards compatible alias for {@link BlockHeader.logsBloom}
* (planned to be removed in next major release)
* @deprecated
*/
get bloom(): Buffer;
/**
* Static constructor to create a block header from a header data dictionary

@@ -63,3 +68,3 @@ *

*/
constructor(parentHash: Buffer, uncleHash: Buffer, coinbase: Address, stateRoot: Buffer, transactionsTrie: Buffer, receiptTrie: Buffer, bloom: Buffer, difficulty: BN, number: BN, gasLimit: BN, gasUsed: BN, timestamp: BN, extraData: Buffer, mixHash: Buffer, nonce: Buffer, options?: BlockOptions, baseFeePerGas?: BN);
constructor(parentHash: Buffer, uncleHash: Buffer, coinbase: Address, stateRoot: Buffer, transactionsTrie: Buffer, receiptTrie: Buffer, logsBloom: Buffer, difficulty: BN, number: BN, gasLimit: BN, gasUsed: BN, timestamp: BN, extraData: Buffer, mixHash: Buffer, nonce: Buffer, options?: BlockOptions, baseFeePerGas?: BN);
/**

@@ -181,3 +186,14 @@ * Validates correct buffer lengths, throws if invalid.

toJSON(): JsonHeader;
private _getHardfork;
private _getHeaderByHash;
/**
* Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
private _validateDAOExtraData;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message

@@ -188,10 +204,3 @@ *

*/
_error(msg: string): Error;
private _getHardfork;
private _getHeaderByHash;
/**
* Force extra data be DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
private _checkDAOExtraData;
protected _errorMsg(msg: string): string;
}

@@ -101,6 +101,5 @@ "use strict";

*/
function BlockHeader(parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, bloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, options, baseFeePerGas) {
function BlockHeader(parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, options, baseFeePerGas) {
if (options === void 0) { options = {}; }
var _a, _b;
this._errorPostfix = '';
this.cache = {

@@ -124,3 +123,3 @@ hash: undefined,

var hardforkByBlockNumber = (_a = options.hardforkByBlockNumber) !== null && _a !== void 0 ? _a : false;
if (hardforkByBlockNumber || options.hardforkByTD) {
if (hardforkByBlockNumber || options.hardforkByTD !== undefined) {
this._common.setHardforkByBlockNumber(number, options.hardforkByTD);

@@ -158,2 +157,6 @@ }

}
if (this._common.gteHardfork(common_1.Hardfork.London) &&
this._common.genesis().baseFeePerGas !== undefined) {
baseFeePerGas = new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(this._common.genesis().baseFeePerGas));
}
}

@@ -166,3 +169,3 @@ this.parentHash = parentHash;

this.receiptTrie = receiptTrie;
this.bloom = bloom;
this.logsBloom = logsBloom;
this.difficulty = difficulty;

@@ -178,3 +181,3 @@ this.number = number;

this._validateHeaderFields();
this._checkDAOExtraData();
this._validateDAOExtraData();
// Now we have set all the values of this Header, we possibly have set a dummy

@@ -197,3 +200,2 @@ // `difficulty` value (defaults to 0). If we have a `calcDifficultyFromHeader`

}
this._errorPostfix = "block number=" + this.number.toNumber() + " hash=" + this.hash().toString('hex');
var freeze = (_b = options === null || options === void 0 ? void 0 : options.freeze) !== null && _b !== void 0 ? _b : true;

@@ -204,2 +206,14 @@ if (freeze) {

}
Object.defineProperty(BlockHeader.prototype, "bloom", {
/**
* Backwards compatible alias for {@link BlockHeader.logsBloom}
* (planned to be removed in next major release)
* @deprecated
*/
get: function () {
return this.logsBloom;
},
enumerable: false,
configurable: true
});
/**

@@ -214,4 +228,11 @@ * Static constructor to create a block header from a header data dictionary

if (opts === void 0) { opts = {}; }
var parentHash = headerData.parentHash, uncleHash = headerData.uncleHash, coinbase = headerData.coinbase, stateRoot = headerData.stateRoot, transactionsTrie = headerData.transactionsTrie, receiptTrie = headerData.receiptTrie, bloom = headerData.bloom, difficulty = headerData.difficulty, number = headerData.number, gasLimit = headerData.gasLimit, gasUsed = headerData.gasUsed, timestamp = headerData.timestamp, extraData = headerData.extraData, mixHash = headerData.mixHash, nonce = headerData.nonce, baseFeePerGas = headerData.baseFeePerGas;
return new BlockHeader(parentHash ? (0, ethereumjs_util_1.toBuffer)(parentHash) : (0, ethereumjs_util_1.zeros)(32), uncleHash ? (0, ethereumjs_util_1.toBuffer)(uncleHash) : ethereumjs_util_1.KECCAK256_RLP_ARRAY, coinbase ? new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)) : ethereumjs_util_1.Address.zero(), stateRoot ? (0, ethereumjs_util_1.toBuffer)(stateRoot) : (0, ethereumjs_util_1.zeros)(32), transactionsTrie ? (0, ethereumjs_util_1.toBuffer)(transactionsTrie) : ethereumjs_util_1.KECCAK256_RLP, receiptTrie ? (0, ethereumjs_util_1.toBuffer)(receiptTrie) : ethereumjs_util_1.KECCAK256_RLP, bloom ? (0, ethereumjs_util_1.toBuffer)(bloom) : (0, ethereumjs_util_1.zeros)(256), difficulty ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)) : new ethereumjs_util_1.BN(0), number ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)) : new ethereumjs_util_1.BN(0), gasLimit ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)) : DEFAULT_GAS_LIMIT, gasUsed ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)) : new ethereumjs_util_1.BN(0), timestamp ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)) : new ethereumjs_util_1.BN(0), extraData ? (0, ethereumjs_util_1.toBuffer)(extraData) : Buffer.from([]), mixHash ? (0, ethereumjs_util_1.toBuffer)(mixHash) : (0, ethereumjs_util_1.zeros)(32), nonce ? (0, ethereumjs_util_1.toBuffer)(nonce) : (0, ethereumjs_util_1.zeros)(8), opts, baseFeePerGas !== undefined ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas)) : undefined);
if (headerData.logsBloom === undefined && headerData.bloom !== undefined) {
// backwards compatible alias for deprecated `bloom` key renamed to `logsBloom`
// (planned to be removed in next major release)
headerData.logsBloom = headerData.bloom;
}
var parentHash = headerData.parentHash, uncleHash = headerData.uncleHash, coinbase = headerData.coinbase, stateRoot = headerData.stateRoot, transactionsTrie = headerData.transactionsTrie, receiptTrie = headerData.receiptTrie, logsBloom = headerData.logsBloom, difficulty = headerData.difficulty, number = headerData.number, gasLimit = headerData.gasLimit, gasUsed = headerData.gasUsed, timestamp = headerData.timestamp, extraData = headerData.extraData, mixHash = headerData.mixHash, nonce = headerData.nonce, baseFeePerGas = headerData.baseFeePerGas;
return new BlockHeader(parentHash ? (0, ethereumjs_util_1.toBuffer)(parentHash) : (0, ethereumjs_util_1.zeros)(32), uncleHash ? (0, ethereumjs_util_1.toBuffer)(uncleHash) : ethereumjs_util_1.KECCAK256_RLP_ARRAY, coinbase ? new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)) : ethereumjs_util_1.Address.zero(), stateRoot ? (0, ethereumjs_util_1.toBuffer)(stateRoot) : (0, ethereumjs_util_1.zeros)(32), transactionsTrie ? (0, ethereumjs_util_1.toBuffer)(transactionsTrie) : ethereumjs_util_1.KECCAK256_RLP, receiptTrie ? (0, ethereumjs_util_1.toBuffer)(receiptTrie) : ethereumjs_util_1.KECCAK256_RLP, logsBloom ? (0, ethereumjs_util_1.toBuffer)(logsBloom) : (0, ethereumjs_util_1.zeros)(256), difficulty ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)) : new ethereumjs_util_1.BN(0), number ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)) : new ethereumjs_util_1.BN(0), gasLimit ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)) : DEFAULT_GAS_LIMIT, gasUsed ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)) : new ethereumjs_util_1.BN(0), timestamp ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)) : new ethereumjs_util_1.BN(0), extraData ? (0, ethereumjs_util_1.toBuffer)(extraData) : Buffer.from([]), mixHash ? (0, ethereumjs_util_1.toBuffer)(mixHash) : (0, ethereumjs_util_1.zeros)(32), nonce ? (0, ethereumjs_util_1.toBuffer)(nonce) : (0, ethereumjs_util_1.zeros)(8), opts, baseFeePerGas !== undefined && baseFeePerGas !== null
? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas))
: undefined);
};

@@ -240,3 +261,3 @@ /**

if (opts === void 0) { opts = {}; }
var _a = __read(values, 16), parentHash = _a[0], uncleHash = _a[1], coinbase = _a[2], stateRoot = _a[3], transactionsTrie = _a[4], receiptTrie = _a[5], bloom = _a[6], difficulty = _a[7], number = _a[8], gasLimit = _a[9], gasUsed = _a[10], timestamp = _a[11], extraData = _a[12], mixHash = _a[13], nonce = _a[14], baseFeePerGas = _a[15];
var _a = __read(values, 16), parentHash = _a[0], uncleHash = _a[1], coinbase = _a[2], stateRoot = _a[3], transactionsTrie = _a[4], receiptTrie = _a[5], logsBloom = _a[6], difficulty = _a[7], number = _a[8], gasLimit = _a[9], gasUsed = _a[10], timestamp = _a[11], extraData = _a[12], mixHash = _a[13], nonce = _a[14], baseFeePerGas = _a[15];
if (values.length > 16) {

@@ -248,3 +269,5 @@ throw new Error('invalid header. More values than expected were received');

}
return new BlockHeader((0, ethereumjs_util_1.toBuffer)(parentHash), (0, ethereumjs_util_1.toBuffer)(uncleHash), new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)), (0, ethereumjs_util_1.toBuffer)(stateRoot), (0, ethereumjs_util_1.toBuffer)(transactionsTrie), (0, ethereumjs_util_1.toBuffer)(receiptTrie), (0, ethereumjs_util_1.toBuffer)(bloom), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)), (0, ethereumjs_util_1.toBuffer)(extraData), (0, ethereumjs_util_1.toBuffer)(mixHash), (0, ethereumjs_util_1.toBuffer)(nonce), opts, baseFeePerGas !== undefined ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas)) : undefined);
return new BlockHeader((0, ethereumjs_util_1.toBuffer)(parentHash), (0, ethereumjs_util_1.toBuffer)(uncleHash), new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)), (0, ethereumjs_util_1.toBuffer)(stateRoot), (0, ethereumjs_util_1.toBuffer)(transactionsTrie), (0, ethereumjs_util_1.toBuffer)(receiptTrie), (0, ethereumjs_util_1.toBuffer)(logsBloom), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)), (0, ethereumjs_util_1.toBuffer)(extraData), (0, ethereumjs_util_1.toBuffer)(mixHash), (0, ethereumjs_util_1.toBuffer)(nonce), opts, baseFeePerGas !== undefined && baseFeePerGas !== null
? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas))
: undefined);
};

@@ -263,17 +286,24 @@ /**

BlockHeader.prototype._validateHeaderFields = function () {
var _a = this, parentHash = _a.parentHash, uncleHash = _a.uncleHash, stateRoot = _a.stateRoot, transactionsTrie = _a.transactionsTrie, receiptTrie = _a.receiptTrie, difficulty = _a.difficulty, extraData = _a.extraData, mixHash = _a.mixHash, nonce = _a.nonce;
var _a = this, parentHash = _a.parentHash, uncleHash = _a.uncleHash, stateRoot = _a.stateRoot, transactionsTrie = _a.transactionsTrie, receiptTrie = _a.receiptTrie, difficulty = _a.difficulty,
// extraData,
mixHash = _a.mixHash, nonce = _a.nonce;
if (parentHash.length !== 32) {
throw new Error("parentHash must be 32 bytes, received " + parentHash.length + " bytes");
var msg = this._errorMsg("parentHash must be 32 bytes, received " + parentHash.length + " bytes");
throw new Error(msg);
}
if (stateRoot.length !== 32) {
throw new Error("stateRoot must be 32 bytes, received " + stateRoot.length + " bytes");
var msg = this._errorMsg("stateRoot must be 32 bytes, received " + stateRoot.length + " bytes");
throw new Error(msg);
}
if (transactionsTrie.length !== 32) {
throw new Error("transactionsTrie must be 32 bytes, received " + transactionsTrie.length + " bytes");
var msg = this._errorMsg("transactionsTrie must be 32 bytes, received " + transactionsTrie.length + " bytes");
throw new Error(msg);
}
if (receiptTrie.length !== 32) {
throw new Error("receiptTrie must be 32 bytes, received " + receiptTrie.length + " bytes");
var msg = this._errorMsg("receiptTrie must be 32 bytes, received " + receiptTrie.length + " bytes");
throw new Error(msg);
}
if (mixHash.length !== 32) {
throw new Error("mixHash must be 32 bytes, received " + mixHash.length + " bytes");
var msg = this._errorMsg("mixHash must be 32 bytes, received " + mixHash.length + " bytes");
throw new Error(msg);
}

@@ -284,7 +314,9 @@ if (nonce.length !== 8) {

if (nonce.length !== 65) {
throw new Error("nonce must be 65 bytes on kovan, received " + nonce.length + " bytes");
var msg = this._errorMsg("nonce must be 65 bytes on kovan, received " + nonce.length + " bytes");
throw new Error(msg);
}
}
else {
throw new Error("nonce must be 8 bytes, received " + nonce.length + " bytes");
var msg = this._errorMsg("nonce must be 8 bytes, received " + nonce.length + " bytes");
throw new Error(msg);
}

@@ -304,6 +336,8 @@ }

}
if (!extraData.equals(Buffer.from([]))) {
errorMsg += ", extraData: " + extraData.toString('hex') + " (expected: '')";
error = true;
}
// WIP from merge interop event:
// extraData behavior pending consideration, for now allowed to be non-empty
// if (!extraData.equals(Buffer.from([]))) {
// errorMsg += `, extraData: ${extraData.toString('hex')} (expected: '')`
// error = true
// }
if (!mixHash.equals((0, ethereumjs_util_1.zeros)(32))) {

@@ -318,3 +352,4 @@ errorMsg += ", mixHash: " + mixHash.toString('hex') + " (expected: " + (0, ethereumjs_util_1.zeros)(32).toString('hex') + ")";

if (error) {
throw new Error('Invalid PoS block' + errorMsg);
var msg = this._errorMsg("Invalid PoS block" + errorMsg);
throw new Error(msg);
}

@@ -330,6 +365,8 @@ }

if (this._common.consensusType() !== common_1.ConsensusType.ProofOfWork) {
throw new Error('difficulty calculation is only supported on PoW chains');
var msg = this._errorMsg('difficulty calculation is only supported on PoW chains');
throw new Error(msg);
}
if (this._common.consensusAlgorithm() !== common_1.ConsensusAlgorithm.Ethash) {
throw new Error('difficulty calculation currently only supports the ethash algorithm');
var msg = this._errorMsg('difficulty calculation currently only supports the ethash algorithm');
throw new Error(msg);
}

@@ -406,6 +443,8 @@ var hardfork = this._getHardfork();

if (!this.difficulty.eq(clique_1.CLIQUE_DIFF_INTURN) && !this.difficulty.eq(clique_1.CLIQUE_DIFF_NOTURN)) {
throw new Error("difficulty for clique block must be INTURN (2) or NOTURN (1), received: " + this.difficulty.toString());
var msg = this._errorMsg("difficulty for clique block must be INTURN (2) or NOTURN (1), received: " + this.difficulty);
throw new Error(msg);
}
if ('cliqueActiveSigners' in blockchain === false) {
throw new Error('PoA blockchain requires method blockchain.cliqueActiveSigners() to validate clique difficulty');
var msg = this._errorMsg('PoA blockchain requires method blockchain.cliqueActiveSigners() to validate clique difficulty');
throw new Error(msg);
}

@@ -469,3 +508,3 @@ var signers = blockchain.cliqueActiveSigners();

return __awaiter(this, void 0, void 0, function () {
var hardfork, msg, minLength, msg, signerLength, msg, msg, msg, msg, parentHeader, number, period, dif, block, isInitialEIP1559Block, initialBaseFee, expectedBaseFee;
var hardfork, msg, minLength, msg, signerLength, msg, msg, msg, msg, parentHeader, msg, number, msg, msg, period, msg, msg, msg, dif, msg, msg, msg, block, isInitialEIP1559Block, initialBaseFee, msg, expectedBaseFee, msg;
return __generator(this, function (_a) {

@@ -482,4 +521,4 @@ switch (_a.label) {

if (this.extraData.length > this._common.paramByHardfork('vm', 'maxExtraDataSize', hardfork)) {
msg = 'invalid amount of extra data';
throw this._error(msg);
msg = this._errorMsg('invalid amount of extra data');
throw new Error(msg);
}

@@ -492,4 +531,4 @@ }

if (this.extraData.length !== minLength) {
msg = "extraData must be " + minLength + " bytes on non-epoch transition blocks, received " + this.extraData.length + " bytes";
throw this._error(msg);
msg = this._errorMsg("extraData must be " + minLength + " bytes on non-epoch transition blocks, received " + this.extraData.length + " bytes");
throw new Error(msg);
}

@@ -500,9 +539,9 @@ }

if (signerLength % 20 !== 0) {
msg = "invalid signer list length in extraData, received signer length of " + signerLength + " (not divisible by 20)";
throw this._error(msg);
msg = this._errorMsg("invalid signer list length in extraData, received signer length of " + signerLength + " (not divisible by 20)");
throw new Error(msg);
}
// coinbase (beneficiary) on epoch transition
if (!this.coinbase.isZero()) {
msg = "coinbase must be filled with zeros on epoch transition blocks, received " + this.coinbase.toString();
throw this._error(msg);
msg = this._errorMsg("coinbase must be filled with zeros on epoch transition blocks, received " + this.coinbase);
throw new Error(msg);
}

@@ -512,8 +551,8 @@ }

if (!this.mixHash.equals(Buffer.alloc(32))) {
msg = "mixHash must be filled with zeros, received " + this.mixHash;
throw this._error(msg);
msg = this._errorMsg("mixHash must be filled with zeros, received " + this.mixHash);
throw new Error(msg);
}
if (!this.validateCliqueDifficulty(blockchain)) {
msg = "invalid clique difficulty";
throw this._error(msg);
msg = this._errorMsg("invalid clique difficulty");
throw new Error(msg);
}

@@ -525,10 +564,13 @@ }

if (!parentHeader) {
throw new Error('could not find parent header');
msg = this._errorMsg('could not find parent header');
throw new Error(msg);
}
number = this.number;
if (!number.eq(parentHeader.number.addn(1))) {
throw new Error('invalid number');
msg = this._errorMsg('invalid number');
throw new Error(msg);
}
if (this.timestamp.lte(parentHeader.timestamp)) {
throw new Error('invalid timestamp');
msg = this._errorMsg('invalid timestamp');
throw new Error(msg);
}

@@ -539,3 +581,4 @@ if (this._common.consensusAlgorithm() === common_1.ConsensusAlgorithm.Clique) {

if (parentHeader.timestamp.addn(period).gt(this.timestamp)) {
throw new Error('invalid timestamp diff (lower than period)');
msg = this._errorMsg('invalid timestamp diff (lower than period)');
throw new Error(msg);
}

@@ -545,7 +588,9 @@ }

if (!this.validateDifficulty(parentHeader)) {
throw new Error('invalid difficulty');
msg = this._errorMsg('invalid difficulty');
throw new Error(msg);
}
}
if (!this.validateGasLimit(parentHeader)) {
throw new Error('invalid gas limit');
msg = this._errorMsg('invalid gas limit');
throw new Error(msg);
}

@@ -555,3 +600,4 @@ if (height) {

if (!(dif.ltn(8) && dif.gtn(1))) {
throw new Error('uncle block has a parent that is too old or too young');
msg = this._errorMsg('uncle block has a parent that is too old or too young');
throw new Error(msg);
}

@@ -561,7 +607,9 @@ }

if (this.gasUsed.gt(this.gasLimit)) {
throw new Error('Invalid block: too much gas used');
msg = this._errorMsg('Invalid block: too much gas used');
throw new Error(msg);
}
if (this._common.isActivatedEIP(1559)) {
if (!this.baseFeePerGas) {
throw new Error('EIP1559 block has no base fee field');
msg = this._errorMsg('EIP1559 block has no base fee field');
throw new Error(msg);
}

@@ -573,3 +621,4 @@ block = this._common.hardforkBlockBN('london');

if (!this.baseFeePerGas.eq(initialBaseFee)) {
throw new Error('Initial EIP1559 block does not have initial base fee');
msg = this._errorMsg('Initial EIP1559 block does not have initial base fee');
throw new Error(msg);
}

@@ -580,3 +629,4 @@ }

if (!this.baseFeePerGas.eq(expectedBaseFee)) {
throw new Error('Invalid block: base fee not correct');
msg = this._errorMsg('Invalid block: base fee not correct');
throw new Error(msg);
}

@@ -595,3 +645,4 @@ }

if (!this._common.isActivatedEIP(1559)) {
throw new Error('calcNextBaseFee() can only be called with EIP1559 being activated');
var msg = this._errorMsg('calcNextBaseFee() can only be called with EIP1559 being activated');
throw new Error(msg);
}

@@ -633,3 +684,3 @@ var nextBaseFee;

this.receiptTrie,
this.bloom,
this.logsBloom,
(0, ethereumjs_util_1.bnToUnpaddedBuffer)(this.difficulty),

@@ -669,3 +720,4 @@ (0, ethereumjs_util_1.bnToUnpaddedBuffer)(this.number),

if (this._common.consensusAlgorithm() !== common_1.ConsensusAlgorithm.Clique) {
throw new Error("BlockHeader." + name + "() call only supported for clique PoA networks");
var msg = this._errorMsg("BlockHeader." + name + "() call only supported for clique PoA networks");
throw new Error(msg);
}

@@ -733,3 +785,4 @@ };

if (!this.cliqueIsEpochTransition()) {
throw new Error('Signers are only included in epoch transition blocks (clique)');
var msg = this._errorMsg('Signers are only included in epoch transition blocks (clique)');
throw new Error(msg);
}

@@ -793,3 +846,3 @@ var start = clique_1.CLIQUE_EXTRA_VANITY;

receiptTrie: '0x' + this.receiptTrie.toString('hex'),
bloom: '0x' + this.bloom.toString('hex'),
logsBloom: '0x' + this.logsBloom.toString('hex'),
difficulty: (0, ethereumjs_util_1.bnToHex)(this.difficulty),

@@ -805,17 +858,8 @@ number: (0, ethereumjs_util_1.bnToHex)(this.number),

if (this._common.isActivatedEIP(1559)) {
jsonDict['baseFee'] = '0x' + this.baseFeePerGas.toString('hex');
jsonDict.baseFeePerGas = '0x' + this.baseFeePerGas.toString('hex');
jsonDict.baseFee = '0x' + this.baseFeePerGas.toString('hex'); // deprecated alias, please use `baseFeePerGas`, will be removed in next major release
}
jsonDict.bloom = jsonDict.logsBloom; // deprecated alias, please use `logsBloom`, will be removed in next major release
return jsonDict;
};
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
BlockHeader.prototype._error = function (msg) {
msg += " (" + this._errorPostfix + ")";
var e = new Error(msg);
return e;
};
BlockHeader.prototype._getHardfork = function () {

@@ -850,22 +894,53 @@ return this._common.hardfork() || this._common.activeHardfork(this.number.toNumber());

/**
* Force extra data be DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
BlockHeader.prototype._checkDAOExtraData = function () {
BlockHeader.prototype._validateDAOExtraData = function () {
if (!this._common.hardforkIsActiveOnChain(common_1.Hardfork.Dao)) {
return;
}
var DAOActivationBlock = this._common.hardforkBlockBN(common_1.Hardfork.Dao);
if (!DAOActivationBlock || DAOActivationBlock.isZero() || this.number.lt(DAOActivationBlock)) {
return;
}
var DAO_ExtraData = Buffer.from('64616f2d686172642d666f726b', 'hex');
var DAO_ForceExtraDataRange = new ethereumjs_util_1.BN(9);
if (this._common.hardforkIsActiveOnChain('dao')) {
// verify the extraData field.
var blockNumber = this.number;
var DAOActivationBlock = this._common.hardforkBlockBN('dao');
if (blockNumber.gte(DAOActivationBlock)) {
var drift = blockNumber.sub(DAOActivationBlock);
if (drift.lte(DAO_ForceExtraDataRange)) {
if (!this.extraData.equals(DAO_ExtraData)) {
throw new Error("extraData should be 'dao-hard-fork'");
}
}
}
var drift = this.number.sub(DAOActivationBlock);
if (drift.lte(DAO_ForceExtraDataRange) && !this.extraData.equals(DAO_ExtraData)) {
var msg = this._errorMsg("extraData should be 'dao-hard-fork'");
throw new Error(msg);
}
};
/**
* Return a compact error string representation of the object
*/
BlockHeader.prototype.errorStr = function () {
var _a;
var hash = '';
try {
hash = (0, ethereumjs_util_1.bufferToHex)(this.hash());
}
catch (e) {
hash = 'error';
}
var hf = '';
try {
hf = this._common.hardfork();
}
catch (e) {
hf = 'error';
}
var errorStr = "block header number=" + this.number + " hash=" + hash + " ";
errorStr += "hf=" + hf + " baseFeePerGas=" + ((_a = this.baseFeePerGas) !== null && _a !== void 0 ? _a : 'none');
return errorStr;
};
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
BlockHeader.prototype._errorMsg = function (msg) {
return msg + " (" + this.errorStr() + ")";
};
return BlockHeader;

@@ -872,0 +947,0 @@ }());

@@ -90,3 +90,3 @@ /// <reference types="node" />

receiptTrie?: BufferLike;
bloom?: BufferLike;
logsBloom?: BufferLike;
difficulty?: BNLike;

@@ -101,2 +101,3 @@ number?: BNLike;

baseFeePerGas?: BNLike;
bloom?: BufferLike;
}

@@ -143,3 +144,3 @@ /**

receiptTrie?: string;
bloom?: string;
logsBloom?: string;
difficulty?: string;

@@ -153,3 +154,5 @@ number?: string;

nonce?: string;
baseFeePerGas?: string;
baseFee?: string;
bloom?: BufferLike;
}

@@ -156,0 +159,0 @@ export interface Blockchain {

@@ -150,9 +150,2 @@ /// <reference types="node" />

/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_error(msg: string): Error;
/**
* The following rules are checked in this method:

@@ -168,2 +161,13 @@ * Uncle Header is a valid header.

private _getBlockByHash;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string): string;
}

@@ -28,6 +28,8 @@ "use strict";

if (this._common.consensusType() === common_1.ConsensusType.ProofOfAuthority) {
throw new Error('Block initialization with uncleHeaders on a PoA network is not allowed');
const msg = this._errorMsg('Block initialization with uncleHeaders on a PoA network is not allowed');
throw new Error(msg);
}
if (this._common.consensusType() === common_1.ConsensusType.ProofOfStake) {
throw new Error('Block initialization with uncleHeaders on a PoS network is not allowed');
const msg = this._errorMsg('Block initialization with uncleHeaders on a PoS network is not allowed');
throw new Error(msg);
}

@@ -63,6 +65,5 @@ }

// Disable this option here (all other options carried over), since this overwrites the provided Difficulty to an incorrect value
calcDifficultyFromHeader: undefined });
if (uncleOpts.hardforkByTD) {
delete uncleOpts.hardforkByBlockNumber;
}
calcDifficultyFromHeader: undefined,
// Uncles are obsolete post-merge (no use for hardforkByTD)
hardforkByTD: undefined });
for (const uhData of uhsData !== null && uhsData !== void 0 ? uhsData : []) {

@@ -238,14 +239,17 @@ const uh = header_1.BlockHeader.fromHeaderData(uhData, uncleOpts);

if (txErrors.length > 0) {
const msg = `invalid transactions: ${txErrors.join(' ')}`;
throw this.header._error(msg);
const msg = this._errorMsg(`invalid transactions: ${txErrors.join(' ')}`);
throw new Error(msg);
}
if (!onlyHeader) {
const validateTxTrie = await this.validateTransactionsTrie();
if (!validateTxTrie) {
throw new Error('invalid transaction trie');
}
if (!this.validateUnclesHash()) {
throw new Error('invalid uncle hash');
}
if (onlyHeader) {
return;
}
const validateTxTrie = await this.validateTransactionsTrie();
if (!validateTxTrie) {
const msg = this._errorMsg('invalid transaction trie');
throw new Error(msg);
}
if (!this.validateUnclesHash()) {
const msg = this._errorMsg('invalid uncle hash');
throw new Error(msg);
}
}

@@ -281,3 +285,4 @@ /**

if (this.uncleHeaders.length > 2) {
throw new Error('too many uncle headers');
const msg = this._errorMsg('too many uncle headers');
throw new Error(msg);
}

@@ -287,3 +292,4 @@ // Header does not count an uncle twice.

if (!(new Set(uncleHashes).size === uncleHashes.length)) {
throw new Error('duplicate uncles');
const msg = this._errorMsg('duplicate uncles');
throw new Error(msg);
}

@@ -328,11 +334,2 @@ await this._validateUncleHeaders(this.uncleHeaders, blockchain);

/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_error(msg) {
return this.header._error(msg);
}
/**
* The following rules are checked in this method:

@@ -373,3 +370,4 @@ * Uncle Header is a valid header.

if (!parentBlock) {
throw new Error('could not find parent block');
const msg = this._errorMsg('could not find parent block');
throw new Error(msg);
}

@@ -393,9 +391,12 @@ canonicalBlockMap.push(parentBlock);

if (!canonicalChainHashes[parentHash]) {
throw new Error('The parent hash of the uncle header is not part of the canonical chain');
const msg = this._errorMsg('The parent hash of the uncle header is not part of the canonical chain');
throw new Error(msg);
}
if (includedUncles[uncleHash]) {
throw new Error('The uncle is already included in the canonical chain');
const msg = this._errorMsg('The uncle is already included in the canonical chain');
throw new Error(msg);
}
if (canonicalChainHashes[uncleHash]) {
throw new Error('The uncle is a canonical block');
const msg = this._errorMsg('The uncle is a canonical block');
throw new Error(msg);
}

@@ -418,4 +419,37 @@ });

}
/**
* Return a compact error string representation of the object
*/
errorStr() {
var _a;
let hash = '';
try {
hash = (0, ethereumjs_util_1.bufferToHex)(this.hash());
}
catch (e) {
hash = 'error';
}
let hf = '';
try {
hf = this._common.hardfork();
}
catch (e) {
hf = 'error';
}
let errorStr = `block number=${this.header.number} hash=${hash} `;
errorStr += `hf=${hf} baseFeePerGas=${(_a = this.header.baseFeePerGas) !== null && _a !== void 0 ? _a : 'none'} `;
errorStr += `txs=${this.transactions.length} uncles=${this.uncleHeaders.length}`;
return errorStr;
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_errorMsg(msg) {
return `${msg} (${this.errorStr()})`;
}
}
exports.Block = Block;
//# sourceMappingURL=block.js.map

@@ -12,9 +12,3 @@ "use strict";

function blockHeaderFromRpc(blockParams, options) {
const { parentHash, sha3Uncles, miner, stateRoot, transactionsRoot, receiptRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, } = blockParams;
let baseFeePerGas;
// Check if the field baseFeePerGas is present in the block.
// This field was introduced after: https://eips.ethereum.org/EIPS/eip-1559
if ('baseFeePerGas' in blockParams) {
baseFeePerGas = blockParams.baseFeePerGas;
}
const { parentHash, sha3Uncles, miner, stateRoot, transactionsRoot, receiptRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, } = blockParams;
const blockHeader = header_1.BlockHeader.fromHeaderData({

@@ -27,3 +21,3 @@ parentHash,

receiptTrie: receiptRoot || receiptsRoot,
bloom: logsBloom,
logsBloom,
difficulty: (0, helpers_1.numberToHex)(difficulty),

@@ -30,0 +24,0 @@ number,

@@ -16,3 +16,3 @@ /// <reference types="node" />

readonly receiptTrie: Buffer;
readonly bloom: Buffer;
readonly logsBloom: Buffer;
readonly difficulty: BN;

@@ -28,5 +28,10 @@ readonly number: BN;

readonly _common: Common;
_errorPostfix: string;
private cache;
/**
* Backwards compatible alias for {@link BlockHeader.logsBloom}
* (planned to be removed in next major release)
* @deprecated
*/
get bloom(): Buffer;
/**
* Static constructor to create a block header from a header data dictionary

@@ -63,3 +68,3 @@ *

*/
constructor(parentHash: Buffer, uncleHash: Buffer, coinbase: Address, stateRoot: Buffer, transactionsTrie: Buffer, receiptTrie: Buffer, bloom: Buffer, difficulty: BN, number: BN, gasLimit: BN, gasUsed: BN, timestamp: BN, extraData: Buffer, mixHash: Buffer, nonce: Buffer, options?: BlockOptions, baseFeePerGas?: BN);
constructor(parentHash: Buffer, uncleHash: Buffer, coinbase: Address, stateRoot: Buffer, transactionsTrie: Buffer, receiptTrie: Buffer, logsBloom: Buffer, difficulty: BN, number: BN, gasLimit: BN, gasUsed: BN, timestamp: BN, extraData: Buffer, mixHash: Buffer, nonce: Buffer, options?: BlockOptions, baseFeePerGas?: BN);
/**

@@ -181,3 +186,14 @@ * Validates correct buffer lengths, throws if invalid.

toJSON(): JsonHeader;
private _getHardfork;
private _getHeaderByHash;
/**
* Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
private _validateDAOExtraData;
/**
* Return a compact error string representation of the object
*/
errorStr(): string;
/**
* Internal helper function to create an annotated error message

@@ -188,10 +204,3 @@ *

*/
_error(msg: string): Error;
private _getHardfork;
private _getHeaderByHash;
/**
* Force extra data be DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
private _checkDAOExtraData;
protected _errorMsg(msg: string): string;
}

@@ -38,5 +38,4 @@ "use strict";

*/
constructor(parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, bloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, options = {}, baseFeePerGas) {
constructor(parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, options = {}, baseFeePerGas) {
var _a, _b;
this._errorPostfix = '';
this.cache = {

@@ -60,3 +59,3 @@ hash: undefined,

const hardforkByBlockNumber = (_a = options.hardforkByBlockNumber) !== null && _a !== void 0 ? _a : false;
if (hardforkByBlockNumber || options.hardforkByTD) {
if (hardforkByBlockNumber || options.hardforkByTD !== undefined) {
this._common.setHardforkByBlockNumber(number, options.hardforkByTD);

@@ -94,2 +93,6 @@ }

}
if (this._common.gteHardfork(common_1.Hardfork.London) &&
this._common.genesis().baseFeePerGas !== undefined) {
baseFeePerGas = new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(this._common.genesis().baseFeePerGas));
}
}

@@ -102,3 +105,3 @@ this.parentHash = parentHash;

this.receiptTrie = receiptTrie;
this.bloom = bloom;
this.logsBloom = logsBloom;
this.difficulty = difficulty;

@@ -114,3 +117,3 @@ this.number = number;

this._validateHeaderFields();
this._checkDAOExtraData();
this._validateDAOExtraData();
// Now we have set all the values of this Header, we possibly have set a dummy

@@ -133,3 +136,2 @@ // `difficulty` value (defaults to 0). If we have a `calcDifficultyFromHeader`

}
this._errorPostfix = `block number=${this.number.toNumber()} hash=${this.hash().toString('hex')}`;
const freeze = (_b = options === null || options === void 0 ? void 0 : options.freeze) !== null && _b !== void 0 ? _b : true;

@@ -141,2 +143,10 @@ if (freeze) {

/**
* Backwards compatible alias for {@link BlockHeader.logsBloom}
* (planned to be removed in next major release)
* @deprecated
*/
get bloom() {
return this.logsBloom;
}
/**
* Static constructor to create a block header from a header data dictionary

@@ -148,4 +158,11 @@ *

static fromHeaderData(headerData = {}, opts = {}) {
const { parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, bloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, } = headerData;
return new BlockHeader(parentHash ? (0, ethereumjs_util_1.toBuffer)(parentHash) : (0, ethereumjs_util_1.zeros)(32), uncleHash ? (0, ethereumjs_util_1.toBuffer)(uncleHash) : ethereumjs_util_1.KECCAK256_RLP_ARRAY, coinbase ? new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)) : ethereumjs_util_1.Address.zero(), stateRoot ? (0, ethereumjs_util_1.toBuffer)(stateRoot) : (0, ethereumjs_util_1.zeros)(32), transactionsTrie ? (0, ethereumjs_util_1.toBuffer)(transactionsTrie) : ethereumjs_util_1.KECCAK256_RLP, receiptTrie ? (0, ethereumjs_util_1.toBuffer)(receiptTrie) : ethereumjs_util_1.KECCAK256_RLP, bloom ? (0, ethereumjs_util_1.toBuffer)(bloom) : (0, ethereumjs_util_1.zeros)(256), difficulty ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)) : new ethereumjs_util_1.BN(0), number ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)) : new ethereumjs_util_1.BN(0), gasLimit ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)) : DEFAULT_GAS_LIMIT, gasUsed ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)) : new ethereumjs_util_1.BN(0), timestamp ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)) : new ethereumjs_util_1.BN(0), extraData ? (0, ethereumjs_util_1.toBuffer)(extraData) : Buffer.from([]), mixHash ? (0, ethereumjs_util_1.toBuffer)(mixHash) : (0, ethereumjs_util_1.zeros)(32), nonce ? (0, ethereumjs_util_1.toBuffer)(nonce) : (0, ethereumjs_util_1.zeros)(8), opts, baseFeePerGas !== undefined ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas)) : undefined);
if (headerData.logsBloom === undefined && headerData.bloom !== undefined) {
// backwards compatible alias for deprecated `bloom` key renamed to `logsBloom`
// (planned to be removed in next major release)
headerData.logsBloom = headerData.bloom;
}
const { parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, } = headerData;
return new BlockHeader(parentHash ? (0, ethereumjs_util_1.toBuffer)(parentHash) : (0, ethereumjs_util_1.zeros)(32), uncleHash ? (0, ethereumjs_util_1.toBuffer)(uncleHash) : ethereumjs_util_1.KECCAK256_RLP_ARRAY, coinbase ? new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)) : ethereumjs_util_1.Address.zero(), stateRoot ? (0, ethereumjs_util_1.toBuffer)(stateRoot) : (0, ethereumjs_util_1.zeros)(32), transactionsTrie ? (0, ethereumjs_util_1.toBuffer)(transactionsTrie) : ethereumjs_util_1.KECCAK256_RLP, receiptTrie ? (0, ethereumjs_util_1.toBuffer)(receiptTrie) : ethereumjs_util_1.KECCAK256_RLP, logsBloom ? (0, ethereumjs_util_1.toBuffer)(logsBloom) : (0, ethereumjs_util_1.zeros)(256), difficulty ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)) : new ethereumjs_util_1.BN(0), number ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)) : new ethereumjs_util_1.BN(0), gasLimit ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)) : DEFAULT_GAS_LIMIT, gasUsed ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)) : new ethereumjs_util_1.BN(0), timestamp ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)) : new ethereumjs_util_1.BN(0), extraData ? (0, ethereumjs_util_1.toBuffer)(extraData) : Buffer.from([]), mixHash ? (0, ethereumjs_util_1.toBuffer)(mixHash) : (0, ethereumjs_util_1.zeros)(32), nonce ? (0, ethereumjs_util_1.toBuffer)(nonce) : (0, ethereumjs_util_1.zeros)(8), opts, baseFeePerGas !== undefined && baseFeePerGas !== null
? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas))
: undefined);
}

@@ -172,3 +189,3 @@ /**

static fromValuesArray(values, opts = {}) {
const [parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, bloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas,] = values;
const [parentHash, uncleHash, coinbase, stateRoot, transactionsTrie, receiptTrie, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas,] = values;
if (values.length > 16) {

@@ -180,3 +197,5 @@ throw new Error('invalid header. More values than expected were received');

}
return new BlockHeader((0, ethereumjs_util_1.toBuffer)(parentHash), (0, ethereumjs_util_1.toBuffer)(uncleHash), new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)), (0, ethereumjs_util_1.toBuffer)(stateRoot), (0, ethereumjs_util_1.toBuffer)(transactionsTrie), (0, ethereumjs_util_1.toBuffer)(receiptTrie), (0, ethereumjs_util_1.toBuffer)(bloom), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)), (0, ethereumjs_util_1.toBuffer)(extraData), (0, ethereumjs_util_1.toBuffer)(mixHash), (0, ethereumjs_util_1.toBuffer)(nonce), opts, baseFeePerGas !== undefined ? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas)) : undefined);
return new BlockHeader((0, ethereumjs_util_1.toBuffer)(parentHash), (0, ethereumjs_util_1.toBuffer)(uncleHash), new ethereumjs_util_1.Address((0, ethereumjs_util_1.toBuffer)(coinbase)), (0, ethereumjs_util_1.toBuffer)(stateRoot), (0, ethereumjs_util_1.toBuffer)(transactionsTrie), (0, ethereumjs_util_1.toBuffer)(receiptTrie), (0, ethereumjs_util_1.toBuffer)(logsBloom), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(difficulty)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(number)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasLimit)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(gasUsed)), new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(timestamp)), (0, ethereumjs_util_1.toBuffer)(extraData), (0, ethereumjs_util_1.toBuffer)(mixHash), (0, ethereumjs_util_1.toBuffer)(nonce), opts, baseFeePerGas !== undefined && baseFeePerGas !== null
? new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(baseFeePerGas))
: undefined);
}

@@ -194,17 +213,24 @@ /**

_validateHeaderFields() {
const { parentHash, uncleHash, stateRoot, transactionsTrie, receiptTrie, difficulty, extraData, mixHash, nonce, } = this;
const { parentHash, uncleHash, stateRoot, transactionsTrie, receiptTrie, difficulty,
// extraData,
mixHash, nonce, } = this;
if (parentHash.length !== 32) {
throw new Error(`parentHash must be 32 bytes, received ${parentHash.length} bytes`);
const msg = this._errorMsg(`parentHash must be 32 bytes, received ${parentHash.length} bytes`);
throw new Error(msg);
}
if (stateRoot.length !== 32) {
throw new Error(`stateRoot must be 32 bytes, received ${stateRoot.length} bytes`);
const msg = this._errorMsg(`stateRoot must be 32 bytes, received ${stateRoot.length} bytes`);
throw new Error(msg);
}
if (transactionsTrie.length !== 32) {
throw new Error(`transactionsTrie must be 32 bytes, received ${transactionsTrie.length} bytes`);
const msg = this._errorMsg(`transactionsTrie must be 32 bytes, received ${transactionsTrie.length} bytes`);
throw new Error(msg);
}
if (receiptTrie.length !== 32) {
throw new Error(`receiptTrie must be 32 bytes, received ${receiptTrie.length} bytes`);
const msg = this._errorMsg(`receiptTrie must be 32 bytes, received ${receiptTrie.length} bytes`);
throw new Error(msg);
}
if (mixHash.length !== 32) {
throw new Error(`mixHash must be 32 bytes, received ${mixHash.length} bytes`);
const msg = this._errorMsg(`mixHash must be 32 bytes, received ${mixHash.length} bytes`);
throw new Error(msg);
}

@@ -215,7 +241,9 @@ if (nonce.length !== 8) {

if (nonce.length !== 65) {
throw new Error(`nonce must be 65 bytes on kovan, received ${nonce.length} bytes`);
const msg = this._errorMsg(`nonce must be 65 bytes on kovan, received ${nonce.length} bytes`);
throw new Error(msg);
}
}
else {
throw new Error(`nonce must be 8 bytes, received ${nonce.length} bytes`);
const msg = this._errorMsg(`nonce must be 8 bytes, received ${nonce.length} bytes`);
throw new Error(msg);
}

@@ -235,6 +263,8 @@ }

}
if (!extraData.equals(Buffer.from([]))) {
errorMsg += `, extraData: ${extraData.toString('hex')} (expected: '')`;
error = true;
}
// WIP from merge interop event:
// extraData behavior pending consideration, for now allowed to be non-empty
// if (!extraData.equals(Buffer.from([]))) {
// errorMsg += `, extraData: ${extraData.toString('hex')} (expected: '')`
// error = true
// }
if (!mixHash.equals((0, ethereumjs_util_1.zeros)(32))) {

@@ -249,3 +279,4 @@ errorMsg += `, mixHash: ${mixHash.toString('hex')} (expected: ${(0, ethereumjs_util_1.zeros)(32).toString('hex')})`;

if (error) {
throw new Error('Invalid PoS block' + errorMsg);
const msg = this._errorMsg(`Invalid PoS block${errorMsg}`);
throw new Error(msg);
}

@@ -261,6 +292,8 @@ }

if (this._common.consensusType() !== common_1.ConsensusType.ProofOfWork) {
throw new Error('difficulty calculation is only supported on PoW chains');
const msg = this._errorMsg('difficulty calculation is only supported on PoW chains');
throw new Error(msg);
}
if (this._common.consensusAlgorithm() !== common_1.ConsensusAlgorithm.Ethash) {
throw new Error('difficulty calculation currently only supports the ethash algorithm');
const msg = this._errorMsg('difficulty calculation currently only supports the ethash algorithm');
throw new Error(msg);
}

@@ -336,6 +369,8 @@ const hardfork = this._getHardfork();

if (!this.difficulty.eq(clique_1.CLIQUE_DIFF_INTURN) && !this.difficulty.eq(clique_1.CLIQUE_DIFF_NOTURN)) {
throw new Error(`difficulty for clique block must be INTURN (2) or NOTURN (1), received: ${this.difficulty.toString()}`);
const msg = this._errorMsg(`difficulty for clique block must be INTURN (2) or NOTURN (1), received: ${this.difficulty}`);
throw new Error(msg);
}
if ('cliqueActiveSigners' in blockchain === false) {
throw new Error('PoA blockchain requires method blockchain.cliqueActiveSigners() to validate clique difficulty');
const msg = this._errorMsg('PoA blockchain requires method blockchain.cliqueActiveSigners() to validate clique difficulty');
throw new Error(msg);
}

@@ -406,4 +441,4 @@ const signers = blockchain.cliqueActiveSigners();

if (this.extraData.length > this._common.paramByHardfork('vm', 'maxExtraDataSize', hardfork)) {
const msg = 'invalid amount of extra data';
throw this._error(msg);
const msg = this._errorMsg('invalid amount of extra data');
throw new Error(msg);
}

@@ -417,4 +452,4 @@ }

if (this.extraData.length !== minLength) {
const msg = `extraData must be ${minLength} bytes on non-epoch transition blocks, received ${this.extraData.length} bytes`;
throw this._error(msg);
const msg = this._errorMsg(`extraData must be ${minLength} bytes on non-epoch transition blocks, received ${this.extraData.length} bytes`);
throw new Error(msg);
}

@@ -425,9 +460,9 @@ }

if (signerLength % 20 !== 0) {
const msg = `invalid signer list length in extraData, received signer length of ${signerLength} (not divisible by 20)`;
throw this._error(msg);
const msg = this._errorMsg(`invalid signer list length in extraData, received signer length of ${signerLength} (not divisible by 20)`);
throw new Error(msg);
}
// coinbase (beneficiary) on epoch transition
if (!this.coinbase.isZero()) {
const msg = `coinbase must be filled with zeros on epoch transition blocks, received ${this.coinbase.toString()}`;
throw this._error(msg);
const msg = this._errorMsg(`coinbase must be filled with zeros on epoch transition blocks, received ${this.coinbase}`);
throw new Error(msg);
}

@@ -437,8 +472,8 @@ }

if (!this.mixHash.equals(Buffer.alloc(32))) {
const msg = `mixHash must be filled with zeros, received ${this.mixHash}`;
throw this._error(msg);
const msg = this._errorMsg(`mixHash must be filled with zeros, received ${this.mixHash}`);
throw new Error(msg);
}
if (!this.validateCliqueDifficulty(blockchain)) {
const msg = `invalid clique difficulty`;
throw this._error(msg);
const msg = this._errorMsg(`invalid clique difficulty`);
throw new Error(msg);
}

@@ -448,10 +483,13 @@ }

if (!parentHeader) {
throw new Error('could not find parent header');
const msg = this._errorMsg('could not find parent header');
throw new Error(msg);
}
const { number } = this;
if (!number.eq(parentHeader.number.addn(1))) {
throw new Error('invalid number');
const msg = this._errorMsg('invalid number');
throw new Error(msg);
}
if (this.timestamp.lte(parentHeader.timestamp)) {
throw new Error('invalid timestamp');
const msg = this._errorMsg('invalid timestamp');
throw new Error(msg);
}

@@ -462,3 +500,4 @@ if (this._common.consensusAlgorithm() === common_1.ConsensusAlgorithm.Clique) {

if (parentHeader.timestamp.addn(period).gt(this.timestamp)) {
throw new Error('invalid timestamp diff (lower than period)');
const msg = this._errorMsg('invalid timestamp diff (lower than period)');
throw new Error(msg);
}

@@ -468,7 +507,9 @@ }

if (!this.validateDifficulty(parentHeader)) {
throw new Error('invalid difficulty');
const msg = this._errorMsg('invalid difficulty');
throw new Error(msg);
}
}
if (!this.validateGasLimit(parentHeader)) {
throw new Error('invalid gas limit');
const msg = this._errorMsg('invalid gas limit');
throw new Error(msg);
}

@@ -478,3 +519,4 @@ if (height) {

if (!(dif.ltn(8) && dif.gtn(1))) {
throw new Error('uncle block has a parent that is too old or too young');
const msg = this._errorMsg('uncle block has a parent that is too old or too young');
throw new Error(msg);
}

@@ -484,7 +526,9 @@ }

if (this.gasUsed.gt(this.gasLimit)) {
throw new Error('Invalid block: too much gas used');
const msg = this._errorMsg('Invalid block: too much gas used');
throw new Error(msg);
}
if (this._common.isActivatedEIP(1559)) {
if (!this.baseFeePerGas) {
throw new Error('EIP1559 block has no base fee field');
const msg = this._errorMsg('EIP1559 block has no base fee field');
throw new Error(msg);
}

@@ -496,3 +540,4 @@ const block = this._common.hardforkBlockBN('london');

if (!this.baseFeePerGas.eq(initialBaseFee)) {
throw new Error('Initial EIP1559 block does not have initial base fee');
const msg = this._errorMsg('Initial EIP1559 block does not have initial base fee');
throw new Error(msg);
}

@@ -504,3 +549,4 @@ }

if (!this.baseFeePerGas.eq(expectedBaseFee)) {
throw new Error('Invalid block: base fee not correct');
const msg = this._errorMsg('Invalid block: base fee not correct');
throw new Error(msg);
}

@@ -515,3 +561,4 @@ }

if (!this._common.isActivatedEIP(1559)) {
throw new Error('calcNextBaseFee() can only be called with EIP1559 being activated');
const msg = this._errorMsg('calcNextBaseFee() can only be called with EIP1559 being activated');
throw new Error(msg);
}

@@ -553,3 +600,3 @@ let nextBaseFee;

this.receiptTrie,
this.bloom,
this.logsBloom,
(0, ethereumjs_util_1.bnToUnpaddedBuffer)(this.difficulty),

@@ -589,3 +636,4 @@ (0, ethereumjs_util_1.bnToUnpaddedBuffer)(this.number),

if (this._common.consensusAlgorithm() !== common_1.ConsensusAlgorithm.Clique) {
throw new Error(`BlockHeader.${name}() call only supported for clique PoA networks`);
const msg = this._errorMsg(`BlockHeader.${name}() call only supported for clique PoA networks`);
throw new Error(msg);
}

@@ -653,3 +701,4 @@ }

if (!this.cliqueIsEpochTransition()) {
throw new Error('Signers are only included in epoch transition blocks (clique)');
const msg = this._errorMsg('Signers are only included in epoch transition blocks (clique)');
throw new Error(msg);
}

@@ -713,3 +762,3 @@ const start = clique_1.CLIQUE_EXTRA_VANITY;

receiptTrie: '0x' + this.receiptTrie.toString('hex'),
bloom: '0x' + this.bloom.toString('hex'),
logsBloom: '0x' + this.logsBloom.toString('hex'),
difficulty: (0, ethereumjs_util_1.bnToHex)(this.difficulty),

@@ -725,17 +774,8 @@ number: (0, ethereumjs_util_1.bnToHex)(this.number),

if (this._common.isActivatedEIP(1559)) {
jsonDict['baseFee'] = '0x' + this.baseFeePerGas.toString('hex');
jsonDict.baseFeePerGas = '0x' + this.baseFeePerGas.toString('hex');
jsonDict.baseFee = '0x' + this.baseFeePerGas.toString('hex'); // deprecated alias, please use `baseFeePerGas`, will be removed in next major release
}
jsonDict.bloom = jsonDict.logsBloom; // deprecated alias, please use `logsBloom`, will be removed in next major release
return jsonDict;
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_error(msg) {
msg += ` (${this._errorPostfix})`;
const e = new Error(msg);
return e;
}
_getHardfork() {

@@ -759,24 +799,55 @@ return this._common.hardfork() || this._common.activeHardfork(this.number.toNumber());

/**
* Force extra data be DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
_checkDAOExtraData() {
_validateDAOExtraData() {
if (!this._common.hardforkIsActiveOnChain(common_1.Hardfork.Dao)) {
return;
}
const DAOActivationBlock = this._common.hardforkBlockBN(common_1.Hardfork.Dao);
if (!DAOActivationBlock || DAOActivationBlock.isZero() || this.number.lt(DAOActivationBlock)) {
return;
}
const DAO_ExtraData = Buffer.from('64616f2d686172642d666f726b', 'hex');
const DAO_ForceExtraDataRange = new ethereumjs_util_1.BN(9);
if (this._common.hardforkIsActiveOnChain('dao')) {
// verify the extraData field.
const blockNumber = this.number;
const DAOActivationBlock = this._common.hardforkBlockBN('dao');
if (blockNumber.gte(DAOActivationBlock)) {
const drift = blockNumber.sub(DAOActivationBlock);
if (drift.lte(DAO_ForceExtraDataRange)) {
if (!this.extraData.equals(DAO_ExtraData)) {
throw new Error("extraData should be 'dao-hard-fork'");
}
}
}
const drift = this.number.sub(DAOActivationBlock);
if (drift.lte(DAO_ForceExtraDataRange) && !this.extraData.equals(DAO_ExtraData)) {
const msg = this._errorMsg("extraData should be 'dao-hard-fork'");
throw new Error(msg);
}
}
/**
* Return a compact error string representation of the object
*/
errorStr() {
var _a;
let hash = '';
try {
hash = (0, ethereumjs_util_1.bufferToHex)(this.hash());
}
catch (e) {
hash = 'error';
}
let hf = '';
try {
hf = this._common.hardfork();
}
catch (e) {
hf = 'error';
}
let errorStr = `block header number=${this.number} hash=${hash} `;
errorStr += `hf=${hf} baseFeePerGas=${(_a = this.baseFeePerGas) !== null && _a !== void 0 ? _a : 'none'}`;
return errorStr;
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_errorMsg(msg) {
return `${msg} (${this.errorStr()})`;
}
}
exports.BlockHeader = BlockHeader;
//# sourceMappingURL=header.js.map

@@ -90,3 +90,3 @@ /// <reference types="node" />

receiptTrie?: BufferLike;
bloom?: BufferLike;
logsBloom?: BufferLike;
difficulty?: BNLike;

@@ -101,2 +101,3 @@ number?: BNLike;

baseFeePerGas?: BNLike;
bloom?: BufferLike;
}

@@ -143,3 +144,3 @@ /**

receiptTrie?: string;
bloom?: string;
logsBloom?: string;
difficulty?: string;

@@ -153,3 +154,5 @@ number?: string;

nonce?: string;
baseFeePerGas?: string;
baseFee?: string;
bloom?: BufferLike;
}

@@ -156,0 +159,0 @@ export interface Blockchain {

{
"name": "@ethereumjs/block",
"version": "3.5.1",
"version": "3.6.0",
"description": "Provides Block serialization and help functions",

@@ -38,6 +38,6 @@ "license": "MPL-2.0",

"dependencies": {
"@ethereumjs/common": "^2.5.0",
"merkle-patricia-tree": "^4.2.1",
"@ethereumjs/tx": "^3.3.1",
"ethereumjs-util": "^7.1.1"
"@ethereumjs/common": "^2.6.0",
"merkle-patricia-tree": "^4.2.2",
"@ethereumjs/tx": "^3.4.0",
"ethereumjs-util": "^7.1.3"
},

@@ -54,3 +54,3 @@ "devDependencies": {

"karma-typescript": "^5.5.1",
"nyc": "^14.0.0",
"nyc": "^15.1.0",
"prettier": "^2.0.5",

@@ -57,0 +57,0 @@ "tape": "^5.3.1",

@@ -81,2 +81,14 @@ # @ethereumjs/block

block.header.calcNextBaseFee().toNumber() // 11
// So for creating a block with a matching base fee in a certain
// chain context you can do:
const blockWithMatchingBaseFee = Block.fromBlockData({
header: {
baseFeePerGas: parentHeader.calcNextBaseFee(),
gasLimit: new BN(100),
gasUsed: new BN(60)
}
}, { common })
```

@@ -83,0 +95,0 @@

import { BaseTrie as Trie } from 'merkle-patricia-tree'
import { BN, rlp, keccak256, KECCAK256_RLP } from 'ethereumjs-util'
import { BN, rlp, keccak256, KECCAK256_RLP, bufferToHex } from 'ethereumjs-util'
import Common, { ConsensusType } from '@ethereumjs/common'

@@ -56,6 +56,5 @@ import {

calcDifficultyFromHeader: undefined,
// Uncles are obsolete post-merge (no use for hardforkByTD)
hardforkByTD: undefined,
}
if (uncleOpts.hardforkByTD) {
delete uncleOpts.hardforkByBlockNumber
}
for (const uhData of uhsData ?? []) {

@@ -156,6 +155,12 @@ const uh = BlockHeader.fromHeaderData(uhData, uncleOpts)

if (this._common.consensusType() === ConsensusType.ProofOfAuthority) {
throw new Error('Block initialization with uncleHeaders on a PoA network is not allowed')
const msg = this._errorMsg(
'Block initialization with uncleHeaders on a PoA network is not allowed'
)
throw new Error(msg)
}
if (this._common.consensusType() === ConsensusType.ProofOfStake) {
throw new Error('Block initialization with uncleHeaders on a PoS network is not allowed')
const msg = this._errorMsg(
'Block initialization with uncleHeaders on a PoS network is not allowed'
)
throw new Error(msg)
}

@@ -298,16 +303,20 @@ }

if (txErrors.length > 0) {
const msg = `invalid transactions: ${txErrors.join(' ')}`
throw this.header._error(msg)
const msg = this._errorMsg(`invalid transactions: ${txErrors.join(' ')}`)
throw new Error(msg)
}
if (!onlyHeader) {
const validateTxTrie = await this.validateTransactionsTrie()
if (!validateTxTrie) {
throw new Error('invalid transaction trie')
}
if (onlyHeader) {
return
}
if (!this.validateUnclesHash()) {
throw new Error('invalid uncle hash')
}
const validateTxTrie = await this.validateTransactionsTrie()
if (!validateTxTrie) {
const msg = this._errorMsg('invalid transaction trie')
throw new Error(msg)
}
if (!this.validateUnclesHash()) {
const msg = this._errorMsg('invalid uncle hash')
throw new Error(msg)
}
}

@@ -346,3 +355,4 @@

if (this.uncleHeaders.length > 2) {
throw new Error('too many uncle headers')
const msg = this._errorMsg('too many uncle headers')
throw new Error(msg)
}

@@ -353,3 +363,4 @@

if (!(new Set(uncleHashes).size === uncleHashes.length)) {
throw new Error('duplicate uncles')
const msg = this._errorMsg('duplicate uncles')
throw new Error(msg)
}

@@ -400,12 +411,2 @@

/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_error(msg: string) {
return this.header._error(msg)
}
/**
* The following rules are checked in this method:

@@ -453,3 +454,4 @@ * Uncle Header is a valid header.

if (!parentBlock) {
throw new Error('could not find parent block')
const msg = this._errorMsg('could not find parent block')
throw new Error(msg)
}

@@ -479,11 +481,16 @@ canonicalBlockMap.push(parentBlock)

if (!canonicalChainHashes[parentHash]) {
throw new Error('The parent hash of the uncle header is not part of the canonical chain')
const msg = this._errorMsg(
'The parent hash of the uncle header is not part of the canonical chain'
)
throw new Error(msg)
}
if (includedUncles[uncleHash]) {
throw new Error('The uncle is already included in the canonical chain')
const msg = this._errorMsg('The uncle is already included in the canonical chain')
throw new Error(msg)
}
if (canonicalChainHashes[uncleHash]) {
throw new Error('The uncle is a canonical block')
const msg = this._errorMsg('The uncle is a canonical block')
throw new Error(msg)
}

@@ -505,2 +512,34 @@ })

}
/**
* Return a compact error string representation of the object
*/
public errorStr() {
let hash = ''
try {
hash = bufferToHex(this.hash())
} catch (e: any) {
hash = 'error'
}
let hf = ''
try {
hf = this._common.hardfork()
} catch (e: any) {
hf = 'error'
}
let errorStr = `block number=${this.header.number} hash=${hash} `
errorStr += `hf=${hf} baseFeePerGas=${this.header.baseFeePerGas ?? 'none'} `
errorStr += `txs=${this.transactions.length} uncles=${this.uncleHeaders.length}`
return errorStr
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string) {
return `${msg} (${this.errorStr()})`
}
}

@@ -29,12 +29,5 @@ import { BlockHeader } from './header'

nonce,
baseFeePerGas,
} = blockParams
let baseFeePerGas
// Check if the field baseFeePerGas is present in the block.
// This field was introduced after: https://eips.ethereum.org/EIPS/eip-1559
if ('baseFeePerGas' in blockParams) {
baseFeePerGas = blockParams.baseFeePerGas
}
const blockHeader = BlockHeader.fromHeaderData(

@@ -48,3 +41,3 @@ {

receiptTrie: receiptRoot || receiptsRoot,
bloom: logsBloom,
logsBloom,
difficulty: numberToHex(difficulty),

@@ -51,0 +44,0 @@ number,

@@ -1,2 +0,2 @@

import Common, { Chain, ConsensusAlgorithm, ConsensusType } from '@ethereumjs/common'
import Common, { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from '@ethereumjs/common'
import {

@@ -16,2 +16,3 @@ Address,

zeros,
bufferToHex,
} from 'ethereumjs-util'

@@ -42,3 +43,3 @@ import { Blockchain, BlockHeaderBuffer, BlockOptions, HeaderData, JsonHeader } from './types'

public readonly receiptTrie: Buffer
public readonly bloom: Buffer
public readonly logsBloom: Buffer
public readonly difficulty: BN

@@ -55,3 +56,2 @@ public readonly number: BN

public readonly _common: Common
public _errorPostfix = ''

@@ -63,2 +63,11 @@ private cache: HeaderCache = {

/**
* Backwards compatible alias for {@link BlockHeader.logsBloom}
* (planned to be removed in next major release)
* @deprecated
*/
get bloom() {
return this.logsBloom
}
/**
* Static constructor to create a block header from a header data dictionary

@@ -70,2 +79,7 @@ *

public static fromHeaderData(headerData: HeaderData = {}, opts: BlockOptions = {}) {
if (headerData.logsBloom === undefined && headerData.bloom !== undefined) {
// backwards compatible alias for deprecated `bloom` key renamed to `logsBloom`
// (planned to be removed in next major release)
headerData.logsBloom = headerData.bloom
}
const {

@@ -78,3 +92,3 @@ parentHash,

receiptTrie,
bloom,
logsBloom,
difficulty,

@@ -98,3 +112,3 @@ number,

receiptTrie ? toBuffer(receiptTrie) : KECCAK256_RLP,
bloom ? toBuffer(bloom) : zeros(256),
logsBloom ? toBuffer(logsBloom) : zeros(256),
difficulty ? new BN(toBuffer(difficulty)) : new BN(0),

@@ -109,3 +123,5 @@ number ? new BN(toBuffer(number)) : new BN(0),

opts,
baseFeePerGas !== undefined ? new BN(toBuffer(baseFeePerGas)) : undefined
baseFeePerGas !== undefined && baseFeePerGas !== null
? new BN(toBuffer(baseFeePerGas))
: undefined
)

@@ -144,3 +160,3 @@ }

receiptTrie,
bloom,
logsBloom,
difficulty,

@@ -171,3 +187,3 @@ number,

toBuffer(receiptTrie),
toBuffer(bloom),
toBuffer(logsBloom),
new BN(toBuffer(difficulty)),

@@ -182,3 +198,5 @@ new BN(toBuffer(number)),

opts,
baseFeePerGas !== undefined ? new BN(toBuffer(baseFeePerGas)) : undefined
baseFeePerGas !== undefined && baseFeePerGas !== null
? new BN(toBuffer(baseFeePerGas))
: undefined
)

@@ -209,3 +227,3 @@ }

receiptTrie: Buffer,
bloom: Buffer,
logsBloom: Buffer,
difficulty: BN,

@@ -240,3 +258,3 @@ number: BN,

const hardforkByBlockNumber = options.hardforkByBlockNumber ?? false
if (hardforkByBlockNumber || options.hardforkByTD) {
if (hardforkByBlockNumber || options.hardforkByTD !== undefined) {
this._common.setHardforkByBlockNumber(number, options.hardforkByTD)

@@ -275,2 +293,8 @@ }

}
if (
this._common.gteHardfork(Hardfork.London) &&
this._common.genesis().baseFeePerGas !== undefined
) {
baseFeePerGas = new BN(toBuffer(this._common.genesis().baseFeePerGas))
}
}

@@ -284,3 +308,3 @@

this.receiptTrie = receiptTrie
this.bloom = bloom
this.logsBloom = logsBloom
this.difficulty = difficulty

@@ -297,3 +321,3 @@ this.number = number

this._validateHeaderFields()
this._checkDAOExtraData()
this._validateDAOExtraData()

@@ -322,6 +346,2 @@ // Now we have set all the values of this Header, we possibly have set a dummy

this._errorPostfix = `block number=${this.number.toNumber()} hash=${this.hash().toString(
'hex'
)}`
const freeze = options?.freeze ?? true

@@ -344,3 +364,3 @@ if (freeze) {

difficulty,
extraData,
// extraData,
mixHash,

@@ -351,17 +371,24 @@ nonce,

if (parentHash.length !== 32) {
throw new Error(`parentHash must be 32 bytes, received ${parentHash.length} bytes`)
const msg = this._errorMsg(`parentHash must be 32 bytes, received ${parentHash.length} bytes`)
throw new Error(msg)
}
if (stateRoot.length !== 32) {
throw new Error(`stateRoot must be 32 bytes, received ${stateRoot.length} bytes`)
const msg = this._errorMsg(`stateRoot must be 32 bytes, received ${stateRoot.length} bytes`)
throw new Error(msg)
}
if (transactionsTrie.length !== 32) {
throw new Error(
const msg = this._errorMsg(
`transactionsTrie must be 32 bytes, received ${transactionsTrie.length} bytes`
)
throw new Error(msg)
}
if (receiptTrie.length !== 32) {
throw new Error(`receiptTrie must be 32 bytes, received ${receiptTrie.length} bytes`)
const msg = this._errorMsg(
`receiptTrie must be 32 bytes, received ${receiptTrie.length} bytes`
)
throw new Error(msg)
}
if (mixHash.length !== 32) {
throw new Error(`mixHash must be 32 bytes, received ${mixHash.length} bytes`)
const msg = this._errorMsg(`mixHash must be 32 bytes, received ${mixHash.length} bytes`)
throw new Error(msg)
}

@@ -373,6 +400,10 @@

if (nonce.length !== 65) {
throw new Error(`nonce must be 65 bytes on kovan, received ${nonce.length} bytes`)
const msg = this._errorMsg(
`nonce must be 65 bytes on kovan, received ${nonce.length} bytes`
)
throw new Error(msg)
}
} else {
throw new Error(`nonce must be 8 bytes, received ${nonce.length} bytes`)
const msg = this._errorMsg(`nonce must be 8 bytes, received ${nonce.length} bytes`)
throw new Error(msg)
}

@@ -396,6 +427,8 @@ }

}
if (!extraData.equals(Buffer.from([]))) {
errorMsg += `, extraData: ${extraData.toString('hex')} (expected: '')`
error = true
}
// WIP from merge interop event:
// extraData behavior pending consideration, for now allowed to be non-empty
// if (!extraData.equals(Buffer.from([]))) {
// errorMsg += `, extraData: ${extraData.toString('hex')} (expected: '')`
// error = true
// }
if (!mixHash.equals(zeros(32))) {

@@ -410,3 +443,4 @@ errorMsg += `, mixHash: ${mixHash.toString('hex')} (expected: ${zeros(32).toString('hex')})`

if (error) {
throw new Error('Invalid PoS block' + errorMsg)
const msg = this._errorMsg(`Invalid PoS block${errorMsg}`)
throw new Error(msg)
}

@@ -423,6 +457,10 @@ }

if (this._common.consensusType() !== ConsensusType.ProofOfWork) {
throw new Error('difficulty calculation is only supported on PoW chains')
const msg = this._errorMsg('difficulty calculation is only supported on PoW chains')
throw new Error(msg)
}
if (this._common.consensusAlgorithm() !== ConsensusAlgorithm.Ethash) {
throw new Error('difficulty calculation currently only supports the ethash algorithm')
const msg = this._errorMsg(
'difficulty calculation currently only supports the ethash algorithm'
)
throw new Error(msg)
}

@@ -509,10 +547,12 @@ const hardfork = this._getHardfork()

if (!this.difficulty.eq(CLIQUE_DIFF_INTURN) && !this.difficulty.eq(CLIQUE_DIFF_NOTURN)) {
throw new Error(
`difficulty for clique block must be INTURN (2) or NOTURN (1), received: ${this.difficulty.toString()}`
const msg = this._errorMsg(
`difficulty for clique block must be INTURN (2) or NOTURN (1), received: ${this.difficulty}`
)
throw new Error(msg)
}
if ('cliqueActiveSigners' in blockchain === false) {
throw new Error(
const msg = this._errorMsg(
'PoA blockchain requires method blockchain.cliqueActiveSigners() to validate clique difficulty'
)
throw new Error(msg)
}

@@ -595,4 +635,4 @@ const signers = (blockchain as any).cliqueActiveSigners()

) {
const msg = 'invalid amount of extra data'
throw this._error(msg)
const msg = this._errorMsg('invalid amount of extra data')
throw new Error(msg)
}

@@ -606,4 +646,6 @@ }

if (this.extraData.length !== minLength) {
const msg = `extraData must be ${minLength} bytes on non-epoch transition blocks, received ${this.extraData.length} bytes`
throw this._error(msg)
const msg = this._errorMsg(
`extraData must be ${minLength} bytes on non-epoch transition blocks, received ${this.extraData.length} bytes`
)
throw new Error(msg)
}

@@ -613,9 +655,13 @@ } else {

if (signerLength % 20 !== 0) {
const msg = `invalid signer list length in extraData, received signer length of ${signerLength} (not divisible by 20)`
throw this._error(msg)
const msg = this._errorMsg(
`invalid signer list length in extraData, received signer length of ${signerLength} (not divisible by 20)`
)
throw new Error(msg)
}
// coinbase (beneficiary) on epoch transition
if (!this.coinbase.isZero()) {
const msg = `coinbase must be filled with zeros on epoch transition blocks, received ${this.coinbase.toString()}`
throw this._error(msg)
const msg = this._errorMsg(
`coinbase must be filled with zeros on epoch transition blocks, received ${this.coinbase}`
)
throw new Error(msg)
}

@@ -625,8 +671,8 @@ }

if (!this.mixHash.equals(Buffer.alloc(32))) {
const msg = `mixHash must be filled with zeros, received ${this.mixHash}`
throw this._error(msg)
const msg = this._errorMsg(`mixHash must be filled with zeros, received ${this.mixHash}`)
throw new Error(msg)
}
if (!this.validateCliqueDifficulty(blockchain)) {
const msg = `invalid clique difficulty`
throw this._error(msg)
const msg = this._errorMsg(`invalid clique difficulty`)
throw new Error(msg)
}

@@ -638,3 +684,4 @@ }

if (!parentHeader) {
throw new Error('could not find parent header')
const msg = this._errorMsg('could not find parent header')
throw new Error(msg)
}

@@ -644,7 +691,9 @@

if (!number.eq(parentHeader.number.addn(1))) {
throw new Error('invalid number')
const msg = this._errorMsg('invalid number')
throw new Error(msg)
}
if (this.timestamp.lte(parentHeader.timestamp)) {
throw new Error('invalid timestamp')
const msg = this._errorMsg('invalid timestamp')
throw new Error(msg)
}

@@ -656,3 +705,4 @@

if (parentHeader.timestamp.addn(period).gt(this.timestamp)) {
throw new Error('invalid timestamp diff (lower than period)')
const msg = this._errorMsg('invalid timestamp diff (lower than period)')
throw new Error(msg)
}

@@ -663,3 +713,4 @@ }

if (!this.validateDifficulty(parentHeader)) {
throw new Error('invalid difficulty')
const msg = this._errorMsg('invalid difficulty')
throw new Error(msg)
}

@@ -669,3 +720,4 @@ }

if (!this.validateGasLimit(parentHeader)) {
throw new Error('invalid gas limit')
const msg = this._errorMsg('invalid gas limit')
throw new Error(msg)
}

@@ -676,3 +728,4 @@

if (!(dif.ltn(8) && dif.gtn(1))) {
throw new Error('uncle block has a parent that is too old or too young')
const msg = this._errorMsg('uncle block has a parent that is too old or too young')
throw new Error(msg)
}

@@ -683,3 +736,4 @@ }

if (this.gasUsed.gt(this.gasLimit)) {
throw new Error('Invalid block: too much gas used')
const msg = this._errorMsg('Invalid block: too much gas used')
throw new Error(msg)
}

@@ -689,3 +743,4 @@

if (!this.baseFeePerGas) {
throw new Error('EIP1559 block has no base fee field')
const msg = this._errorMsg('EIP1559 block has no base fee field')
throw new Error(msg)
}

@@ -697,3 +752,4 @@ const block = this._common.hardforkBlockBN('london')

if (!this.baseFeePerGas!.eq(initialBaseFee)) {
throw new Error('Initial EIP1559 block does not have initial base fee')
const msg = this._errorMsg('Initial EIP1559 block does not have initial base fee')
throw new Error(msg)
}

@@ -705,3 +761,4 @@ } else {

if (!this.baseFeePerGas!.eq(expectedBaseFee)) {
throw new Error('Invalid block: base fee not correct')
const msg = this._errorMsg('Invalid block: base fee not correct')
throw new Error(msg)
}

@@ -717,3 +774,6 @@ }

if (!this._common.isActivatedEIP(1559)) {
throw new Error('calcNextBaseFee() can only be called with EIP1559 being activated')
const msg = this._errorMsg(
'calcNextBaseFee() can only be called with EIP1559 being activated'
)
throw new Error(msg)
}

@@ -759,3 +819,3 @@ let nextBaseFee: BN

this.receiptTrie,
this.bloom,
this.logsBloom,
bnToUnpaddedBuffer(this.difficulty),

@@ -801,3 +861,6 @@ bnToUnpaddedBuffer(this.number),

if (this._common.consensusAlgorithm() !== ConsensusAlgorithm.Clique) {
throw new Error(`BlockHeader.${name}() call only supported for clique PoA networks`)
const msg = this._errorMsg(
`BlockHeader.${name}() call only supported for clique PoA networks`
)
throw new Error(msg)
}

@@ -873,3 +936,4 @@ }

if (!this.cliqueIsEpochTransition()) {
throw new Error('Signers are only included in epoch transition blocks (clique)')
const msg = this._errorMsg('Signers are only included in epoch transition blocks (clique)')
throw new Error(msg)
}

@@ -939,3 +1003,3 @@

receiptTrie: '0x' + this.receiptTrie.toString('hex'),
bloom: '0x' + this.bloom.toString('hex'),
logsBloom: '0x' + this.logsBloom.toString('hex'),
difficulty: bnToHex(this.difficulty),

@@ -951,20 +1015,9 @@ number: bnToHex(this.number),

if (this._common.isActivatedEIP(1559)) {
jsonDict['baseFee'] = '0x' + this.baseFeePerGas!.toString('hex')
jsonDict.baseFeePerGas = '0x' + this.baseFeePerGas!.toString('hex')
jsonDict.baseFee = '0x' + this.baseFeePerGas!.toString('hex') // deprecated alias, please use `baseFeePerGas`, will be removed in next major release
}
jsonDict.bloom = jsonDict.logsBloom // deprecated alias, please use `logsBloom`, will be removed in next major release
return jsonDict
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
_error(msg: string) {
msg += ` (${this._errorPostfix})`
const e = new Error(msg)
return e
}
private _getHardfork(): string {

@@ -991,23 +1044,52 @@ return this._common.hardfork() || this._common.activeHardfork(this.number.toNumber())

/**
* Force extra data be DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* Validates extra data is DAO_ExtraData for DAO_ForceExtraDataRange blocks after DAO
* activation block (see: https://blog.slock.it/hard-fork-specification-24b889e70703)
*/
private _checkDAOExtraData() {
private _validateDAOExtraData() {
if (!this._common.hardforkIsActiveOnChain(Hardfork.Dao)) {
return
}
const DAOActivationBlock = this._common.hardforkBlockBN(Hardfork.Dao)
if (!DAOActivationBlock || DAOActivationBlock.isZero() || this.number.lt(DAOActivationBlock)) {
return
}
const DAO_ExtraData = Buffer.from('64616f2d686172642d666f726b', 'hex')
const DAO_ForceExtraDataRange = new BN(9)
const drift = this.number.sub(DAOActivationBlock)
if (drift.lte(DAO_ForceExtraDataRange) && !this.extraData.equals(DAO_ExtraData)) {
const msg = this._errorMsg("extraData should be 'dao-hard-fork'")
throw new Error(msg)
}
}
if (this._common.hardforkIsActiveOnChain('dao')) {
// verify the extraData field.
const blockNumber = this.number
const DAOActivationBlock = this._common.hardforkBlockBN('dao')!
if (blockNumber.gte(DAOActivationBlock)) {
const drift = blockNumber.sub(DAOActivationBlock)
if (drift.lte(DAO_ForceExtraDataRange)) {
if (!this.extraData.equals(DAO_ExtraData)) {
throw new Error("extraData should be 'dao-hard-fork'")
}
}
}
/**
* Return a compact error string representation of the object
*/
public errorStr() {
let hash = ''
try {
hash = bufferToHex(this.hash())
} catch (e: any) {
hash = 'error'
}
let hf = ''
try {
hf = this._common.hardfork()
} catch (e: any) {
hf = 'error'
}
let errorStr = `block header number=${this.number} hash=${hash} `
errorStr += `hf=${hf} baseFeePerGas=${this.baseFeePerGas ?? 'none'}`
return errorStr
}
/**
* Internal helper function to create an annotated error message
*
* @param msg Base error message
* @hidden
*/
protected _errorMsg(msg: string) {
return `${msg} (${this.errorStr()})`
}
}

@@ -92,3 +92,3 @@ import { AddressLike, BNLike, BufferLike } from 'ethereumjs-util'

receiptTrie?: BufferLike
bloom?: BufferLike
logsBloom?: BufferLike
difficulty?: BNLike

@@ -103,2 +103,10 @@ number?: BNLike

baseFeePerGas?: BNLike
/*
* Backwards compatible alias for {@link HeaderData.logsBloom}
* Will only be used if {@link HeaderData.logsBloom} is undefined
* (planned to be removed in next major release)
* @deprecated
*/
bloom?: BufferLike
}

@@ -149,3 +157,3 @@

receiptTrie?: string
bloom?: string
logsBloom?: string
difficulty?: string

@@ -159,3 +167,16 @@ number?: string

nonce?: string
baseFeePerGas?: string
/*
* Backwards compatible alias for {@link JsonHeader.baseFeePerGas}
* (planned to be removed in next major release)
* @deprecated
*/
baseFee?: string
/*
* Backwards compatible alias for {@link JsonHeader.logsBloom}
* (planned to be removed in next major release)
* @deprecated
*/
bloom?: BufferLike
}

@@ -162,0 +183,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc