Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RoutingIsm #1985

Merged
merged 28 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
356717b
Add RoutingIsm
asaj Mar 22, 2023
72936f5
Merge branch 'main' into asaj/routing
asaj Mar 22, 2023
1cff464
Comments and ICA ISM
asaj Mar 22, 2023
c00b1f5
Add ICA routing ISM
asaj Mar 22, 2023
6dca359
rm
asaj Mar 22, 2023
9b4d5ef
Merge branch 'main' into asaj/routing
asaj Mar 22, 2023
6d554fd
test use of mailbox default ISM
asaj Mar 22, 2023
c68c6e0
Remove duplicate test
asaj Mar 22, 2023
0651853
Merge branch 'main' into asaj/routing
asaj Mar 29, 2023
b734c66
Add tests
asaj Mar 29, 2023
454788f
Add DomainRoutingIsmFactory
asaj Apr 4, 2023
19fba46
Merge main
asaj Apr 4, 2023
696348e
cleanup
asaj Apr 4, 2023
7fb391c
Merge branch 'main' into asaj/routing
asaj Apr 4, 2023
fe1c223
Merge branch 'main' into asaj/routing
asaj Apr 4, 2023
13d9ace
more coverage
asaj Apr 4, 2023
7924193
Merge branch 'asaj/routing' of github.com:abacus-network/abacus-monor…
asaj Apr 4, 2023
8a28813
Test factory
asaj Apr 4, 2023
f27e08a
Merge branch 'main' into asaj/routing
asaj Apr 5, 2023
4e143c9
Merge branch 'main' into asaj/routing
asaj Apr 5, 2023
27c776f
Merge branch 'asaj/routing' of github.com:abacus-network/abacus-monor…
asaj Apr 6, 2023
edc1701
Merge branch 'main' into asaj/routing
asaj Apr 6, 2023
d896d66
Merge branch 'main' into asaj/routing
asaj Apr 12, 2023
fc5cf95
Merge branch 'asaj/routing' of github.com:abacus-network/abacus-monor…
asaj Apr 12, 2023
a0a8987
Comments
asaj Apr 12, 2023
b5d2579
Fix tests
asaj Apr 12, 2023
6e287c5
Merge branch 'main' into asaj/routing
asaj Apr 17, 2023
409faf9
Pragma
asaj Apr 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test factory
  • Loading branch information
asaj committed Apr 4, 2023
commit 8a288135618bf40b945d476cb89509c8b262289d
25 changes: 16 additions & 9 deletions solidity/contracts/isms/routing/DomainRoutingIsm.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.0;
// ============ External Imports ============
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";

// ============ Internal Imports ============
import {AbstractRoutingIsm} from "./AbstractRoutingIsm.sol";
Expand All @@ -11,7 +11,7 @@ import {Message} from "../../libs/Message.sol";
/**
* @title DomainRoutingIsm
*/
contract DomainRoutingIsm is AbstractRoutingIsm, Ownable {
contract DomainRoutingIsm is AbstractRoutingIsm, OwnableUpgradeable {
asaj marked this conversation as resolved.
Show resolved Hide resolved
// ============ Public Storage ============
mapping(uint32 => IInterchainSecurityModule) public modules;

Expand All @@ -24,27 +24,34 @@ contract DomainRoutingIsm is AbstractRoutingIsm, Ownable {
*/
event ModuleSet(uint32 indexed domain, IInterchainSecurityModule module);

// ============ Constructor ============

// solhint-disable-next-line no-empty-blocks
constructor() Ownable() {}

// ============ External Functions ============

/**
* @param _owner The owner of the contract.
*/
function initialize(address _owner) public initializer {
__Ownable_init();
_transferOwnership(_owner);
}

/**
* @notice Sets the ISMs to be used for the specified origin domains
* @param _owner The owner of the contract.
* @param _domains The origin domains
* @param _modules The ISMs to use to verify messages
*/
function set(
function initialize(
address _owner,
uint32[] calldata _domains,
IInterchainSecurityModule[] calldata _modules
) external onlyOwner {
) public initializer {
__Ownable_init();
require(_domains.length == _modules.length, "length mismatch");
uint256 _length = _domains.length;
for (uint256 i = 0; i < _length; ++i) {
_set(_domains[i], _modules[i]);
}
_transferOwnership(_owner);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions solidity/contracts/isms/routing/DomainRoutingIsmFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ contract DomainRoutingIsmFactory {
function deploy(
uint32[] calldata _domains,
IInterchainSecurityModule[] calldata _modules
) external {
) external returns (DomainRoutingIsm) {
DomainRoutingIsm _ism = DomainRoutingIsm(
MinimalProxy.create(_implementation)
asaj marked this conversation as resolved.
Show resolved Hide resolved
);
_ism.set(_domains, _modules);
_ism.initialize(msg.sender, _domains, _modules);
return _ism;
}
}
7 changes: 5 additions & 2 deletions solidity/test/isms/DomainRoutingIsm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.13;
import "forge-std/Test.sol";

import {DomainRoutingIsm} from "../../contracts/isms/routing/DomainRoutingIsm.sol";
import {DomainRoutingIsmFactory} from "../../contracts/isms/routing/DomainRoutingIsmFactory.sol";
import {IInterchainSecurityModule} from "../../contracts/interfaces/IInterchainSecurityModule.sol";
import {MessageUtils, TestIsm} from "./IsmTestUtils.sol";

Expand All @@ -14,6 +15,7 @@ contract DomainRoutingIsmTest is Test {

function setUp() public {
ism = new DomainRoutingIsm();
ism.initialize(address(this));
}

function deployTestIsm(uint32 domain, bytes32 requiredMetadata)
Expand All @@ -36,12 +38,13 @@ contract DomainRoutingIsmTest is Test {
assertEq(address(ism.modules(domain)), address(_ism));
}

function testSetMany(
function testSetManyViaFactory(
uint8 count,
uint32 domain,
IInterchainSecurityModule _ism
) public {
vm.assume(domain > count && uint160(address(_ism)) > count);
DomainRoutingIsmFactory factory = new DomainRoutingIsmFactory();
uint32[] memory _domains = new uint32[](count);
IInterchainSecurityModule[]
memory _isms = new IInterchainSecurityModule[](count);
Expand All @@ -53,7 +56,7 @@ contract DomainRoutingIsmTest is Test {
vm.expectEmit(true, true, false, true);
emit ModuleSet(_domains[i], _isms[i]);
}
ism.set(_domains, _isms);
ism = factory.deploy(_domains, _isms);
for (uint256 i = 0; i < count; ++i) {
assertEq(address(ism.modules(_domains[i])), address(_isms[i]));
}
Expand Down