Skip to content

Commit

Permalink
Use chainlink-commons for hash and merkle pkg in ocr3 (#1000)
Browse files Browse the repository at this point in the history
## Motivation
With
[chainlink-common#527](smartcontractkit/chainlink-common#527)
hashlib (now hashutil) and merklemulti were moved to a common location.

## Solution
Update [ccip repo](https://github.com/smartcontractkit/ccip) to remove
`core/services/ocr3/plugins/ccip/internal/libs/hashlib/` and
`core/services/ocr3/plugins/ccip/internal/libs/merklemulti/`. Replace
them with the versions in chainlink-common.

## Future work
After the merge of [Merge core release
2.13.0](#988), this
refactor should be done also in
`./core/services/ocr2/plugins/ccip/pkg/hashlib/` and
`./core/services/ocr2/plugins/ccip/pkg/merklemulti/`.
  • Loading branch information
agusaldasoro authored Jun 14, 2024
1 parent 3dcd44b commit fb6ee74
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 862 deletions.
5 changes: 5 additions & 0 deletions .changeset/clever-hotels-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": patch
---

use chainlink-common for hash and merklemulti in ocr3 #internal
7 changes: 4 additions & 3 deletions core/services/ocr3/plugins/ccip/commit/plugin_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"golang.org/x/sync/errgroup"

"github.com/smartcontractkit/ccipocr3/internal/libs/hashlib"
"github.com/smartcontractkit/ccipocr3/internal/libs/merklemulti"
"github.com/smartcontractkit/ccipocr3/internal/libs/slicelib"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink-common/pkg/hashutil"
"github.com/smartcontractkit/chainlink-common/pkg/merklemulti"
)

// observeMaxSeqNums finds the maximum committed sequence numbers for each source chain.
Expand Down Expand Up @@ -364,7 +365,7 @@ func newMsgsConsensusForChain(
}

lggr.Debugw("constructing merkle tree", "chain", chainSel, "treeLeaves", len(treeLeaves))
tree, err := merklemulti.NewTree(hashlib.NewKeccakCtx(), treeLeaves)
tree, err := merklemulti.NewTree(hashutil.NewKeccak(), treeLeaves)
if err != nil {
return observedMsgsConsensus{}, fmt.Errorf("construct merkle tree from %d leaves: %w", len(treeLeaves), err)
}
Expand Down
41 changes: 0 additions & 41 deletions core/services/ocr3/plugins/ccip/internal/libs/hashlib/common.go

This file was deleted.

This file was deleted.

66 changes: 0 additions & 66 deletions core/services/ocr3/plugins/ccip/internal/libs/hashlib/hasher.go

This file was deleted.

This file was deleted.

Loading

0 comments on commit fb6ee74

Please sign in to comment.