Skip to content

Commit

Permalink
Merge pull request #41 from gnosisguild/update-language
Browse files Browse the repository at this point in the history
fix: computationModule -> e3Program
  • Loading branch information
auryn-macmillan authored Sep 4, 2024
2 parents b403e83 + 14b6d4d commit b8f9658
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 121 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sequenceDiagram
participant DecryptionVerifier
Users->>Enclave: request(parameters)
Enclave->>E3Program: validate(computationParams)
Enclave->>E3Program: validate(e3ProgramParams)
E3Program-->>Enclave: inputValidator
Enclave->>ComputeProvider: validate(emParams)
ComputeProvider-->>Enclave: decryptionVerifier
Expand Down
58 changes: 20 additions & 38 deletions packages/evm/contracts/Enclave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
// This would reduce the governance overhead for Enclave.

// Mapping of allowed E3 Programs.
mapping(IE3Program computationModule => bool allowed)
public computationModules;
mapping(IE3Program e3Program => bool allowed) public e3Programs;

// Mapping of allowed compute providers.
mapping(IComputeProvider computeProvider => bool allowed)
Expand All @@ -63,7 +62,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
////////////////////////////////////////////////////////////

error CommitteeSelectionFailed();
error E3ProgramNotAllowed(IE3Program computationModule);
error E3ProgramNotAllowed(IE3Program e3Program);
error E3AlreadyActivated(uint256 e3Id);
error E3Expired();
error E3NotActivated(uint256 e3Id);
Expand Down Expand Up @@ -126,8 +125,8 @@ contract Enclave is IEnclave, OwnableUpgradeable {
uint32[2] calldata threshold,
uint256[2] calldata startWindow,
uint256 duration,
IE3Program computationModule,
bytes memory computationParams,
IE3Program e3Program,
bytes memory e3ProgramParams,
IComputeProvider computeProvider,
bytes memory emParams
) external payable returns (uint256 e3Id, E3 memory e3) {
Expand All @@ -148,10 +147,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
duration > 0 && duration <= maxDuration,
InvalidDuration(duration)
);
require(
computationModules[computationModule],
E3ProgramNotAllowed(computationModule)
);
require(e3Programs[e3Program], E3ProgramNotAllowed(e3Program));
require(
computeProviders[computeProvider],
ModuleNotEnabled(address(computeProvider))
Expand All @@ -161,9 +157,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
e3Id = nexte3Id;
nexte3Id++;

IInputValidator inputValidator = computationModule.validate(
computationParams
);
IInputValidator inputValidator = e3Program.validate(e3ProgramParams);
require(address(inputValidator) != address(0), InvalidComputation());

// TODO: validate that the requested computation can be performed by the given compute provider.
Expand All @@ -181,7 +175,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
startWindow: startWindow,
duration: duration,
expiration: 0,
computationModule: computationModule,
e3Program: e3Program,
computeProvider: computeProvider,
inputValidator: inputValidator,
decryptionVerifier: decryptionVerifier,
Expand All @@ -196,13 +190,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
CommitteeSelectionFailed()
);

emit E3Requested(
e3Id,
e3s[e3Id],
filter,
computationModule,
computeProvider
);
emit E3Requested(e3Id, e3s[e3Id], filter, e3Program, computeProvider);
}

function activate(uint256 e3Id) external returns (bool success) {
Expand Down Expand Up @@ -270,7 +258,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
CiphertextOutputAlreadyPublished(e3Id)
);
bytes memory output;
(output, success) = e3.computationModule.verify(e3Id, data);
(output, success) = e3.e3Program.verify(e3Id, data);
require(success, InvalidOutput(output));
e3s[e3Id].ciphertextOutput = output;

Expand Down Expand Up @@ -328,15 +316,15 @@ contract Enclave is IEnclave, OwnableUpgradeable {
}

function enableE3Program(
IE3Program computationModule
IE3Program e3Program
) public onlyOwner returns (bool success) {
require(
!computationModules[computationModule],
ModuleAlreadyEnabled(address(computationModule))
!e3Programs[e3Program],
ModuleAlreadyEnabled(address(e3Program))
);
computationModules[computationModule] = true;
e3Programs[e3Program] = true;
success = true;
emit E3ProgramEnabled(computationModule);
emit E3ProgramEnabled(e3Program);
}

