Skip to content

Commit

Permalink
Make trustedSetupPath in Util kzg module optional (#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerd77 authored Feb 29, 2024
1 parent 0596d16 commit b8f5b6d
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion packages/block/examples/4844.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { randomBytes } from 'crypto'

const main = async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Cancun,
Expand Down
6 changes: 3 additions & 3 deletions packages/block/test/eip4844block.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('EIP4844 header tests', () => {

beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('blob gas tests', () => {
let blobGasPerBlob: bigint
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('transaction validation tests', () => {
let blobGasPerBlob: bigint
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down
4 changes: 2 additions & 2 deletions packages/block/test/from-beacon-payload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('[fromExecutionPayloadJson]: 4844 devnet 5', () => {
let common: Common
beforeAll(async () => {
kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
const commonJson = { ...shardingJson }
commonJson.config = { ...commonJson.config, chainId: 4844001005 }
const network = 'sharding'
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('[fromExecutionPayloadJson]: kaustinen', () => {
let kzg
beforeAll(async () => {
kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
})
const network = 'kaustinen'

Expand Down
2 changes: 1 addition & 1 deletion packages/client/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ async function run() {
const chain = args.networkId ?? args.network ?? Chain.Mainnet
const cryptoFunctions: CustomCrypto = {}
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

// Initialize WASM crypto if JS crypto is not specified
if (args.useJsCrypto === false) {
Expand Down
2 changes: 1 addition & 1 deletion packages/client/devnets/4844-interop/tools/txGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getNonce(client: Client, account: string) {

async function run(data: any) {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const common = Common.fromGethGenesis(genesisJson, {
chain: genesisJson.ChainName ?? 'devnet',
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/miner/pendingBlock.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe('[PendingBlock]', async () => {

it('construct blob bundles', async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
const common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/engine/getPayloadV3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe(method, () => {
}

const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const { service, server, common } = await setupChain(genesisJSON, 'post-merge', {
engine: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/engine/kaustinen2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function runBlock(

describe(`valid verkle network setup`, async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const { server, chain, common } = await setupChain(genesisJSON, 'post-merge', {
engine: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const [blockData] = blocks
describe(`${method}: Cancun validations`, () => {
it('blobVersionedHashes', async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const { server } = await setupChain(genesisJSON, 'post-merge', {
engine: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/eth/getBlockByNumber.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { INVALID_PARAMS } from '../../../src/rpc/error-code.js'
import { createClient, createManager, dummy, getRpcClient, startRPC } from '../helpers.js'

const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const common = Common.custom({ chainId: 1 }, { customCrypto: { kzg } })

Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/eth/getTransactionReceipt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe(method, () => {
const gethGenesis = require('../../../../block/test/testdata/4844-hardfork.json')

const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
Expand Down
2 changes: 1 addition & 1 deletion packages/client/test/rpc/eth/sendRawTransaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ describe(method, () => {
const gethGenesis = require('../../../../block/test/testdata/4844-hardfork.json')

const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
Expand Down
2 changes: 1 addition & 1 deletion packages/common/examples/initKzg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { initKZG } from '@ethereumjs/util'

const main = async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
const common = new Common({
chain: Chain.Mainnet,
hardfork: Hardfork.Cancun,
Expand Down
2 changes: 1 addition & 1 deletion packages/evm/test/precompiles/0a-pointevaluation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Precompiles: point evaluation', () => {
const genesisJSON = await import('../../../client/test/testdata/geth-genesis/eip4844.json')

const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const common = Common.fromGethGenesis(genesisJSON, {
chain: 'custom',
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/examples/blobTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createKZG } from 'kzg-wasm'

const main = async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const common = new Common({
chain: Chain.Mainnet,
Expand Down
2 changes: 1 addition & 1 deletion packages/tx/examples/initKzg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { initKZG } from '@ethereumjs/util'

const main = async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

// Instantiate `common`
const common = new Common({
Expand Down
14 changes: 7 additions & 7 deletions packages/tx/test/eip4844.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('EIP4844 addSignature tests', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('EIP4844 constructor tests - valid scenarios', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -130,7 +130,7 @@ describe('fromTxData using from a json', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('EIP4844 constructor tests - invalid scenarios', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -259,7 +259,7 @@ describe('Network wrapper tests', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -503,7 +503,7 @@ describe('hash() and signature verification', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down Expand Up @@ -554,7 +554,7 @@ describe('Network wrapper deserialization test', () => {
let common: Common
beforeAll(async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
common = Common.fromGethGenesis(gethGenesis, {
chain: 'customChain',
hardfork: Hardfork.Cancun,
Expand Down
4 changes: 2 additions & 2 deletions packages/util/src/kzg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Interface for an externally provided kzg library used when creating blob transactions
*/
export interface Kzg {
loadTrustedSetup(filePath: string): void
loadTrustedSetup(filePath?: string): void
blobToKzgCommitment(blob: Uint8Array): Uint8Array
computeBlobKzgProof(blob: Uint8Array, commitment: Uint8Array): Uint8Array
verifyKzgProof(
Expand Down Expand Up @@ -35,7 +35,7 @@ export let kzg: Kzg = {
* @param kzgLib a KZG implementation (defaults to c-kzg)
* @param trustedSetupPath the full path (e.g. "/home/linux/devnet4.txt") to a kzg trusted setup text file
*/
export function initKZG(kzgLib: Kzg, trustedSetupPath: string) {
export function initKZG(kzgLib: Kzg, trustedSetupPath?: string) {
kzg = kzgLib
kzg.loadTrustedSetup(trustedSetupPath)
}
2 changes: 1 addition & 1 deletion packages/vm/test/api/EIPs/eip-4844-blobs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('EIP4844 tests', () => {
try {
//initKZG(kzg, __dirname + '/../../client/src/trustedSetups/official.txt')
kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
} catch {
// no-op
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/test/api/runTx.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ it('Validate SELFDESTRUCT does not charge new account gas when calling CALLER an
describe('EIP 4844 transaction tests', () => {
it('should work', async () => {
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)

const genesisJson = require('../../../block/test/testdata/4844-hardfork.json')
const common = Common.fromGethGenesis(genesisJson, {
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/test/tester/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function runTests() {
* Run-time configuration
*/
const kzg = await createKZG()
initKZG(kzg, '')
initKZG(kzg)
const runnerArgs: {
forkConfigVM: string
forkConfigTestSuite: string
Expand Down

0 comments on commit b8f5b6d

Please sign in to comment.