From 4062cdc0f82eb65941e78440bdec6cb1cb80ca8b Mon Sep 17 00:00:00 2001 From: Angus Dippenaar Date: Sun, 5 Feb 2023 16:10:19 +0100 Subject: [PATCH 1/2] switch to upstream go-merkletree --- go.mod | 4 +--- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 7316cec57..65d9fef01 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,7 @@ require ( github.com/wealdtech/go-eth2-types/v2 v2.7.0 github.com/wealdtech/go-eth2-util v1.7.0 github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.3.0 - github.com/wealdtech/go-merkletree v1.0.1-0.20190605192610-2bb163c2ea2a + github.com/wealdtech/go-merkletree v1.0.1-0.20230205101955-ec7a95ea11ca github.com/web3-storage/go-w3s-client v0.0.7 golang.org/x/crypto v0.4.0 golang.org/x/sync v0.1.0 @@ -182,6 +182,4 @@ require ( nhooyr.io/websocket v1.8.7 // indirect ) -replace github.com/wealdtech/go-merkletree v1.0.1-0.20190605192610-2bb163c2ea2a => github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd - // replace github.com/rocket-pool/rocketpool-go => ../rocketpool-go diff --git a/go.sum b/go.sum index 5ccffa56b..ec587dcfc 100644 --- a/go.sum +++ b/go.sum @@ -1624,8 +1624,6 @@ github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rjeczalik/notify v0.9.1 h1:CLCKso/QK1snAlnhNR/CNvNiFU2saUtjV0bx3EwNeCE= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= -github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd h1:p9KuetSKB9nte9I/MkkiM3pwKFVQgqxxPTQ0y56Ff6s= -github.com/rocket-pool/go-merkletree v1.0.1-0.20220406020931-c262d9b976dd/go.mod h1:UE9fof8P7iESVtLn1K9CTSkNRYVFHZHlf96RKbU33kA= github.com/rocket-pool/rocketpool-go v1.4.2 h1:Jp1X4hkaRthVu7YMXgip+n2K8tvLwPjlGEutpti658I= github.com/rocket-pool/rocketpool-go v1.4.2/go.mod h1:+7kSXEvMUCEqstio3PBVTnaGoI2lSTwNUJ8/D4D91gM= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= @@ -1817,6 +1815,8 @@ github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.3.0 h1:3Kx2QvKU/4PP0 github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4 v1.3.0/go.mod h1:qqIU42c9sXcNYsiEjUQoOOWYZfZDL1zmyLtz3t+wN2s= github.com/wealdtech/go-eth2-wallet-types/v2 v2.9.0 h1:XqWgsONVqsPvciuEXxM/QU4hYouBVk0+5/pGqDMGUHQ= github.com/wealdtech/go-eth2-wallet-types/v2 v2.9.0/go.mod h1:7Ad2xp27vOQRQWQsIeHBdU/YiyEt6klBeh5gwnNnlwE= +github.com/wealdtech/go-merkletree v1.0.1-0.20230205101955-ec7a95ea11ca h1:oK35INPN4CiubFw7ZPQkbxm2AsSU6Tjeb9YhciZnvIM= +github.com/wealdtech/go-merkletree v1.0.1-0.20230205101955-ec7a95ea11ca/go.mod h1:bM9mDSjsti+gkjl8FjovMoUH3MPR5bwJ3+ucaYFY0Jk= github.com/wealdtech/go-multicodec v1.4.0 h1:iq5PgxwssxnXGGPTIK1srvt6U5bJwIp7k6kBrudIWxg= github.com/wealdtech/go-multicodec v1.4.0/go.mod h1:aedGMaTeYkIqi/KCPre1ho5rTb3hGpu/snBOS3GQLw4= github.com/wealdtech/go-string2eth v1.1.0 h1:USJQmysUrBYYmZs7d45pMb90hRSyEwizP7lZaOZLDAw= From 56ed20ed2a309f992d22533a6c8dd2d7ee763d73 Mon Sep 17 00:00:00 2001 From: Angus Dippenaar Date: Sun, 5 Feb 2023 16:55:15 +0100 Subject: [PATCH 2/2] Use new go-merkletree functions --- shared/services/rewards/generator-impl-v1.go | 6 +++++- shared/services/rewards/generator-impl-v2.go | 6 +++++- shared/services/rewards/generator-impl-v3.go | 6 +++++- shared/services/rewards/generator-impl-v4.go | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/shared/services/rewards/generator-impl-v1.go b/shared/services/rewards/generator-impl-v1.go index 3ac623050..95c45b7d5 100644 --- a/shared/services/rewards/generator-impl-v1.go +++ b/shared/services/rewards/generator-impl-v1.go @@ -247,7 +247,11 @@ func (r *treeGeneratorImpl_v1) generateMerkleTree() error { } // Generate the tree - tree, err := merkletree.NewUsing(totalData, keccak256.New(), false, true) + tree, err := merkletree.NewTree( + merkletree.WithData(totalData), + merkletree.WithHashType(keccak256.New()), + merkletree.WithSorted(true), + ) if err != nil { return fmt.Errorf("error generating Merkle Tree: %w", err) } diff --git a/shared/services/rewards/generator-impl-v2.go b/shared/services/rewards/generator-impl-v2.go index 5e8932ec1..08b4a679a 100644 --- a/shared/services/rewards/generator-impl-v2.go +++ b/shared/services/rewards/generator-impl-v2.go @@ -251,7 +251,11 @@ func (r *treeGeneratorImpl_v2) generateMerkleTree() error { } // Generate the tree - tree, err := merkletree.NewUsing(totalData, keccak256.New(), false, true) + tree, err := merkletree.NewTree( + merkletree.WithData(totalData), + merkletree.WithHashType(keccak256.New()), + merkletree.WithSorted(true), + ) if err != nil { return fmt.Errorf("error generating Merkle Tree: %w", err) } diff --git a/shared/services/rewards/generator-impl-v3.go b/shared/services/rewards/generator-impl-v3.go index 48516d354..992bbcd9d 100644 --- a/shared/services/rewards/generator-impl-v3.go +++ b/shared/services/rewards/generator-impl-v3.go @@ -247,7 +247,11 @@ func (r *treeGeneratorImpl_v3) generateMerkleTree() error { } // Generate the tree - tree, err := merkletree.NewUsing(totalData, keccak256.New(), false, true) + tree, err := merkletree.NewTree( + merkletree.WithData(totalData), + merkletree.WithHashType(keccak256.New()), + merkletree.WithSorted(true), + ) if err != nil { return fmt.Errorf("error generating Merkle Tree: %w", err) } diff --git a/shared/services/rewards/generator-impl-v4.go b/shared/services/rewards/generator-impl-v4.go index ee64be2fe..85f1b7468 100644 --- a/shared/services/rewards/generator-impl-v4.go +++ b/shared/services/rewards/generator-impl-v4.go @@ -286,7 +286,11 @@ func (r *treeGeneratorImpl_v4) generateMerkleTree() error { } // Generate the tree - tree, err := merkletree.NewUsing(totalData, keccak256.New(), false, true) + tree, err := merkletree.NewTree( + merkletree.WithData(totalData), + merkletree.WithHashType(keccak256.New()), + merkletree.WithSorted(true), + ) if err != nil { return fmt.Errorf("error generating Merkle Tree: %w", err) }