mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
chore(contracts): 🗑️ Remove unused contracts (#29)
This commit is contained in:
parent
75e39ff98f
commit
c7cf6cead8
5 changed files with 14 additions and 140 deletions
2
contracts/deployments/.gitignore
vendored
Normal file
2
contracts/deployments/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# Ignoring local deployments
|
||||
anvil.json
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"network": "anvil","BeefyClient": "0x46b142DD1E924FAb83eCc3c08e4D46E82f005e0E","AgentExecutor": "0xC9a43158891282A2B1475592D5719c001986Aaec","Gateway": "0x367761085BF3C12e5DA2Df99AC6E1a824612b8fb","ServiceManager": "0xD84379CEae14AA33C123Af12424A37803F885889","VetoableSlasher": "0x2B0d36FACD61B71CC05ab8F3D2355ec3631C0dd5","RewardsRegistry": "0xfbC22278A96299D91d41C453234d97b4F5Eb9B2d","Agent": "0x0Eb3A81D5C8708506638EF3374f4EA6c80C93DeE","DelegationManager": "0xCD8a1C3ba11CF5ECfa6267617243239504a98d90","StrategyManager": "0x82e01223d51Eb87e16A03E24687EDF0F294da6f1","AVSDirectory": "0x2bdCC0de6bE1f7D2ee689a0342D76F52E8EFABa3","EigenPodManager": "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0","EigenPodBeacon": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07","RewardsCoordinator": "0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650","AllocationManager": "0xc351628EB244ec633d5f21fBD6621e1a683B1181","PermissionController": "0xFD471836031dc5108809D173A067e8486B9047A3"}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.27;
|
||||
|
||||
interface IBeefyMessageVerifierErrors {}
|
||||
|
||||
interface IBeefyMessageVerifierEvents {}
|
||||
|
||||
/// @dev An BEEFY MMRLeaf without the `leaf_extra field.
|
||||
/// Reference: https://github.com/paritytech/polkadot-sdk/blob/1abdb7f39cada4840d795b9b721631a3cfe53174/substrate/primitives/consensus/beefy/src/mmr.rs#L53
|
||||
struct BeefyMMRLeafPartial {
|
||||
uint8 version;
|
||||
uint32 parentNumber;
|
||||
bytes32 parentHash;
|
||||
uint64 nextAuthoritySetID;
|
||||
uint32 nextAuthoritySetLen;
|
||||
bytes32 nextAuthoritySetRoot;
|
||||
}
|
||||
|
||||
/// @dev Parameters used to verify a proof generated by https://github.com/paritytech/polkadot-sdk/blob/1abdb7f39cada4840d795b9b721631a3cfe53174/substrate/utils/binary-merkle-tree/src/lib.rs#L144
|
||||
struct SubstrateBinaryMerkleProof {
|
||||
uint256 position;
|
||||
uint256 width;
|
||||
bytes32[] proof;
|
||||
}
|
||||
|
||||
/// @dev Parameters used to verify a that a BEEFY MMRLeaf is part of the latest BEEFY MMR Root.
|
||||
/// Reference: https://github.com/Snowfork/snowbridge/blob/069177d6c6d44c5a1478ae2f14051c0b3bd7a69a/contracts/src/BeefyClient.sol#L399
|
||||
struct BeefyMMRProof {
|
||||
bytes32[] proof;
|
||||
uint256 leafProofOrder;
|
||||
}
|
||||
|
||||
interface IBeefyMessageVerifier is IBeefyMessageVerifierErrors, IBeefyMessageVerifierEvents {
|
||||
/**
|
||||
* @notice Verifies a message passed through the "Extra Leaf Data" field of a BEEFY MMRLeaf.
|
||||
* @dev The message has to be a part of the committed messages in a BEEFY MMRLeaf, that
|
||||
* is part of the latest BEEFY MMR Root that the validators have signed and finalised.
|
||||
* @dev To prove that the message is part of the committed messages, three proofs are required:
|
||||
* 1. A proof that the message is part of a message commitment in the BEEFY MMRLeaf.
|
||||
* 2. A proof that the message commitment is part of the BEEFY MMRLeaf.
|
||||
* 3. A proof that the BEEFY MMRLeaf is part of the latest BEEFY MMR Root.
|
||||
* @dev For more a diagram on these three layers of proofs, see:
|
||||
* https://github.com/Moonsong-Labs/datahaven/blob/main/contracts/resources/MessageProofs.png
|
||||
* @dev For more details on BEEFY, see: https://wiki.polkadot.network/docs/learn-consensus#bridging-beefy
|
||||
* @dev For more details on the MMRLeaf specification, see: https://spec.polkadot.network/sect-finality#defn-beefy-payload
|
||||
* @dev For more details on the verification of the MMRLeaf, see Snowbridge's docs: https://docs.snowbridge.network/architecture/verification/polkadot
|
||||
* @param message The message to verify.
|
||||
* @param messageProof The proof that the message is part of a message commitment in the BEEFY MMRLeaf.
|
||||
* @param messageId The ID that identifies the kind of message being passed through the "Extra Leaf Data" field of the BEEFY MMRLeaf.
|
||||
* @param messageCommitmentProof The proof that the message commitment is part of the BEEFY MMRLeaf.
|
||||
* @param partialBeefyLeaf The partial BEEFY leaf (without the `leaf_extra` field which contains the root of the message commitments).
|
||||
* @param beefyLeafProof The proof that the BEEFY MMRLeaf is part of the latest BEEFY MMR Root.
|
||||
* @return isValid Whether the message is valid.
|
||||
*/
|
||||
function verifyBeefyMessage(
|
||||
bytes calldata message,
|
||||
bytes calldata messageProof,
|
||||
bytes32 messageId,
|
||||
SubstrateBinaryMerkleProof calldata messageCommitmentProof,
|
||||
BeefyMMRLeafPartial calldata partialBeefyLeaf,
|
||||
BeefyMMRProof calldata beefyLeafProof
|
||||
) external view returns (bool);
|
||||
}
|
||||
|
|
@ -133,6 +133,8 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage, IAVSRegistrar
|
|||
}
|
||||
|
||||
/**
|
||||
* @dev DEPRECATED ❗️ This function is not used. This contract distributes rewards directly to operators
|
||||
* instead of using the RewardsCoordinator.
|
||||
* @notice Creates a new operator-directed rewards submission, to be split amongst the operators and
|
||||
* set of stakers delegated to operators who are registered to this AVS' OperatorSet.
|
||||
* @param operatorSet The OperatorSet to create the rewards submission for
|
||||
|
|
@ -174,6 +176,11 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage, IAVSRegistrar
|
|||
_rewardsCoordinator.createOperatorDirectedOperatorSetRewardsSubmission(
|
||||
operatorSet, operatorDirectedRewardsSubmissions
|
||||
);
|
||||
|
||||
// REVERTING BECAUSE THIS FUNCTION IS DEPRECATED ❗️
|
||||
revert(
|
||||
"ServiceManagerBase: createOperatorDirectedOperatorSetRewardsSubmission is deprecated"
|
||||
);
|
||||
}
|
||||
|
||||
/// @inheritdoc IServiceManager
|
||||
|
|
@ -265,6 +272,8 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage, IAVSRegistrar
|
|||
}
|
||||
|
||||
/**
|
||||
* @dev DEPRECATED ❗️ This function is not used. This contract distributes rewards directly to operators
|
||||
* instead of using the RewardsCoordinator.
|
||||
* @notice Sets the rewards initiator address
|
||||
* @param newRewardsInitiator The new rewards initiator address
|
||||
* @dev only callable by the owner
|
||||
|
|
@ -273,6 +282,9 @@ abstract contract ServiceManagerBase is ServiceManagerBaseStorage, IAVSRegistrar
|
|||
address newRewardsInitiator
|
||||
) external virtual onlyOwner {
|
||||
_setRewardsInitiator(newRewardsInitiator);
|
||||
|
||||
// REVERTING BECAUSE THIS FUNCTION IS DEPRECATED ❗️
|
||||
revert("ServiceManagerBase: setRewardsInitiator is deprecated");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,76 +0,0 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.27;
|
||||
|
||||
import "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol";
|
||||
import "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
|
||||
|
||||
import "../interfaces/IBeefyMessageVerifier.sol";
|
||||
|
||||
contract ServiceMessageDispatcher is IBeefyMessageVerifier, Initializable, OwnableUpgradeable {
|
||||
bytes32 public constant VALIDATOR_POINTS_MESSAGE_ID = keccak256("VALIDATOR_POINTS");
|
||||
bytes32 public constant SLASH_MESSAGE_ID = keccak256("SLASH");
|
||||
|
||||
/// @notice A mapping of message IDs to external verifiers.
|
||||
/// @dev The external verifier is a contract that implements the `IBeefyMessageVerifier` interface.
|
||||
/// @dev This provides a way to delegate the verification of unknown message IDs to an external contract,
|
||||
/// thus extending the functionality of this contract without the need to modify the contract.
|
||||
mapping(bytes32 => address) public messageIdToExternalVerifier;
|
||||
|
||||
function initialize() public initializer {
|
||||
__Ownable_init();
|
||||
}
|
||||
|
||||
function verifyValidatorPointsMessage(
|
||||
bytes calldata, // message,
|
||||
bytes calldata, // messageProof,
|
||||
SubstrateBinaryMerkleProof calldata, // messageCommitmentProof,
|
||||
BeefyMMRLeafPartial calldata, // partialBeefyLeaf,
|
||||
BeefyMMRProof calldata // beefyLeafProof
|
||||
) public view returns (bool) {
|
||||
// TODO: Implement the logic to verify the validator points message
|
||||
return true;
|
||||
}
|
||||
|
||||
function verifySlashMessage(
|
||||
bytes calldata, // message,
|
||||
bytes calldata, // messageProof,
|
||||
SubstrateBinaryMerkleProof calldata, // messageCommitmentProof,
|
||||
BeefyMMRLeafPartial calldata, // partialBeefyLeaf,
|
||||
BeefyMMRProof calldata // beefyLeafProof
|
||||
) public view returns (bool) {
|
||||
// TODO: Implement the logic to verify the slash message
|
||||
return true;
|
||||
}
|
||||
|
||||
function verifyBeefyMessage(
|
||||
bytes calldata message,
|
||||
bytes calldata messageProof,
|
||||
bytes32 messageId,
|
||||
SubstrateBinaryMerkleProof calldata messageCommitmentProof,
|
||||
BeefyMMRLeafPartial calldata partialBeefyLeaf,
|
||||
BeefyMMRProof calldata beefyLeafProof
|
||||
) external view override returns (bool) {
|
||||
// For known message IDs, we can verify it here.
|
||||
if (messageId == VALIDATOR_POINTS_MESSAGE_ID) {
|
||||
return verifyValidatorPointsMessage(
|
||||
message, messageProof, messageCommitmentProof, partialBeefyLeaf, beefyLeafProof
|
||||
);
|
||||
} else if (messageId == SLASH_MESSAGE_ID) {
|
||||
return verifySlashMessage(
|
||||
message, messageProof, messageCommitmentProof, partialBeefyLeaf, beefyLeafProof
|
||||
);
|
||||
} else if (messageIdToExternalVerifier[messageId] != address(0)) {
|
||||
// For unknown message IDs, we delegate the verification to an external verifier, if there is one registered.
|
||||
return IBeefyMessageVerifier(messageIdToExternalVerifier[messageId]).verifyBeefyMessage(
|
||||
message,
|
||||
messageProof,
|
||||
messageId,
|
||||
messageCommitmentProof,
|
||||
partialBeefyLeaf,
|
||||
beefyLeafProof
|
||||
);
|
||||
}
|
||||
// Unknown message IDs are not supported.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue