Skip to content

Commit

Permalink
chore: merge branch main into prerelease/2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Oct 16, 2024
2 parents 76d6005 + 0dbea01 commit e430917
Show file tree
Hide file tree
Showing 98 changed files with 4,769 additions and 15,599 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-radios-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": major
---

Make `IAuthorityFactory` functions return `IAuthority`
5 changes: 5 additions & 0 deletions .changeset/lovely-glasses-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": minor
---

Add `IOwnable` interface
5 changes: 5 additions & 0 deletions .changeset/metal-dryers-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": major
---

Made `ISelfHostedApplicationFactory` return `IApplication`
5 changes: 5 additions & 0 deletions .changeset/nine-grapes-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": major
---

Make `IQuorumFactory` functions return `IQuorum`
5 changes: 5 additions & 0 deletions .changeset/purple-wasps-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": minor
---

Add `IQuorum` interface
2 changes: 2 additions & 0 deletions .changeset/quiet-guests-greet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
Modified the `ICartesiDAppFactory` interface:

- Renamed it as `IApplicationFactory`.

- Made it return `IApplication` instead of `Application`.
5 changes: 1 addition & 4 deletions .changeset/silly-islands-end.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ Modified the `ICartesiDApp` interface:

- Renamed it as `IApplication`.

- Made it inherit from:

- `IERC721Receiver`.
- `IERC1155Receiver`.
- Made it inherit from `IOwnable`.

- Modified the `executeVoucher` function:

Expand Down
5 changes: 5 additions & 0 deletions .changeset/tidy-pans-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cartesi/rollups": minor
---

Add `IAuthority` interface
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,34 @@ jobs:
id: get_version
run: jq -r '"version=\(.version)"' package.json >> "$GITHUB_OUTPUT"

