Skip to content

Commit

Permalink
Merge branch 'main' into g/token
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj authored Jan 10, 2025
2 parents d8a519f + fe95761 commit 7b1a38e
Show file tree
Hide file tree
Showing 130 changed files with 7,635 additions and 2,720 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Welcome to the River repo. Here you will find all of the components to run the c

## Prerequisites

- **Rust** Install the latest Rust tools from <https://rustup.rs/>

- **Docker Desktop** we use docker to run postgresql, redis, etc for local development. Note, you may have to restart your computer after installing to grant it the right permissions <https://www.docker.com/products/docker-desktop/>

- **Node v20.x.x**, I recommend using nvm to install node: <https://github.com/nvm-sh/nvm>, then you can run `nvm use` to switch to the node version specified in .nvmrc, or `nvm alias default 20 && nvm use default` to set the default version across all of your terminals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@ contract DeployMainnetDelegation is FacetHelper, Deployer {
addSelector(MainnetDelegation.setProxyDelegation.selector);
addSelector(MainnetDelegation.setDelegationDigest.selector);
addSelector(MainnetDelegation.relayDelegations.selector);
addSelector(MainnetDelegation.setDelegation.selector);
addSelector(MainnetDelegation.getDelegationByDelegator.selector);
addSelector(MainnetDelegation.getMainnetDelegationsByOperator.selector);
addSelector(MainnetDelegation.getDelegatedStakeByOperator.selector);
addSelector(MainnetDelegation.setAuthorizedClaimer.selector);
addSelector(MainnetDelegation.getAuthorizedClaimer.selector);
addSelector(MainnetDelegation.setBatchDelegation.selector);
addSelector(MainnetDelegation.setBatchAuthorizedClaimers.selector);
addSelector(MainnetDelegation.getProxyDelegation.selector);
addSelector(MainnetDelegation.getMessenger.selector);
addSelector(MainnetDelegation.removeDelegations.selector);
addSelector(MainnetDelegation.getDepositIdByDelegator.selector);
}

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 @@ -18,20 +18,13 @@ contract DeployStreamRegistry is FacetHelper, Deployer {
addSelector(StreamRegistry.allocateStream.selector);
addSelector(StreamRegistry.getStream.selector);
addSelector(StreamRegistry.getStreamWithGenesis.selector);
addSelector(StreamRegistry.setStreamLastMiniblock.selector);
addSelector(StreamRegistry.setStreamLastMiniblockBatch.selector); // reduce to only this
addSelector(StreamRegistry.setStreamLastMiniblockBatch.selector);
addSelector(StreamRegistry.placeStreamOnNode.selector); // future
addSelector(StreamRegistry.removeStreamFromNode.selector);
addSelector(StreamRegistry.getStreamCount.selector); // monitoring
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
97 changes: 81 additions & 16 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,54 +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);

function setStreamLastMiniblock(
bytes32 streamId,
bytes32 prevMiniBlockHash,
bytes32 lastMiniblockHash,
uint64 lastMiniblockNum,
bool isSealed
) external;

/**
* @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 7b1a38e

Please sign in to comment.