function enableComputeProvider(
Expand All @@ -352,15 +340,12 @@ contract Enclave is IEnclave, OwnableUpgradeable {
}

function disableE3Program(
IE3Program computationModule
IE3Program e3Program
) public onlyOwner returns (bool success) {
require(
computationModules[computationModule],
ModuleNotEnabled(address(computationModule))
);
delete computationModules[computationModule];
require(e3Programs[e3Program], ModuleNotEnabled(address(e3Program)));
delete e3Programs[e3Program];
success = true;
emit E3ProgramDisabled(computationModule);
emit E3ProgramDisabled(e3Program);
}

function disableComputeProvider(
Expand All @@ -383,15 +368,12 @@ contract Enclave is IEnclave, OwnableUpgradeable {

function getE3(uint256 e3Id) public view returns (E3 memory e3) {
e3 = e3s[e3Id];
require(
e3.computationModule != IE3Program(address(0)),
E3DoesNotExist(e3Id)
);
require(e3.e3Program != IE3Program(address(0)), E3DoesNotExist(e3Id));
}

function getInputRoot(uint256 e3Id) public view returns (uint256) {
require(
e3s[e3Id].computationModule != IE3Program(address(0)),
e3s[e3Id].e3Program != IE3Program(address(0)),
E3DoesNotExist(e3Id)
);
return InternalLeanIMT._root(inputs[e3Id]);
Expand Down
4 changes: 2 additions & 2 deletions packages/evm/contracts/interfaces/IE3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { IDecryptionVerifier } from "./IDecryptionVerifier.sol";
/// @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.
/// @param computationModule Address of the E3 Program contract.
/// @param e3Program Address of the E3 Program contract.
/// @param computeProvider Address of the compute provider contract.
/// @param inputValidator Address of the input validator contract.
/// @param decryptionVerifier Address of the output verifier contract.
Expand All @@ -24,7 +24,7 @@ struct E3 {
uint256[2] startWindow;
uint256 duration;
uint256 expiration;
IE3Program computationModule;
IE3Program e3Program;
IComputeProvider computeProvider;
IInputValidator inputValidator;
IDecryptionVerifier decryptionVerifier;
Expand Down
20 changes: 10 additions & 10 deletions packages/evm/contracts/interfaces/IEnclave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ interface IEnclave {
/// @param e3Id ID of the E3.
/// @param e3 Details of the E3.
/// @param filter Address of the pool of nodes from which the Cipher Node committee was selected.
/// @param computationModule Address of the Computation module selected.
/// @param e3Program Address of the Computation module selected.
/// @param computeProvider Address of the compute provider selected.
event E3Requested(
uint256 e3Id,
E3 e3,
address filter,
IE3Program indexed computationModule,
IE3Program indexed e3Program,
IComputeProvider indexed computeProvider
);

Expand Down Expand Up @@ -69,12 +69,12 @@ interface IEnclave {
event CiphernodeRegistrySet(address ciphernodeRegistry);

/// @notice This event MUST be emitted any time a E3 Program is enabled.
/// @param computationModule The address of the E3 Program.
event E3ProgramEnabled(IE3Program computationModule);
/// @param e3Program The address of the E3 Program.
event E3ProgramEnabled(IE3Program e3Program);

/// @notice This event MUST be emitted any time a E3 Program is disabled.
/// @param computationModule The address of the E3 Program.
event E3ProgramDisabled(IE3Program computationModule);
/// @param e3Program The address of the E3 Program.
event E3ProgramDisabled(IE3Program e3Program);

/// @notice This event MUST be emitted any time an compute provider is enabled.
/// @param computeProvider The address of the compute provider.
Expand All @@ -95,8 +95,8 @@ interface IEnclave {
/// @param filter IDs of the pool of nodes from which to select the committee.
/// @param threshold The M/N threshold for the committee.
/// @param duration The duration of the computation in seconds.
/// @param computationModule Address of the E3 Program.
/// @param computationParams ABI encoded computation parameters.
/// @param e3Program Address of the E3 Program.
/// @param e3ProgramParams ABI encoded computation parameters.
/// @param computeProvider Address of the compute provider.
/// @param emParams ABI encoded compute provider parameters.
/// @return e3Id ID of the E3.
Expand All @@ -106,8 +106,8 @@ interface IEnclave {
uint32[2] calldata threshold,
uint256[2] calldata startWindow,
uint256 duration,
IE3Program computationModule,
bytes memory computationParams,
IE3Program e3Program,
bytes memory e3ProgramParams,
IComputeProvider computeProvider,
bytes memory emParams
) external payable returns (uint256 e3Id, E3 memory e3);
Expand Down
Loading

0 comments on commit b8f9658

Please sign in to comment.