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: block number to e3 struct #150

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions packages/evm/contracts/Enclave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ contract Enclave is IEnclave, OwnableUpgradeable {
e3 = E3({
seed: seed,
threshold: threshold,
requestBlock: block.number,
startWindow: startWindow,
duration: duration,
expiration: 0,
Expand Down
2 changes: 2 additions & 0 deletions packages/evm/contracts/interfaces/IE3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions packages/evm/contracts/registry/NaiveRegistryFilter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract NaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable {
error CommitteeAlreadyPublished();
error CommitteeDoesNotExist();
error CommitteeNotPublished();
error CiphernodeNotEnabled(address ciphernode);
error OnlyRegistry();

////////////////////////////////////////////////////////////
Expand All @@ -47,6 +48,15 @@ contract NaiveRegistryFilter is IRegistryFilter, OwnableUpgradeable {
_;
}

modifier onlyOwnerOrCiphernode() {
require(
msg.sender == owner() ||
ICiphernodeRegistry(registry).isCiphernodeEligible(msg.sender),
CiphernodeNotEnabled(msg.sender)
);
_;
}

////////////////////////////////////////////////////////////
// //
// Initialization //
Expand Down
2 changes: 2 additions & 0 deletions packages/evm/test/Enclave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
Expand Down
Loading