diff --git a/contracts/contracts/coordination/Coordinator.sol b/contracts/contracts/coordination/Coordinator.sol index e58337a7..2672fede 100644 --- a/contracts/contracts/coordination/Coordinator.sol +++ b/contracts/contracts/coordination/Coordinator.sol @@ -138,8 +138,43 @@ contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable } } - function rituals(uint32 ritualId) public view returns (Ritual memory) { - return storageRitual(ritualId); + function rituals( + uint256 ritualId // uint256 for backward compatibility + ) + external + view + returns ( + address initiator, + uint32 initTimestamp, + uint32 endTimestamp, + uint16 totalTranscripts, + uint16 totalAggregations, + // + address authority, + uint16 dkgSize, + uint16 threshold, + bool aggregationMismatch, + // + IEncryptionAuthorizer accessController, + BLS12381.G1Point memory publicKey, + bytes memory aggregatedTranscript, + IFeeModel feeModel + ) + { + Ritual storage ritual = storageRitual(uint32(ritualId)); + initiator = ritual.initiator; + initTimestamp = ritual.initTimestamp; + endTimestamp = ritual.endTimestamp; + totalTranscripts = ritual.totalTranscripts; + totalAggregations = ritual.totalAggregations; + authority = ritual.authority; + dkgSize = ritual.dkgSize; + threshold = ritual.threshold; + aggregationMismatch = ritual.aggregationMismatch; + accessController = ritual.accessController; + publicKey = ritual.publicKey; + aggregatedTranscript = ritual.aggregatedTranscript; + feeModel = ritual.feeModel; } // for backward compatibility @@ -152,7 +187,7 @@ contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable } function getInitiator(uint32 ritualId) external view returns (address) { - return rituals(ritualId).initiator; + return storageRitual(ritualId).initiator; } function getTimestamps( @@ -377,7 +412,7 @@ contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable } function getAuthority(uint32 ritualId) external view returns (address) { - return rituals(ritualId).authority; + return storageRitual(ritualId).authority; } function postAggregation( diff --git a/deployment/artifacts/lynx.json b/deployment/artifacts/lynx.json index 7d1f65d6..ddbf5bba 100644 --- a/deployment/artifacts/lynx.json +++ b/deployment/artifacts/lynx.json @@ -4539,6 +4539,13 @@ ], "outputs": [] }, + { + "type": "function", + "name": "initializeNumberOfRituals", + "stateMutability": "nonpayable", + "inputs": [], + "outputs": [] + }, { "type": "function", "name": "initiateRitual", @@ -4844,7 +4851,7 @@ "stateMutability": "view", "inputs": [ { - "name": "", + "name": "ritualId", "type": "uint256", "internalType": "uint256" } @@ -7054,4 +7061,4 @@ "deployer": "0x3B42d26E19FF860bC4dEbB920DD8caA53F93c600" } } -} +} \ No newline at end of file diff --git a/deployment/params.py b/deployment/params.py index 53826e26..e91e85e5 100644 --- a/deployment/params.py +++ b/deployment/params.py @@ -4,7 +4,7 @@ from pathlib import Path from typing import Any, List -from ape import chain, networks +from ape import chain, networks, project from ape.api import AccountAPI, ReceiptAPI from ape.cli.choices import select_account from ape.contracts.base import ContractContainer, ContractInstance, ContractTransactionHandler @@ -633,6 +633,13 @@ def _deploy_proxy( return contract_type_container.at(proxy_contract.address) def upgrade(self, container: ContractContainer, proxy_address, data=b"") -> ContractInstance: + implementation = self.deploy(container) + # upgrade proxy to implementation + return self.upgradeTo(implementation, proxy_address, data) + + def upgradeTo( + self, implementation: ContractInstance, proxy_address, data=b"" + ) -> ContractInstance: admin_slot = chain.provider.get_storage_at(address=proxy_address, slot=EIP1967_ADMIN_SLOT) if admin_slot == EMPTY_BYTES32: @@ -645,12 +652,9 @@ def upgrade(self, container: ContractContainer, proxy_address, data=b"") -> Cont proxy_admin = OZ_DEPENDENCY.ProxyAdmin.at(admin_address) # TODO: Check that owner of proxy admin is deployer - implementation = self.deploy(container) - # TODO: initialize taco app implementation too - self.transact(proxy_admin.upgradeAndCall, proxy_address, implementation.address, data) - wrapped_instance = container.at(proxy_address) + wrapped_instance = getattr(project, implementation.contract_type.name).at(proxy_address) return wrapped_instance def finalize(self, deployments: List[ContractInstance]) -> None: diff --git a/scripts/lynx/upgrade_coordinator.py b/scripts/lynx/upgrade_coordinator.py index 39161981..5ecf8704 100644 --- a/scripts/lynx/upgrade_coordinator.py +++ b/scripts/lynx/upgrade_coordinator.py @@ -4,10 +4,11 @@ from deployment.constants import ARTIFACTS_DIR, CONSTRUCTOR_PARAMS_DIR from deployment.params import Deployer -from deployment.registry import contracts_from_registry +from deployment.registry import contracts_from_registry, merge_registries VERIFY = False CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "lynx" / "upgrade-coordinator.yml" +LYNX_REGISTRY = ARTIFACTS_DIR / "lynx.json" def main(): @@ -18,6 +19,16 @@ def main(): deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH, verify=VERIFY) instances = contracts_from_registry(filepath=ARTIFACTS_DIR / "lynx.json", chain_id=80002) + # `initializeNumberOfRituals` was used for the original upgrade, but should NOT be + # used for subsequent upgrades of Coordinator + # implementation = deployer.deploy(project.Coordinator) + # encoded_initializer_function = implementation.initializeNumberOfRituals.encode_input() + # encoded_initializer_function = b"" + # coordinator = deployer.upgradeTo( + # implementation, + # instances[project.Coordinator.contract_type.name].address, + # encoded_initializer_function, + # ) coordinator = deployer.upgrade( project.Coordinator, instances[project.Coordinator.contract_type.name].address ) @@ -27,3 +38,8 @@ def main(): ] deployer.finalize(deployments=deployments) + merge_registries( + registry_1_filepath=LYNX_REGISTRY, + registry_2_filepath=deployer.registry_filepath, + output_filepath=LYNX_REGISTRY, + ) diff --git a/scripts/ritual_state_check.py b/scripts/ritual_state_check.py index c414fd9b..c6810623 100644 --- a/scripts/ritual_state_check.py +++ b/scripts/ritual_state_check.py @@ -114,6 +114,7 @@ def cli(network, domain, ritual_id, realtime): f"\tAccessController : " f"{ritual.accessController} {'(GlobalAllowList)' if isGlobalAllowList else ''}" ) + print(f"\tFee Model : {ritual.feeModel}") print("\tParticipants :") for participant in participants: provider = participant.provider