Skip to content

Commit

Permalink
Merge branch 'main' into erik/keypacks-derive-miniblocknum
Browse files Browse the repository at this point in the history
  • Loading branch information
erikolsson committed Jan 13, 2025
2 parents 7acc421 + 8918082 commit faa6d38
Show file tree
Hide file tree
Showing 84 changed files with 2,582 additions and 667 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,8 @@ jobs:
--name river_postgres_container
steps:
- uses: taiki-e/install-action@just

- name: Cancel previous runs
if: github.event_name != 'schedule'
uses: styfle/[email protected]
Expand Down Expand Up @@ -682,11 +684,8 @@ jobs:
run: ./scripts/register-ca.sh
working-directory: core

- name: Build MLS libs
run: ./scripts/build-mls.sh

- name: Run node tests
run: CGO_LDFLAGS="./libmls_lib.a -ldl" go test -race -timeout 24m -v -parallel 1 -count 1 -p 8 ./...
run: just test-all -race -timeout 24m -parallel 1 -count 1 -p 8
working-directory: core

XChain_Integration:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"address": "0x1A01452AdE93E9907Baf0817c9835e89616975BF"
"address": "0xa9DdAFf98EF46850a7e75376D456c0EF45ae5C9a"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"address": "0x2186e9D5d8b1177b07AD06CeA14f695F8fb0d0b1"
"address": "0x4Dd0B63cB55A988BDc28e3a39Bc42E7E34e9C4eA"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"address": "0xabB6A0f9Bd6Bc985456Bf49821dD16192E141B27"
"address": "0xb2A948Ea103882c527Dc27a4f0581E5FCCCDC645"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"address": "0x7B809Fe671efef51BaAaDf6F0A8C9FD84ce5b608"
"address": "0x3466893bDedb3c158F91D2efEe6cD927Cd765e03"
}
10 changes: 6 additions & 4 deletions contracts/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ deploy-any :;
@echo "Running $(contract) on remote network"
@SAVE_DEPLOYMENTS=1 $(if $(context),DEPLOYMENT_CONTEXT=$(context)) \
forge script scripts/deployments/${type}/${contract}.s.sol:${contract} \
--ffi --rpc-url ${rpc} --private-key ${private_key} --broadcast --verify
--ffi --rpc-url ${rpc} $(if $(private_key),--private-key ${private_key},$(if $(account),--account ${account})) \
--broadcast --verify

deploy-any-blockscout :;
@echo "Running $(contract) on remote network"
@SAVE_DEPLOYMENTS=1 $(if $(context),DEPLOYMENT_CONTEXT=$(context)) \
forge script scripts/deployments/${type}/${contract}.s.sol:${contract} \
--ffi --rpc-url ${rpc} --private-key ${private_key} --broadcast --verify --verifier=blockscout --verifier-url=${verifier}
--ffi --rpc-url ${rpc} $(if $(private_key),--private-key ${private_key},$(if $(account),--account ${account})) \
--broadcast --verify --verifier=blockscout --verifier-url=${verifier}

deploy-any-explicit :;
@echo "Running $(contract) on remote network"
Expand Down Expand Up @@ -205,7 +207,7 @@ deploy-ledger-base-sepolia :;
@$(MAKE) resume-any-ledger rpc=base_sepolia hd_path=${HD_PATH} sender=${SENDER_ADDRESS} verifier=${BASESCAN_SEPOLIA_URL} etherscan=${BASESCAN_API_KEY}

deploy-base-sepolia :;
@$(MAKE) deploy-any-blockscout rpc=base_sepolia private_key=${TESTNET_PRIVATE_KEY} verifier=${BLOCKSCOUT_SEPOLIA_URL}
@$(MAKE) deploy-any-blockscout rpc=base_sepolia private_key=${TESTNET_PRIVATE_KEY} verifier=${BLOCKSCOUT_SEPOLIA_URL} etherscan=${BLOCKSCOUT_SEPOLIA_API_KEY}
@$(MAKE) resume-any rpc=base_sepolia private_key=${TESTNET_PRIVATE_KEY} verifier=${BASESCAN_SEPOLIA_URL} etherscan=${BASESCAN_API_KEY}

interact-base-sepolia :;
Expand Down Expand Up @@ -293,7 +295,7 @@ deploy-alpha-sepolia :;
@$(MAKE) deploy-any context=alpha rpc=sepolia private_key=${TESTNET_PRIVATE_KEY}

deploy-alpha-base-sepolia :;
@$(MAKE) deploy-any-blockscout context=alpha rpc=base_sepolia private_key=${TESTNET_PRIVATE_KEY} verifier=${BLOCKSCOUT_SEPOLIA_URL}
@$(MAKE) deploy-any-blockscout context=alpha rpc=base_sepolia private_key=${TESTNET_PRIVATE_KEY} verifier=${BLOCKSCOUT_SEPOLIA_URL} etherscan=${BLOCKSCOUT_SEPOLIA_API_KEY}
@$(MAKE) resume-any rpc=base_sepolia private_key=${TESTNET_PRIVATE_KEY} verifier=${BASESCAN_SEPOLIA_URL} etherscan=${BASESCAN_API_KEY}

interact-alpha-base-sepolia :;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {NodeRegistry} from "contracts/src/river/registry/facets/node/NodeRegistr

