mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-24 09:50:01 +00:00
## This PR includes: - Running the execution relayer on the CLI - Modifying the Payload generation in the `DataHavenServiceManager.sol` - Modified the `EigenLayerMessageProcessor` to work with the ValidatorSet update message, but for this change we are loosing the generic message type (it was the only way to make it work so far). - Adds a `--no-wait` argument to the cli launch and stop commands to bootstrap faster. ### Testing the Snowbridge message encoding / decoding - Added`MessageEncoding.t.sol` is documented and explains how to generate bin data to use in the rust test. - Added a Rust unit test to `EigenLayerMessageProcessor` to compare the message encoding/decoding taking the bytes from a file (previously generated with some mock data). Specifically, we want that:3cbca0db6d/contracts/src/libraries/DataHavenSnowbridgeMessages.sol (L78-L85)Generates the right bytes encoding for0e2c9cd518/operator/primitives/bridge/src/lib.rs (L51)If the test passes, it's very likely that the CLI will also pass, if not, then we might wanna check something else is missing. ### Breaking change ⚠️ For compatibility reasons with Snowbridge contracts (they call specific extrinsics of specific pallets), I had to rename: - `InboundQueueV2` -> `EthereumInboundQueueV2` - `OutboundQueueV2` -> `EthereumOutboundQueueV2` ## For follow up PRs: - Add an automated way of generating the Solidity bytes fo testing, so we don't need to maintain the MessageEncoding.t.sol and generate the binary data manually. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for the "execution" relayer type in relay configuration, parsing, and CLI launch utilities. - Introduced a Solidity test contract for encoding and logging validator set messages. - Added a comprehensive "start:all" script to streamline launching and setup processes. - **Enhancements** - Improved message encoding for validator set updates, aligning with new struct field names and message formats. - Updated relay configuration schema and validation to support execution relayers and OFAC settings. - Increased beacon datastore capacity and adjusted relay scheduling parameters in configuration files. - **Refactor** - Renamed runtime type aliases for inbound/outbound queues to more descriptive names across mainnet, stagenet, and testnet. - Centralized and streamlined validator set update logic in CLI utilities. - Centralized message decoding logic and improved visibility of message fields in Rust components. - **Bug Fixes** - Improved error handling and decoding logic for message processing in Rust components. - **Tests** - Added Rust and Solidity tests for message encoding and processing validation. - **Chores** - Updated dependencies and feature flags in Rust project configuration. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Facundo Farall <37149322+ffarall@users.noreply.github.com>
44 lines
2.1 KiB
Solidity
44 lines
2.1 KiB
Solidity
// SPDX-License-Identifier: UNLICENSED
|
|
pragma solidity ^0.8.27;
|
|
|
|
import {Test} from "forge-std/Test.sol";
|
|
import {console} from "forge-std/console.sol";
|
|
import {DataHavenSnowbridgeMessages} from "../src/libraries/DataHavenSnowbridgeMessages.sol";
|
|
|
|
// This test is used to encode the receive validators message and log the hex string.
|
|
// The hex string is then used to generate the .bin file for the Rust test.
|
|
// To generate the .bin file, run:
|
|
// forge test --match-test testEncodeReceiveValidatorsMessageAndLog
|
|
// Then, copy the hex string and paste it into the Rust test file.
|
|
// Then, run:
|
|
// cargo test --test decode_receive_validators_message_from_file_correctly
|
|
// The test should pass.
|
|
contract MessageEncodingTest is Test {
|
|
function testEncodeReceiveValidatorsMessageAndLog() public pure {
|
|
// Mock Data -
|
|
uint64 mockNonce = 12345;
|
|
bytes32 mockTopic = 0x123456789012345678901234567890123456789012345678901234567890abcd;
|
|
|
|
bytes32[] memory mockValidators = new bytes32[](2);
|
|
mockValidators[0] = 0x0000000000000000000000000000000000000000000000000000000000000001;
|
|
mockValidators[1] = 0x0000000000000000000000000000000000000000000000000000000000000002;
|
|
// uint64 mockEpoch = 0; // This is hardcoded to 0 in the Solidity function's payload part
|
|
|
|
DataHavenSnowbridgeMessages.NewValidatorSetPayload memory newValidatorSetPayload =
|
|
DataHavenSnowbridgeMessages.NewValidatorSetPayload({validators: mockValidators});
|
|
// epoch is implicitly 0 in scaleEncodeNewValidatorSetMessagePayload
|
|
|
|
DataHavenSnowbridgeMessages.NewValidatorSet memory newValidatorSetMessage =
|
|
DataHavenSnowbridgeMessages.NewValidatorSet({
|
|
nonce: mockNonce,
|
|
topic: mockTopic,
|
|
payload: newValidatorSetPayload
|
|
});
|
|
|
|
bytes memory encodedMessage =
|
|
DataHavenSnowbridgeMessages.scaleEncodeNewValidatorSetMessage(newValidatorSetMessage);
|
|
|
|
console.log("Encoded NewValidatorSet message (hex):");
|
|
console.logBytes(encodedMessage); // This will print the hex string
|
|
}
|
|
}
|