Skip to content

Commit

Permalink
fix: remove hashtree
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Jun 26, 2024
1 parent e0857e1 commit f9825bb
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 785 deletions.
179 changes: 0 additions & 179 deletions packages/persistent-merkle-tree/src/hasher/hashtree.ts

This file was deleted.

9 changes: 1 addition & 8 deletions packages/persistent-merkle-tree/test/unit/hasher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import {expectEqualHex} from "../utils/expectHex";
import {uint8ArrayToHashObject, hashObjectToUint8Array} from "../../src/hasher/util";
import {hasher as nobleHasher} from "../../src/hasher/noble";
import {hasher as asSha256Hasher} from "../../src/hasher/as-sha256";
import {hasher as hashtreeHasher} from "../../src/hasher/hashtree";
import {linspace} from "../utils/misc";
import {buildComparisonTrees} from "../utils/tree";

const hashers = [hashtreeHasher, asSha256Hasher, nobleHasher];
const hashers = [asSha256Hasher, nobleHasher];

describe("hashers", function () {
describe("digest64 vs digest64HashObjects methods should be the same", () => {
Expand All @@ -30,9 +29,7 @@ describe("hashers", function () {
const root2 = Buffer.alloc(32, 0xff);
const hash1 = nobleHasher.digest64(root1, root2);
const hash2 = asSha256Hasher.digest64(root1, root2);
const hash3 = hashtreeHasher.digest64(root1, root2);
expectEqualHex(hash1, hash2);
expectEqualHex(hash1, hash3);
});

it("all hashers should return the same values from digest64HashObjects", () => {
Expand All @@ -42,9 +39,7 @@ describe("hashers", function () {
const hashObject2 = uint8ArrayToHashObject(root2);
const hash1 = hashObjectToUint8Array(nobleHasher.digest64HashObjects(hashObject1, hashObject2));
const hash2 = hashObjectToUint8Array(asSha256Hasher.digest64HashObjects(hashObject1, hashObject2));
const hash3 = hashObjectToUint8Array(hashtreeHasher.digest64HashObjects(hashObject1, hashObject2));
expectEqualHex(hash1, hash2);
expectEqualHex(hash1, hash3);
});

it("all hashers should return the same values from batchHashObjects", () => {
Expand All @@ -53,10 +48,8 @@ describe("hashers", function () {
.map(uint8ArrayToHashObject);
const results1 = nobleHasher.batchHashObjects(hashObjects).map(hashObjectToUint8Array);
const results2 = asSha256Hasher.batchHashObjects(hashObjects).map(hashObjectToUint8Array);
const results3 = hashtreeHasher.batchHashObjects(hashObjects).map(hashObjectToUint8Array);
Object.values(results1).forEach((result1, i) => {
expectEqualHex(result1, results2[i]);
expectEqualHex(result1, results3[i]);
});
});

Expand Down
15 changes: 0 additions & 15 deletions packages/ssz/test/lodestarTypes/phase0/listValidator.ts

This file was deleted.

4 changes: 1 addition & 3 deletions packages/ssz/test/lodestarTypes/phase0/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
ATTESTATION_SUBNET_COUNT,
} from "../params";
import * as primitiveSsz from "../primitive/sszTypes";
import {ListValidatorType} from "./listValidator";
import {ValidatorNodeStruct} from "./validator";

export {ValidatorNodeStruct};
Expand Down Expand Up @@ -252,8 +251,7 @@ export const ValidatorContainer = new ContainerType(
export const Validator = ValidatorNodeStruct;

// Export as stand-alone for direct tree optimizations
// export const Validators = new ListCompositeType(ValidatorNodeStruct, VALIDATOR_REGISTRY_LIMIT);
export const Validators = new ListValidatorType(VALIDATOR_REGISTRY_LIMIT);
export const Validators = new ListCompositeType(ValidatorNodeStruct, VALIDATOR_REGISTRY_LIMIT);
export const Balances = new ListUintNum64Type(VALIDATOR_REGISTRY_LIMIT);
export const RandaoMixes = new VectorCompositeType(Bytes32, EPOCHS_PER_HISTORICAL_VECTOR);
export const Slashings = new VectorBasicType(Gwei, EPOCHS_PER_SLASHINGS_VECTOR);
Expand Down
6 changes: 0 additions & 6 deletions packages/ssz/test/lodestarTypes/phase0/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import {ByteViews} from "../../../src/type/abstract";
import {ContainerNodeStructType} from "../../../src/type/containerNodeStruct";
import {ValueOfFields} from "../../../src/view/container";
import * as primitiveSsz from "../primitive/sszTypes";
import { ValidatorTreeViewDU } from "./viewDU/validator";
import {Node} from "@chainsafe/persistent-merkle-tree";

const {Boolean, Bytes32, UintNum64, BLSPubkey, EpochInf} = primitiveSsz;

Expand Down Expand Up @@ -37,10 +35,6 @@ export class ValidatorNodeStructType extends ContainerNodeStructType<typeof Vali
super(ValidatorType, {typeName: "Validator", jsonCase: "eth2"});
}

getViewDU(node: Node): ValidatorTreeViewDU {
return new ValidatorTreeViewDU(this, node);
}

value_serializeToBytes(
{uint8Array: output, dataView}: ByteViews,
offset: number,
Expand Down
Loading

0 comments on commit f9825bb

Please sign in to comment.