Skip to content

Commit

Permalink
feat!: make quorum factory return interface
Browse files Browse the repository at this point in the history
  • Loading branch information
guidanoli committed Oct 10, 2024
1 parent d425fe1 commit 3ef8cb5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
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`
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
11 changes: 6 additions & 5 deletions contracts/consensus/quorum/QuorumFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ pragma solidity ^0.8.8;
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";

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

/// @title Quorum Factory
/// @notice Allows anyone to reliably deploy a new `Quorum` contract.
/// @notice Allows anyone to reliably deploy a new `IQuorum` contract.
contract QuorumFactory is IQuorumFactory {
function newQuorum(
address[] calldata validators,
uint256 epochLength
) external override returns (Quorum) {
Quorum quorum = new Quorum(validators, epochLength);
) external override returns (IQuorum) {
IQuorum quorum = new Quorum(validators, epochLength);

emit QuorumCreated(quorum);

Expand All @@ -26,8 +27,8 @@ contract QuorumFactory is IQuorumFactory {
address[] calldata validators,
uint256 epochLength,
bytes32 salt
) external override returns (Quorum) {
Quorum quorum = new Quorum{salt: salt}(validators, epochLength);
) external override returns (IQuorum) {
IQuorum quorum = new Quorum{salt: salt}(validators, epochLength);

emit QuorumCreated(quorum);

Expand Down
10 changes: 5 additions & 5 deletions test/foundry/consensus/quorum/QuorumFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
pragma solidity ^0.8.22;

import {QuorumFactory, IQuorumFactory} from "contracts/consensus/quorum/QuorumFactory.sol";
import {Quorum} from "contracts/consensus/quorum/Quorum.sol";
import {IQuorum} from "contracts/consensus/quorum/IQuorum.sol";
import {Vm} from "forge-std/Vm.sol";

import {TestBase} from "../../util/TestBase.sol";
Expand Down Expand Up @@ -37,7 +37,7 @@ contract QuorumFactoryTest is TestBase {

vm.recordLogs();

Quorum quorum = _factory.newQuorum(validators, epochLength);
IQuorum quorum = _factory.newQuorum(validators, epochLength);

_testNewQuorumAux(validators, epochLength, quorum);
}
Expand All @@ -60,7 +60,7 @@ contract QuorumFactoryTest is TestBase {

vm.recordLogs();

Quorum quorum = _factory.newQuorum(validators, epochLength, salt);
IQuorum quorum = _factory.newQuorum(validators, epochLength, salt);

_testNewQuorumAux(validators, epochLength, quorum);

Expand All @@ -84,7 +84,7 @@ contract QuorumFactoryTest is TestBase {
function _testNewQuorumAux(
address[] memory validators,
uint256 epochLength,
Quorum quorum
IQuorum quorum
) internal {
Vm.Log[] memory entries = vm.getRecordedLogs();

Expand All @@ -97,7 +97,7 @@ contract QuorumFactoryTest is TestBase {
entry.topics[0] == IQuorumFactory.QuorumCreated.selector
) {
++numQuorumCreated;
Quorum eventQuorum = abi.decode(entry.data, (Quorum));
IQuorum eventQuorum = abi.decode(entry.data, (IQuorum));
assertEq(address(eventQuorum), address(quorum));
}
}
Expand Down

0 comments on commit 3ef8cb5

Please sign in to comment.