diff --git a/packages/evm/contracts/Enclave.sol b/packages/evm/contracts/Enclave.sol index c620d77f..72977b82 100644 --- a/packages/evm/contracts/Enclave.sol +++ b/packages/evm/contracts/Enclave.sol @@ -160,6 +160,7 @@ contract Enclave is IEnclave, OwnableUpgradeable { e3 = E3({ seed: seed, threshold: threshold, + requestBlock: block.number, startWindow: startWindow, duration: duration, expiration: 0, diff --git a/packages/evm/contracts/interfaces/IE3.sol b/packages/evm/contracts/interfaces/IE3.sol index bafb28b5..60971504 100644 --- a/packages/evm/contracts/interfaces/IE3.sol +++ b/packages/evm/contracts/interfaces/IE3.sol @@ -8,6 +8,7 @@ import { IDecryptionVerifier } from "./IDecryptionVerifier.sol"; /// @title E3 struct /// @notice This struct represents an E3 computation. /// @param threshold M/N threshold for the committee. +/// @param requestBlock Block number when the E3 was requested. /// @param startWindow Start window for the computation: index zero is minimum, index 1 is the maxium. /// @param duration Duration of the E3. /// @param expiration Timestamp when committee duties expire. @@ -21,6 +22,7 @@ import { IDecryptionVerifier } from "./IDecryptionVerifier.sol"; struct E3 { uint256 seed; uint32[2] threshold; + uint256 requestBlock; uint256[2] startWindow; uint256 duration; uint256 expiration; diff --git a/packages/evm/contracts/registry/NaiveRegistryFilter.sol b/packages/evm/contracts/registry/NaiveRegistryFilter.sol index 61faa32c..cf7d719b 100644 --- a/packages/evm/contracts/registry/NaiveRegistryFilter.sol +++ b/packages/evm/contracts/registry/NaiveRegistryFilter.sol @@ -34,6 +34,7 @@ contract NaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable { error CommitteeAlreadyPublished(); error CommitteeDoesNotExist(); error CommitteeNotPublished(); + error CiphernodeNotEnabled(address ciphernode); error OnlyRegistry(); //////////////////////////////////////////////////////////// @@ -47,6 +48,15 @@ contract NaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable { _; } + modifier onlyOwnerOrCiphernode() { + require( + msg.sender == owner() || + ICiphernodeRegistry(registry).isCiphernodeEligible(msg.sender), + CiphernodeNotEnabled(msg.sender) + ); + _; + } + //////////////////////////////////////////////////////////// // // // Initialization // diff --git a/packages/evm/test/Enclave.spec.ts b/packages/evm/test/Enclave.spec.ts index 6a32bb43..c7b7fa2e 100644 --- a/packages/evm/test/Enclave.spec.ts +++ b/packages/evm/test/Enclave.spec.ts @@ -587,10 +587,12 @@ describe("Enclave", function () { { value: 10 }, ); const e3 = await enclave.getE3(0); + const block = await ethers.provider.getBlock("latest").catch((e) => e); expect(e3.threshold).to.deep.equal(request.threshold); expect(e3.expiration).to.equal(0n); expect(e3.e3Program).to.equal(request.e3Program); + expect(e3.requestBlock).to.equal(block.number); expect(e3.inputValidator).to.equal( await mocks.inputValidator.getAddress(), );