mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## Summary - Add zero address validation across all functions that accept address parameters to prevent misconfiguration - Fix race condition in `buildNewValidatorSetMessage()` that could cause reverts during validator deregistration - Refactor contract for improved readability and reduced code duplication - Update AVS metadata URL to point to the correct hosted JSON file ## Changes ### Security & Validation - Add `ZeroAddress` error and validate all address inputs in `initialize`, `setRewardsInitiator`, `setSnowbridgeGateway`, `addValidatorToAllowlist`, `registerOperator`, and `updateSolochainAddressForValidator` - Fix race condition: filter out zero solochain addresses in `buildNewValidatorSetMessage()` to prevent reverts when a validator is mid-deregistration ### Refactoring - Replace verbose `if/revert` patterns with `require` statements for consistency - Inline single-use internal functions (`_createDataHavenOperatorSets`, `_setRewardsInitiator`) - Consolidate duplicate error types into single `ZeroAddress` error - Rename `initialise` → `initialize` to maintain consistency with the transparent upgradability pattern - Optimize validator set message encoding by removing redundant wrapper function ### Observability - Add `SolochainAddressUpdated` event for tracking validator address changes ### Cleanup - Remove unused remappings from `foundry.toml` - Fix typo in metadata description --------- Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
61 lines
1.4 KiB
Solidity
61 lines
1.4 KiB
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.27;
|
|
|
|
import {IGatewayV2} from "snowbridge/src/v2/IGateway.sol";
|
|
import {OperatingMode, InboundMessage} from "snowbridge/src/v2/Types.sol";
|
|
import {BeefyVerification} from "snowbridge/src/BeefyVerification.sol";
|
|
|
|
/// @notice Minimal mock of the Snowbridge Gateway for testing purposes
|
|
contract SnowbridgeGatewayMock is IGatewayV2 {
|
|
function operatingMode() external pure returns (OperatingMode) {
|
|
return OperatingMode.Normal;
|
|
}
|
|
|
|
function agentOf(
|
|
bytes32
|
|
) external pure returns (address) {
|
|
return address(0);
|
|
}
|
|
|
|
function v2_submit(
|
|
InboundMessage calldata,
|
|
bytes32[] calldata,
|
|
BeefyVerification.Proof calldata,
|
|
bytes32
|
|
) external {}
|
|
|
|
function v2_sendMessage(
|
|
bytes calldata,
|
|
bytes[] calldata,
|
|
bytes calldata,
|
|
uint128,
|
|
uint128
|
|
) external payable {}
|
|
|
|
function v2_registerToken(
|
|
address,
|
|
uint8,
|
|
uint128,
|
|
uint128
|
|
) external payable {}
|
|
|
|
function v2_createAgent(
|
|
bytes32
|
|
) external {}
|
|
|
|
function v2_outboundNonce() external pure returns (uint64) {
|
|
return 0;
|
|
}
|
|
|
|
function v2_isDispatched(
|
|
uint64
|
|
) external pure returns (bool) {
|
|
return false;
|
|
}
|
|
|
|
function isTokenRegistered(
|
|
address
|
|
) external pure returns (bool) {
|
|
return false;
|
|
}
|
|
}
|