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

@ethereumjs/block

Package Overview
Dependencies
Maintainers
6
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.1.0 to 3.2.0

30

CHANGELOG.md

@@ -9,2 +9,32 @@ # Changelog

## 3.2.0 - 2021-03-18
### Berlin HF Support
This release gets the `Block` library ready for the `berlin` HF by adding support for [EIP2718](https://eips.ethereum.org/EIPS/eip-2718) Typed Transactions. Transaction objects are now created with the new `TransactionFactory` introduced with the `@ethereumjs/tx` `v3.1.0` release which chooses the correct tx type for the data. The initial tx release supports the old legacy transactions and the newly added [EIP2930](https://eips.ethereum.org/EIPS/eip-2930) Access List Transaction Type, see PR [#1048](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1048).
Please note that the default HF is still set to `istanbul`. You therefore need to explicitly set the `hardfork` parameter for instantiating a `Block` instance with a `berlin` HF activated:
```typescript
import { Block } from 'ethereumjs-block'
import Common from '@ethereumjs/common'
const common = new Common({ chain: 'mainnet', hardfork: 'berlin' })
const block = Block.fromBlockData({}, { common })
```
#### EthereumJS Libraries - Typed Transactions Readiness
If you are using this library in conjunction with other EthereumJS libraries make sure to minimally have the following library versions installed for typed transaction support:
- `@ethereumjs/common` `v2.2.0`
- `@ethereumjs/tx` `v3.1.0`
- `@ethereumjs/block` `v3.2.0`
- `@ethereumjs/blockchain` `v5.2.0`
- `@ethereumjs/vm` `v5.2.0`
### Other Changes
- Added support for very large chain IDs when using Block `cliqueSigner()` address recovery, PR [#1139](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1139)
- Fixed a TS compilation failure on install relating to `ethereumjs-util` `v7.0.9`, PR [#1136](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1136)
## 3.1.0 - 2021-02-22

@@ -11,0 +41,0 @@

8

dist.browser/block.d.ts

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

import Common from '@ethereumjs/common';
import { Transaction } from '@ethereumjs/tx';
import { TypedTransaction } from '@ethereumjs/tx';
import { BlockHeader } from './header';

@@ -15,3 +15,3 @@ import { BlockData, BlockOptions, JsonBlock, BlockBuffer, Blockchain } from './types';

readonly header: BlockHeader;
readonly transactions: Transaction[];
readonly transactions: TypedTransaction[];
readonly uncleHeaders: BlockHeader[];

@@ -49,5 +49,5 @@ readonly txTrie: Trie;

*/
constructor(header?: BlockHeader, transactions?: Transaction[], uncleHeaders?: BlockHeader[], opts?: BlockOptions);
constructor(header?: BlockHeader, transactions?: TypedTransaction[], uncleHeaders?: BlockHeader[], opts?: BlockOptions);
/**
* Returns a Buffer Array of the raw Buffers of this block, in order.
* Returns a Buffer Array of the raw Buffers of this block, in order.
*/

@@ -54,0 +54,0 @@ raw(): BlockBuffer;

@@ -127,3 +127,3 @@ "use strict";

var txData = _d.value;
var tx = tx_1.Transaction.fromTxData(txData, __assign(__assign({}, opts), {
var tx = tx_1.TransactionFactory.fromTxData(txData, __assign(__assign({}, opts), {
// Use header common in case of hardforkByBlockNumber being activated

@@ -195,3 +195,3 @@ common: header._common }));

var txData = _e.value;
transactions.push(tx_1.Transaction.fromValuesArray(txData, __assign(__assign({}, opts), {
transactions.push(tx_1.TransactionFactory.fromBlockBodyData(txData, __assign(__assign({}, opts), {
// Use header common in case of hardforkByBlockNumber being activated

@@ -238,3 +238,3 @@ common: header._common })));

/**
* Returns a Buffer Array of the raw Buffers of this block, in order.
* Returns a Buffer Array of the raw Buffers of this block, in order.
*/

@@ -244,3 +244,5 @@ Block.prototype.raw = function () {

this.header.raw(),
this.transactions.map(function (tx) { return tx.raw(); }),
this.transactions.map(function (tx) {
return 'transactionType' in tx && tx.transactionType > 0 ? tx.serialize() : tx.raw();
}),
this.uncleHeaders.map(function (uh) { return uh.raw(); }),

@@ -247,0 +249,0 @@ ];

@@ -52,3 +52,3 @@ "use strict";

var txParams = normalizeTxParams(_txParams);
var tx = tx_1.Transaction.fromTxData(txParams, opts);
var tx = tx_1.TransactionFactory.fromTxData(txParams, opts);
transactions.push(tx);

@@ -55,0 +55,0 @@ }

@@ -105,5 +105,2 @@ "use strict";

if (options.initWithGenesisHeader) {
if (this._common.hardfork() !== 'chainstart') {
throw new Error('Genesis parameters can only be set with a Common instance set to chainstart');
}
number = new ethereumjs_util_1.BN(0);

@@ -607,3 +604,3 @@ if (gasLimit.eq(DEFAULT_GAS_LIMIT)) {

var s = extraSeal.slice(32, 64);
var v = ethereumjs_util_1.bufferToInt(extraSeal.slice(64, 65)) + 27;
var v = new ethereumjs_util_1.BN(extraSeal.slice(64, 65)).addn(27);
var pubKey = ethereumjs_util_1.ecrecover(this.cliqueSigHash(), v, r, s);

@@ -689,3 +686,3 @@ return ethereumjs_util_1.Address.fromPublicKey(pubKey);

var blockNumber = this.number;
var DAOActivationBlock = new ethereumjs_util_1.BN(this._common.hardforkBlock('dao'));
var DAOActivationBlock = this._common.hardforkBlockBN('dao');
if (blockNumber.gte(DAOActivationBlock)) {

@@ -692,0 +689,0 @@ var drift = blockNumber.sub(DAOActivationBlock);

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

export declare type BlockBodyBuffer = [TransactionsBuffer, UncleHeadersBuffer];
export declare type TransactionsBuffer = Buffer[][];
/**
* TransactionsBuffer can be an array of serialized txs for Typed Transactions or an array of Buffer Arrays for legacy transactions.
*/
export declare type TransactionsBuffer = Buffer[][] | Buffer[];
export declare type UncleHeadersBuffer = Buffer[][];

@@ -102,0 +105,0 @@ /**

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

import Common from '@ethereumjs/common';
import { Transaction } from '@ethereumjs/tx';
import { TypedTransaction } from '@ethereumjs/tx';
import { BlockHeader } from './header';

@@ -15,3 +15,3 @@ import { BlockData, BlockOptions, JsonBlock, BlockBuffer, Blockchain } from './types';

readonly header: BlockHeader;
readonly transactions: Transaction[];
readonly transactions: TypedTransaction[];
readonly uncleHeaders: BlockHeader[];

@@ -49,5 +49,5 @@ readonly txTrie: Trie;

*/
constructor(header?: BlockHeader, transactions?: Transaction[], uncleHeaders?: BlockHeader[], opts?: BlockOptions);
constructor(header?: BlockHeader, transactions?: TypedTransaction[], uncleHeaders?: BlockHeader[], opts?: BlockOptions);
/**
* Returns a Buffer Array of the raw Buffers of this block, in order.
* Returns a Buffer Array of the raw Buffers of this block, in order.
*/

@@ -54,0 +54,0 @@ raw(): BlockBuffer;

@@ -46,3 +46,3 @@ "use strict";

for (const txData of txsData || []) {
const tx = tx_1.Transaction.fromTxData(txData, Object.assign(Object.assign({}, opts), {
const tx = tx_1.TransactionFactory.fromTxData(txData, Object.assign(Object.assign({}, opts), {
// Use header common in case of hardforkByBlockNumber being activated

@@ -93,3 +93,3 @@ common: header._common }));

for (const txData of txsData || []) {
transactions.push(tx_1.Transaction.fromValuesArray(txData, Object.assign(Object.assign({}, opts), {
transactions.push(tx_1.TransactionFactory.fromBlockBodyData(txData, Object.assign(Object.assign({}, opts), {
// Use header common in case of hardforkByBlockNumber being activated

@@ -117,3 +117,3 @@ common: header._common })));

/**
* Returns a Buffer Array of the raw Buffers of this block, in order.
* Returns a Buffer Array of the raw Buffers of this block, in order.
*/

@@ -123,3 +123,3 @@ raw() {

this.header.raw(),
this.transactions.map((tx) => tx.raw()),
this.transactions.map((tx) => 'transactionType' in tx && tx.transactionType > 0 ? tx.serialize() : tx.raw()),
this.uncleHeaders.map((uh) => uh.raw()),

@@ -126,0 +126,0 @@ ];

@@ -37,3 +37,3 @@ "use strict";

const txParams = normalizeTxParams(_txParams);
const tx = tx_1.Transaction.fromTxData(txParams, opts);
const tx = tx_1.TransactionFactory.fromTxData(txParams, opts);
transactions.push(tx);

@@ -40,0 +40,0 @@ }

@@ -41,5 +41,2 @@ "use strict";

if (options.initWithGenesisHeader) {
if (this._common.hardfork() !== 'chainstart') {
throw new Error('Genesis parameters can only be set with a Common instance set to chainstart');
}
number = new ethereumjs_util_1.BN(0);

@@ -529,3 +526,3 @@ if (gasLimit.eq(DEFAULT_GAS_LIMIT)) {

const s = extraSeal.slice(32, 64);
const v = ethereumjs_util_1.bufferToInt(extraSeal.slice(64, 65)) + 27;
const v = new ethereumjs_util_1.BN(extraSeal.slice(64, 65)).addn(27);
const pubKey = ethereumjs_util_1.ecrecover(this.cliqueSigHash(), v, r, s);

@@ -600,3 +597,3 @@ return ethereumjs_util_1.Address.fromPublicKey(pubKey);

const blockNumber = this.number;
const DAOActivationBlock = new ethereumjs_util_1.BN(this._common.hardforkBlock('dao'));
const DAOActivationBlock = this._common.hardforkBlockBN('dao');
if (blockNumber.gte(DAOActivationBlock)) {

@@ -603,0 +600,0 @@ const drift = blockNumber.sub(DAOActivationBlock);

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

export declare type BlockBodyBuffer = [TransactionsBuffer, UncleHeadersBuffer];
export declare type TransactionsBuffer = Buffer[][];
/**
* TransactionsBuffer can be an array of serialized txs for Typed Transactions or an array of Buffer Arrays for legacy transactions.
*/
export declare type TransactionsBuffer = Buffer[][] | Buffer[];
export declare type UncleHeadersBuffer = Buffer[][];

@@ -102,0 +105,0 @@ /**

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

@@ -29,3 +29,3 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/ethereumjs/ethereumjs-vm.git"
"url": "git+https://github.com/ethereumjs/ethereumjs-monorepo.git"
},

@@ -39,11 +39,10 @@ "keywords": [

"bugs": {
"url": "https://github.com/ethereumjs/ethereumjs-vm/issues?q=is%3Aissue+label%3A%22package%3A+block%22"
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+block%22"
},
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/block#readme",
"homepage": "https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/block#readme",
"dependencies": {
"@ethereumjs/common": "^2.1.0",
"@ethereumjs/common": "^2.2.0",
"merkle-patricia-tree": "^4.1.0",
"@ethereumjs/tx": "^3.0.2",
"@types/bn.js": "^4.11.6",
"ethereumjs-util": "^7.0.8"
"@ethereumjs/tx": "^3.1.0",
"ethereumjs-util": "^7.0.9"
},

@@ -50,0 +49,0 @@ "devDependencies": {

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