contract DeployNodeRegistry is FacetHelper, Deployer {
constructor() {
addSelector(NodeRegistry.isNode.selector);
addSelector(NodeRegistry.registerNode.selector);
addSelector(NodeRegistry.removeNode.selector);
addSelector(NodeRegistry.updateNodeStatus.selector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ contract DeployStreamRegistry is FacetHelper, Deployer {
addSelector(StreamRegistry.getPaginatedStreams.selector); // only interested for stream on a single node
addSelector(StreamRegistry.isStream.selector); // returns if stream exists
addSelector(StreamRegistry.getStreamCountOnNode.selector);

// addSelector(StreamRegistry.getStreams.selector);
// addSelector(StreamRegistry.getStreamByIndex.selector);
// addSelector(StreamRegistry.getAllStreamIds.selector);
// addSelector(StreamRegistry.getAllStreams.selector);
// addSelector(StreamRegistry.getStreamsOnNode.selector);
}

function versionName() public pure override returns (string memory) {
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/river/registry/facets/node/INodeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface INodeRegistry is INodeRegistryBase {
// =============================================================
// Nodes
// =============================================================

function isNode(address nodeAddress) external view returns (bool);
function registerNode(
address nodeAddress,
string memory url,
Expand Down
4 changes: 4 additions & 0 deletions contracts/src/river/registry/facets/node/NodeRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import {RegistryModifiers} from "contracts/src/river/registry/libraries/Registry
contract NodeRegistry is INodeRegistry, RegistryModifiers {
using EnumerableSet for EnumerableSet.AddressSet;

function isNode(address nodeAddress) public view returns (bool) {
return ds.nodeByAddress[nodeAddress].nodeAddress != address(0);
}

function registerNode(
address nodeAddress,
string memory url,
Expand Down
89 changes: 81 additions & 8 deletions contracts/src/river/registry/facets/stream/IStreamRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import {Stream, StreamWithId, SetMiniblock} from "contracts/src/river/registry/l
// libraries

// contracts

interface IStreamRegistry {
interface IStreamRegistryBase {
// =============================================================
// Events
// =============================================================
Expand Down Expand Up @@ -38,46 +37,120 @@ interface IStreamRegistry {
address nodeAddress,
bool isAdded
);
}

interface IStreamRegistry is IStreamRegistryBase {
// =============================================================
// Streams
// =============================================================

/**
* @notice Check if a stream exists in the registry
* @param streamId The ID of the stream to check
* @return bool True if the stream exists, false otherwise
*/
function isStream(bytes32 streamId) external view returns (bool);

/**
* @notice Allocate a new stream in the registry
* @param streamId The ID of the stream to allocate
* @param nodes The list of nodes to place the stream on
* @param genesisMiniblockHash The hash of the genesis miniblock
* @param genesisMiniblock The genesis miniblock data
* @dev Only callable by registered nodes
*/
function allocateStream(
bytes32 streamId,
address[] memory nodes,
bytes32 genesisMiniblockHash,
bytes memory genesisMiniblock
) external;

/**
* @notice Get a stream from the registry
* @param streamId The ID of the stream to get
* @return Stream The stream data
*/
function getStream(bytes32 streamId) external view returns (Stream memory);

/// @return stream, genesisMiniblockHash, genesisMiniblock
function getStreamWithGenesis(
bytes32 streamId
) external view returns (Stream memory, bytes32, bytes memory);

/**
* @notice Set the last miniblock for multiple streams in a batch operation
* @param miniblocks Array of SetMiniblock structs containing stream IDs and their last miniblock information
* @dev Only callable by registered nodes
* @dev This function allows updating multiple streams' last miniblock data in a single transaction
*/
function setStreamLastMiniblockBatch(
SetMiniblock[] calldata miniblocks
) external;

/**
* @notice Place a stream on a specific node
* @param streamId The ID of the stream to place
* @param nodeAddress The address of the node to place the stream on
*/
function placeStreamOnNode(bytes32 streamId, address nodeAddress) external;

/**
* @notice Remove a stream from a specific node
* @param streamId The ID of the stream to remove
* @param nodeAddress The address of the node to remove the stream from
*/
function removeStreamFromNode(bytes32 streamId, address nodeAddress) external;

/**
* @notice Get the total number of streams in the registry
* @return uint256 The total number of streams
*/
function getStreamCount() external view returns (uint256);

/**
* @notice Get the number of streams placed on a specific node
* @param nodeAddress The address of the node to check
* @return uint256 The number of streams on the node
*/
function getStreamCountOnNode(
address nodeAddress
) external view returns (uint256);

/**
* @dev Recommended range is 5000 streams, returns true if on the last page.
* @notice Get a paginated list of streams from the registry
* @dev Recommended range is 5000 streams to avoid gas limits
* @param start The starting index for pagination
* @param stop The ending index for pagination
* @return StreamWithId[] Array of streams with their IDs in the requested range
* @return bool True if this is the last page of results
*/
function getPaginatedStreams(
uint256 start,
uint256 stop
) external view returns (StreamWithId[] memory, bool);

/**
* @notice Get a stream and its genesis information from the registry
* @param streamId The ID of the stream to get
* @return Stream The stream data
* @return bytes32 The genesis miniblock hash
* @return bytes The genesis miniblock data
*/
function getStreamWithGenesis(
bytes32 streamId
) external view returns (Stream memory, bytes32, bytes memory);

/**
* @notice Update the last miniblock information for a stream
* @dev Only callable by registered nodes
* @param streamId The ID of the stream to update
* @param prevMiniblockHash The hash of the previous miniblock (currently unused)
* @param lastMiniblockHash The hash of the new last miniblock
* @param lastMiniblockNum The number of the new last miniblock
* @param isSealed Whether to mark the stream as sealed
* @custom:deprecated Deprecated in favor of setStreamLastMiniblockBatch
*/
function setStreamLastMiniblock(
bytes32 streamId,
bytes32 prevMiniblockHash,
bytes32 lastMiniblockHash,
uint64 lastMiniblockNum,
bool isSealed
) external;
}
Loading

0 comments on commit faa6d38

Please sign in to comment.