upload_contract_artifacts_to_gh_releases:
name: Upload contract artifacts to GitHub Releases
needs: version_or_publish
if: ${{ needs.version_or_publish.outputs.published == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: ./.github/workflows/setup

- name: Build contracts
run: pnpm build

- name: Create upload folder
run: mkdir -p upload

- name: Compress contract artifacts
run: tar -czf "$FILEPATH" -C export/artifacts/contracts .
env:
FILEPATH: upload/rollups-contracts-${{ needs.version_or_publish.outputs.version }}-artifacts.tar.gz

- name: Upload files to GitHub Releases
uses: softprops/action-gh-release@v2
with:
files: upload/*

rust_bindings:
name: Generate and publish Rust bindings
needs: version_or_publish
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'

- name: Install Node packages
Expand Down
11 changes: 11 additions & 0 deletions contracts/access/IOwnable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;

/// @notice The interface of OpenZeppelin's `Ownable` contract.
interface IOwnable {
function owner() external view returns (address);
function renounceOwnership() external;
function transferOwnership(address newOwner) external;
}
20 changes: 18 additions & 2 deletions contracts/consensus/authority/Authority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ pragma solidity ^0.8.8;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

import {IAuthority} from "./IAuthority.sol";
import {IConsensus} from "../IConsensus.sol";
import {AbstractConsensus} from "../AbstractConsensus.sol";
import {IOwnable} from "../../access/IOwnable.sol";

/// @notice A consensus contract controlled by a single address, the owner.
/// @dev This contract inherits from OpenZeppelin's `Ownable` contract.
/// For more information on `Ownable`, please consult OpenZeppelin's official documentation.
contract Authority is AbstractConsensus, Ownable {
contract Authority is IAuthority, AbstractConsensus, Ownable {
/// @param initialOwner The initial contract owner
/// @param epochLength The epoch length
/// @dev Reverts if the epoch length is zero.
Expand All @@ -30,7 +32,7 @@ contract Authority is AbstractConsensus, Ownable {
address appContract,
uint256 lastProcessedBlockNumber,
bytes32 claim
) external onlyOwner {
) external override onlyOwner {
emit ClaimSubmission(
msg.sender,
appContract,
Expand All @@ -39,4 +41,18 @@ contract Authority is AbstractConsensus, Ownable {
);
_acceptClaim(appContract, lastProcessedBlockNumber, claim);
}

function owner() public view override(IOwnable, Ownable) returns (address) {
return super.owner();
}

function renounceOwnership() public override(IOwnable, Ownable) {
super.renounceOwnership();
}

function transferOwnership(
address newOwner
) public override(IOwnable, Ownable) {
super.transferOwnership(newOwner);
}
}
11 changes: 6 additions & 5 deletions contracts/consensus/authority/AuthorityFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

import {IAuthorityFactory} from "./IAuthorityFactory.sol";
import {Authority} from "./Authority.sol";
import {IAuthority} from "./IAuthority.sol";

/// @title Authority Factory
/// @notice Allows anyone to reliably deploy a new `Authority` contract.
/// @notice Allows anyone to reliably deploy a new `IAuthority` contract.
contract AuthorityFactory is IAuthorityFactory {
function newAuthority(
address authorityOwner,
uint256 epochLength
) external override returns (Authority) {
Authority authority = new Authority(authorityOwner, epochLength);
) external override returns (IAuthority) {
IAuthority authority = new Authority(authorityOwner, epochLength);

emit AuthorityCreated(authority);

Expand All @@ -26,8 +27,8 @@ contract AuthorityFactory is IAuthorityFactory {
address authorityOwner,
uint256 epochLength,
bytes32 salt
) external override returns (Authority) {
Authority authority = new Authority{salt: salt}(
) external override returns (IAuthority) {
IAuthority authority = new Authority{salt: salt}(
authorityOwner,
epochLength
);
Expand Down
10 changes: 10 additions & 0 deletions contracts/consensus/authority/IAuthority.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;

import {IOwnable} from "../../access/IOwnable.sol";
import {IConsensus} from "../IConsensus.sol";

/// @notice A consensus contract controlled by a single address, the owner.
interface IAuthority is IConsensus, IOwnable {}
8 changes: 4 additions & 4 deletions contracts/consensus/authority/IAuthorityFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pragma solidity ^0.8.8;

import {Authority} from "./Authority.sol";
import {IAuthority} from "./IAuthority.sol";

/// @title Authority Factory interface
interface IAuthorityFactory {
Expand All @@ -12,7 +12,7 @@ interface IAuthorityFactory {
/// @notice A new authority was deployed.
/// @param authority The authority
/// @dev MUST be triggered on a successful call to `newAuthority`.
event AuthorityCreated(Authority authority);
event AuthorityCreated(IAuthority authority);

// Permissionless functions

Expand All @@ -26,7 +26,7 @@ interface IAuthorityFactory {
function newAuthority(
address authorityOwner,
uint256 epochLength
) external returns (Authority);
) external returns (IAuthority);

/// @notice Deploy a new authority deterministically.
/// @param authorityOwner The initial authority owner
Expand All @@ -40,7 +40,7 @@ interface IAuthorityFactory {
address authorityOwner,
uint256 epochLength,
bytes32 salt
) external returns (Authority);
) external returns (IAuthority);

/// @notice Calculate the address of an authority to be deployed deterministically.
/// @param authorityOwner The initial authority owner
Expand Down
54 changes: 54 additions & 0 deletions contracts/consensus/quorum/IQuorum.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

pragma solidity ^0.8.8;

import {IConsensus} from "../IConsensus.sol";

/// @notice A consensus model controlled by a small, immutable set of `n` validators.
/// @notice You can know the value of `n` by calling the `numOfValidators` function.
/// @notice Upon construction, each validator is assigned a unique number between 1 and `n`.
/// These numbers are used internally instead of addresses for gas optimization reasons.
/// @notice You can list the validators in the quorum by calling the `validatorById`
/// function for each ID from 1 to `n`.
interface IQuorum is IConsensus {
/// @notice Get the number of validators.
function numOfValidators() external view returns (uint256);

/// @notice Get the ID of a validator.
/// @param validator The validator address
/// @dev Validators have IDs greater than zero.
/// @dev Non-validators are assigned to ID zero.
function validatorId(address validator) external view returns (uint256);

/// @notice Get the address of a validator by its ID.
/// @param id The validator ID
/// @dev Validator IDs range from 1 to `N`, the total number of validators.
/// @dev Invalid IDs map to address zero.
function validatorById(uint256 id) external view returns (address);

/// @notice Get the number of validators in favor of a claim.
/// @param appContract The application contract address
/// @param lastProcessedBlockNumber The number of the last processed block
/// @param claim The output Merkle root hash
/// @return Number of validators in favor of claim
function numOfValidatorsInFavorOf(
address appContract,
uint256 lastProcessedBlockNumber,
bytes32 claim
) external view returns (uint256);

/// @notice Check whether a validator is in favor of a claim.
/// @param appContract The application contract address
/// @param lastProcessedBlockNumber The number of the last processed block
/// @param claim The output Merkle root hash
/// @param id The ID of the validator
/// @return Whether validator is in favor of claim
/// @dev Assumes the provided ID is valid.
function isValidatorInFavorOf(
address appContract,
uint256 lastProcessedBlockNumber,
bytes32 claim,
uint256 id
) external view returns (bool);
}
8 changes: 4 additions & 4 deletions contracts/consensus/quorum/IQuorumFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pragma solidity ^0.8.8;

import {Quorum} from "./Quorum.sol";
import {IQuorum} from "./IQuorum.sol";

/// @title Quorum Factory interface
interface IQuorumFactory {
Expand All @@ -12,7 +12,7 @@ interface IQuorumFactory {
/// @notice A new quorum was deployed.
/// @param quorum The quorum
/// @dev MUST be triggered on a successful call to `newQuorum`.
event QuorumCreated(Quorum quorum);
event QuorumCreated(IQuorum quorum);

// Permissionless functions

Expand All @@ -26,7 +26,7 @@ interface IQuorumFactory {
function newQuorum(
address[] calldata validators,
uint256 epochLength
) external returns (Quorum);
) external returns (IQuorum);

/// @notice Deploy a new quorum deterministically.
/// @param validators the list of validators
Expand All @@ -40,7 +40,7 @@ interface IQuorumFactory {
address[] calldata validators,
uint256 epochLength,
bytes32 salt
) external returns (Quorum);
) external returns (IQuorum);

/// @notice Calculate the address of a quorum to be deployed deterministically.
/// @param validators the list of validators
Expand Down
Loading

0 comments on commit e430917

Please sign in to comment.