Skip to content

Commit

Permalink
Tx libray KZG setup instruction generalization
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 committed Feb 16, 2023
1 parent 343bda9 commit 9acf4ef
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
24 changes: 20 additions & 4 deletions packages/tx/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,32 @@ This release supports an experimental version of the blob transaction type intro

This transaction type requires additional dependencies that are not installed by default to limit bundle size.

##### Configuration
##### KZG Setup

There are two additional configuration steps needed to work with blob transactions.
For blob transactions and other KZG related proof functionality (e.g. for EVM precompiles) KZG has to be manually installed and initialized once in a global scope. The functionality is then available for all KZG usages throughout different libraries (Transaction, Block, EVM).

###### Installation

The following two manul installation steps for a KZG library and the trusted setup are needed.

1. Install an additional dependency that supports the `kzg` interface defined in [the kzg interface](./src/kzg/kzg.ts). You can install the default option [c-kzg](https://github.com/ethereum/c-kzg-4844) by simply running `npm install c-kzg`.
2. Download the trusted setup required for the KZG module. It can be found [here](../client/lib/trustedSetups/trusted_setup.txt) within the client package.

###### Global Initialization

Global initialization can then be done like this (using the `c-kzg` module for our KZG dependency):

```typescript
// Make the kzg library available globally
import * as kzg from 'c-kzg'

// Initialize the trusted setup
initKzg(kzg, 'path/to/my/trusted_setup.txt')
```

##### Usage

See the following code snipped for an example on how to instantiate (using the `c-kzg` module for our KZG dependency).
See the following code snipped for an example on how to instantiate.

```typescript
import { Chain, Common, Hardfork } from '@ethereumjs/common'
Expand Down Expand Up @@ -68,7 +84,7 @@ const txData = {
const tx = BlobEIP4844Transaction.fromTxData(txData, { common })
```

Note, the `versionedHashes`, `kzgCommitments`, and `blobs` are in reality 32 bytes or 4096 bytes in length but are trimmed here for brevity.
Note that `versionedHashes` and `kzgCommitments` have a real length of 32 bytes and `blobs` have a real length of `4096` bytes and values are trimmed here for brevity.

See the [Blob Transaction Tests](./test/eip4844.spec.ts) for examples of usage in instantiating, serializing, and deserializing these transactions.

Expand Down
22 changes: 18 additions & 4 deletions packages/tx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,29 @@ This library supports the following transaction types ([EIP-2718](https://eips.e

This library supports an experimental version of the blob transaction type introduced with [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844) as being specified in the [01d3209](https://github.com/ethereum/EIPs/commit/01d320998d1d53d95f347b5f43feaf606f230703) EIP version from February 8, 2023 and deployed along `eip4844-devnet-4` (January 2023), see PR [#2349](https://github.com/ethereumjs/ethereumjs-monorepo/pull/2349).

This transaction type requires additional dependencies that are not installed by default to limit bundle size.
##### KZG Setup

##### Configuration
For blob transactions and other KZG related proof functionality (e.g. for EVM precompiles) KZG has to be manually installed and initialized once in a global scope. The functionality is then available for all KZG usages throughout different libraries (Transaction, Block, EVM).

There are two additional configuration steps needed to work with blob transactions.
###### Installation

The following two manual installation steps for a KZG library and the trusted setup are needed.

1. Install an additional dependency that supports the `kzg` interface defined in [the kzg interface](./src/kzg/kzg.ts). You can install the default option [c-kzg](https://github.com/ethereum/c-kzg-4844) by simply running `npm install c-kzg`.
2. Download the trusted setup required for the KZG module. It can be found [here](../client/lib/trustedSetups/trusted_setup.txt) within the client package.

###### Global Initialization

Global initialization can then be done like this (using the `c-kzg` module for our KZG dependency):

```typescript
// Make the kzg library available globally
import * as kzg from 'c-kzg'

// Initialize the trusted setup
initKzg(kzg, 'path/to/my/trusted_setup.txt')
```

##### Usage

See the following code snipped for an example on how to instantiate (using the `c-kzg` module for our KZG dependency).
Expand Down Expand Up @@ -122,7 +136,7 @@ const txData = {
const tx = BlobEIP4844Transaction.fromTxData(txData, { common })
```

Note, the `versionedHashes`, `kzgCommitments`, and `blobs` are in reality 32 bytes or 4096 bytes in length but are trimmed here for brevity.
Note that `versionedHashes` and `kzgCommitments` have a real length of 32 bytes and `blobs` have a real length of `4096` bytes and values are trimmed here for brevity.

See the [Blob Transaction Tests](./test/eip4844.spec.ts) for examples of usage in instantiating, serializing, and deserializing these transactions.

Expand Down

0 comments on commit 9acf4ef

Please sign in to comment.