mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
We remove `calculateMerkleRootUnsorted` and `buildMerkleProofUnsorted` and instead introduce a new parameter `sorting`. This parameter `sorting` will indicate if we need to sort the pair before hashing the new node.
19 lines
823 B
Solidity
19 lines
823 B
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.27;
|
|
|
|
import {MerkleUtils} from "../../src/libraries/MerkleUtils.sol";
|
|
import {BeefyClient} from "snowbridge/src/BeefyClient.sol";
|
|
|
|
library ValidatorsUtils {
|
|
function _buildValidatorSet(
|
|
uint128 id,
|
|
bytes32[] memory validators
|
|
) internal pure returns (BeefyClient.ValidatorSet memory) {
|
|
// Calculate the merkle root from the validators array. We specify to not sort the pair before hashing to be compatible with Beefy Merkle Tree implementation.
|
|
bytes32 merkleRoot = MerkleUtils.calculateMerkleRoot(validators, false);
|
|
|
|
// Create and return the validator set with the calculated merkle root
|
|
return
|
|
BeefyClient.ValidatorSet({id: id, length: uint128(validators.length), root: merkleRoot});
|
|
}
|
|
}
|