diff --git a/package-lock.json b/package-lock.json index 3e84b5c70a1..493d16d0db5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1843,11 +1843,6 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, - "node_modules/@chainsafe/as-sha256": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@chainsafe/as-sha256/-/as-sha256-0.4.1.tgz", - "integrity": "sha512-IqeeGwQihK6Y2EYLFofqs2eY2ep1I2MvQXHzOAI+5iQN51OZlUkrLgyAugu2x86xZewDk5xas7lNczkzFzF62w==" - }, "node_modules/@chainsafe/libp2p-noise": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-noise/-/libp2p-noise-4.1.2.tgz", @@ -1914,24 +1909,6 @@ "node": ">=12.0.0" } }, - "node_modules/@chainsafe/persistent-merkle-tree": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.6.1.tgz", - "integrity": "sha512-gcENLemRR13+1MED2NeZBMA7FRS0xQPM7L2vhMqvKkjqtFT4YfjSVADq5U0iLuQLhFUJEMVuA8fbv5v+TN6O9A==", - "dependencies": { - "@chainsafe/as-sha256": "^0.4.1", - "@noble/hashes": "^1.3.0" - } - }, - "node_modules/@chainsafe/ssz": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/@chainsafe/ssz/-/ssz-0.11.1.tgz", - "integrity": "sha512-cB8dBkgGN6ZoeOKuk+rIRHKN0L5i9JLGeC0Lui71QX0TuLcQKwgbfkUexpyJxnGFatWf8yeJxlOjozMn/OTP0g==", - "dependencies": { - "@chainsafe/as-sha256": "^0.4.1", - "@chainsafe/persistent-merkle-tree": "^0.6.1" - } - }, "node_modules/@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -20066,7 +20043,6 @@ "version": "4.1.2", "license": "MPL-2.0", "dependencies": { - "@chainsafe/ssz": "^0.11.1", "@ethereumjs/common": "^3.1.2", "@ethereumjs/rlp": "^4.0.1", "@ethereumjs/util": "^8.0.6", @@ -20095,7 +20071,6 @@ "version": "8.0.6", "license": "MPL-2.0", "dependencies": { - "@chainsafe/ssz": "^0.11.1", "@ethereumjs/rlp": "^4.0.1", "ethereum-cryptography": "^2.0.0" }, @@ -21503,11 +21478,6 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, - "@chainsafe/as-sha256": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/@chainsafe/as-sha256/-/as-sha256-0.4.1.tgz", - "integrity": "sha512-IqeeGwQihK6Y2EYLFofqs2eY2ep1I2MvQXHzOAI+5iQN51OZlUkrLgyAugu2x86xZewDk5xas7lNczkzFzF62w==" - }, "@chainsafe/libp2p-noise": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/@chainsafe/libp2p-noise/-/libp2p-noise-4.1.2.tgz", @@ -21569,24 +21539,6 @@ } } }, - "@chainsafe/persistent-merkle-tree": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/@chainsafe/persistent-merkle-tree/-/persistent-merkle-tree-0.6.1.tgz", - "integrity": "sha512-gcENLemRR13+1MED2NeZBMA7FRS0xQPM7L2vhMqvKkjqtFT4YfjSVADq5U0iLuQLhFUJEMVuA8fbv5v+TN6O9A==", - "requires": { - "@chainsafe/as-sha256": "^0.4.1", - "@noble/hashes": "^1.3.0" - } - }, - "@chainsafe/ssz": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/@chainsafe/ssz/-/ssz-0.11.1.tgz", - "integrity": "sha512-cB8dBkgGN6ZoeOKuk+rIRHKN0L5i9JLGeC0Lui71QX0TuLcQKwgbfkUexpyJxnGFatWf8yeJxlOjozMn/OTP0g==", - "requires": { - "@chainsafe/as-sha256": "^0.4.1", - "@chainsafe/persistent-merkle-tree": "^0.6.1" - } - }, "@colors/colors": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", @@ -21973,7 +21925,6 @@ "@ethereumjs/tx": { "version": "file:packages/tx", "requires": { - "@chainsafe/ssz": "^0.11.1", "@ethereumjs/common": "^3.1.2", "@ethereumjs/rlp": "^4.0.1", "@ethereumjs/util": "^8.0.6", @@ -21987,7 +21938,6 @@ "@ethereumjs/util": { "version": "file:packages/util", "requires": { - "@chainsafe/ssz": "^0.11.1", "@ethereumjs/rlp": "^4.0.1", "@types/bn.js": "^5.1.0", "@types/secp256k1": "^4.0.1", diff --git a/packages/block/src/block.ts b/packages/block/src/block.ts index 659a1c55d54..b86aa9cbf27 100644 --- a/packages/block/src/block.ts +++ b/packages/block/src/block.ts @@ -14,7 +14,6 @@ import { hexStringToBytes, intToHex, isHexPrefixed, - ssz, } from '@ethereumjs/util' import { keccak256 } from 'ethereum-cryptography/keccak' @@ -66,14 +65,6 @@ export class Block { return trie.root() } - /** - * Returns the ssz root for array of withdrawal transactions. - * @param wts array of Withdrawal to compute the root of - */ - public static async generateWithdrawalsSSZRoot(withdrawals: Withdrawal[]) { - ssz.Withdrawals.hashTreeRoot(withdrawals.map((wt) => wt.toValue())) - } - /** * Returns the txs trie root for array of TypedTransaction * @param txs array of TypedTransaction to compute the root of diff --git a/packages/tx/package.json b/packages/tx/package.json index 0b8b0025012..70cefd4dea4 100644 --- a/packages/tx/package.json +++ b/packages/tx/package.json @@ -57,7 +57,6 @@ "tsc": "../../config/cli/ts-compile.sh" }, "dependencies": { - "@chainsafe/ssz": "^0.11.1", "@ethereumjs/common": "^3.1.2", "@ethereumjs/rlp": "^4.0.1", "@ethereumjs/util": "^8.0.6", diff --git a/packages/tx/src/eip4844Transaction.ts b/packages/tx/src/eip4844Transaction.ts index d4d12d3048e..763489f1a12 100644 --- a/packages/tx/src/eip4844Transaction.ts +++ b/packages/tx/src/eip4844Transaction.ts @@ -1,4 +1,3 @@ -import { byteArrayEquals } from '@chainsafe/ssz' import { RLP } from '@ethereumjs/rlp' import { MAX_INTEGER, @@ -58,7 +57,7 @@ const validateBlobTransactionNetworkWrapper = ( for (let x = 0; x < versionedHashes.length; x++) { const computedVersionedHash = computeVersionedHash(commitments[x], version) - if (!byteArrayEquals(computedVersionedHash, versionedHashes[x])) { + if (!equalsBytes(computedVersionedHash, versionedHashes[x])) { throw new Error(`commitment for blob at index ${x} does not match versionedHash`) } } diff --git a/packages/util/package.json b/packages/util/package.json index 1d1b77e0cf1..8ee63b1674a 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -89,7 +89,6 @@ "tsc": "../../config/cli/ts-compile.sh" }, "dependencies": { - "@chainsafe/ssz": "^0.11.1", "@ethereumjs/rlp": "^4.0.1", "ethereum-cryptography": "^2.0.0" }, diff --git a/packages/util/src/index.ts b/packages/util/src/index.ts index 7ba80184ca0..152211ed926 100644 --- a/packages/util/src/index.ts +++ b/packages/util/src/index.ts @@ -38,11 +38,6 @@ export * from './signature' */ export * from './bytes' -/** - * SSZ containers - */ -export * as ssz from './ssz' - /** * Helpful TypeScript types */ diff --git a/packages/util/src/ssz.ts b/packages/util/src/ssz.ts deleted file mode 100644 index 1b8462148f1..00000000000 --- a/packages/util/src/ssz.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { - ByteVectorType, - ContainerType, - ListCompositeType, - UintBigintType, - UintNumberType, -} from '@chainsafe/ssz' - -import { MAX_WITHDRAWALS_PER_PAYLOAD } from './constants' - -export const UintNum64 = new UintNumberType(8) -export const UintBigInt64 = new UintBigintType(8) -export const Bytes20 = new ByteVectorType(20) - -export const Withdrawal = new ContainerType( - { - index: UintBigInt64, - validatorIndex: UintBigInt64, - address: Bytes20, - amount: UintBigInt64, - }, - { typeName: 'Withdrawal', jsonCase: 'eth2' } -) -export const Withdrawals = new ListCompositeType(Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD) diff --git a/packages/util/test/ssz.spec.ts b/packages/util/test/ssz.spec.ts deleted file mode 100644 index ebd8b233d36..00000000000 --- a/packages/util/test/ssz.spec.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { bytesToHex, hexToBytes } from 'ethereum-cryptography/utils' -import * as tape from 'tape' - -import { Withdrawal, ssz } from '../src' -const withdrawalsData = [ - { - index: BigInt(0), - validatorIndex: BigInt(65535), - address: hexToBytes('0000000000000000000000000000000000000000'), - amount: BigInt('0'), - }, - { - index: BigInt(1), - validatorIndex: BigInt(65536), - address: hexToBytes('0100000000000000000000000000000000000000'), - amount: BigInt('04523128485832663883'), - }, - { - index: BigInt(2), - validatorIndex: BigInt(65537), - address: hexToBytes('0200000000000000000000000000000000000000'), - amount: BigInt('09046256971665327767'), - }, - { - index: BigInt(4), - validatorIndex: BigInt(65538), - address: hexToBytes('0300000000000000000000000000000000000000'), - amount: BigInt('13569385457497991651'), - }, - { - index: BigInt(4), - validatorIndex: BigInt(65539), - address: hexToBytes('0400000000000000000000000000000000000000'), - amount: BigInt('18446744073709551615'), - }, - { - index: BigInt(5), - validatorIndex: BigInt(65540), - address: hexToBytes('0500000000000000000000000000000000000000'), - amount: BigInt('02261564242916331941'), - }, - { - index: BigInt(6), - validatorIndex: BigInt(65541), - address: hexToBytes('0600000000000000000000000000000000000000'), - amount: BigInt('02713877091499598330'), - }, - { - index: BigInt(7), - validatorIndex: BigInt(65542), - address: hexToBytes('0700000000000000000000000000000000000000'), - amount: BigInt('03166189940082864718'), - }, -] - -tape('ssz', (t) => { - t.test('withdrawals', (st) => { - const withdrawals = withdrawalsData.map((wt) => Withdrawal.fromWithdrawalData(wt)) - const withdrawalsValue = withdrawals.map((wt) => wt.toValue()) - const sszValues = ssz.Withdrawals.toViewDU(withdrawalsData).toValue() - - st.deepEqual(sszValues, withdrawalsValue, 'sszValues should be same as withdrawalsValue') - const withdrawalsRoot = ssz.Withdrawals.hashTreeRoot(withdrawalsValue) - st.equal( - bytesToHex(withdrawalsRoot), - 'bd97f65e513f870484e85927510acb291fcfb3e593c05ab7f21f206921264946', - 'ssz root should match' - ) - st.end() - }) - - const specWithdrawals = [ - // https://github.com/ethereum/consensus-spec-tests/tree/v1.3.0-rc.1/tests/mainnet/capella/ssz_static/Withdrawal/ssz_random/case_0 - { - index: BigInt('17107150653359250726'), - validatorIndex: BigInt('1906681273455760070'), - address: hexToBytes('02ab1379b6334b58df82c85d50ff1214663cba20'), - amount: BigInt('5055030296454530815'), - }, - ] - - t.test('match spec v1.3.0-rc.1', (st) => { - const withdrawalsRoot = ssz.Withdrawal.hashTreeRoot(specWithdrawals[0]) - st.equal( - bytesToHex(withdrawalsRoot), - 'ed9cec6fb8ee22b146059d02c38940cca1dd22a00d0132b000999b983fceff95', - 'ssz root should match' - ) - st.end() - }) -})