Skip to content

Commit

Permalink
update interface
Browse files Browse the repository at this point in the history
  • Loading branch information
1xstj committed Nov 28, 2023
1 parent f481b8c commit 4b12b30
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 14 deletions.
118 changes: 110 additions & 8 deletions precompiles/jobs/Jobs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,115 @@ Jobs constant JOBS_CONTRACT = Jobs(JOBS_ADDRESS);
/// @author Webb Inc
/// @title Pallet Jobs Interface
/// @title The interface through which solidity contracts will interact with the jobs pallet
/// @custom:address 0x0000000000000000000000000000000000000813
/// @custom:address 0x0000000000000000000000000000000000000820
interface Jobs {
/// @dev Register Jobs on-chain.
/// @custom:selector cb00f603
/// @param jobSubmission The jobs to be registered on-chain
/// @return jobsHash The hash of the jobs
function submitJobs(bytes memory jobSubmission)
external
returns (bytes32 jobsHash);

/// Submit a DKG phase one job
/// @custom:selector <selector_hash>
///
/// @notice Submits a job for the first phase of the Distributed Key Generation (DKG) process.
///
/// @param expiry The expiration timestamp for the submitted job.
/// @param participants An array of Ethereum addresses representing participants in the DKG.
/// @param threshold The minimum number of participants required for the DKG to succeed.
/// @param permitted_caller The Ethereum address of the permitted caller initiating the job submission.
///
/// @dev This function initiates the first phase of a DKG process, allowing participants to collaborate
/// in generating cryptographic keys. The submitted job includes information such as the expiration time,
/// the list of participants, the threshold for successful completion, and the permitted caller's address.
/// It is crucial for the caller to ensure that the specified parameters align with the intended DKG process.
///
function submitDkgPhaseOneJob(
uint64 expiry,
address[] memory participants,
uint8 threshold,
address permitted_caller
) external;

/// @custom:selector <selector_hash>
///
/// @notice Submits a job for the second phase of the Distributed Key Generation (DKG) process.
///
/// @param expiry The expiration timestamp for the submitted job.
/// @param phase_one_id The identifier of the corresponding phase one DKG job.
/// @param submission The byte array containing the data submission for the DKG phase two.
///
/// @dev This function initiates the second phase of a Distributed Key Generation process, building upon
/// the results of a prior phase one submission. The submitted job includes an expiration time, the identifier
/// of the phase one DKG job, and the byte array representing the participant's data contribution for phase two.
/// It is important for the caller to ensure that the provided parameters align with the ongoing DKG process.
///
function submitDkgPhaseTwoJob(
uint64 expiry,
uint32 phase_one_id,
bytes memory submission
) external;

/// @custom:selector <selector_hash>
///
/// @notice Submits a job for the first phase of the Zero-Knowledge as a Service (ZkSaas) protocol.
///
/// @param expiry The expiration timestamp for the submitted job.
/// @param participants An array of Ethereum addresses representing participants in the ZkSaas phase one.
/// @param permitted_caller The Ethereum address of the permitted caller initiating the job submission.
///
/// @dev This function initiates the first phase of a ZkSaas protocol, where participants collaborate to achieve
/// specific cryptographic tasks. The submitted job includes details such as the expiration time, the list of
/// participants, and the permitted caller's address. It is essential for the caller to ensure that the provided
/// parameters align with the intended ZkSaas phase one process.
///
function submitDkgzkSaasPhaseOneJob(
uint64 expiry,
address[] memory participants,
address permitted_caller
) external;

/// @custom:selector <selector_hash>
///
/// @notice Submits a job for the second phase of the Zero-Knowledge as a Service (ZkSaas) protocol.
///
/// @param expiry The expiration timestamp for the submitted job.
/// @param phase_one_id The identifier of the corresponding phase one ZkSaas job.
/// @param submission The byte array containing the data submission for the ZkSaas phase two.
///
/// @dev This function initiates the second phase of a Zero-Knowledge as a Service protocol, building upon
/// the results of a prior phase one submission. The submitted job includes an expiration time, the identifier
/// of the phase one ZkSaas job, and the byte array representing the participant's data contribution for phase two.
/// It is important for the caller to ensure that the provided parameters align with the ongoing ZkSaas process.
///
function submitzkSaasPhaseTwoJob(
uint64 expiry,
uint32 phase_one_id,
bytes memory submission
) external;

/// @custom:selector <selector_hash>
///
/// @notice Initiates the withdrawal of accumulated rewards for the caller.
///
/// @dev This function allows the caller to withdraw any rewards accumulated through participation in
/// various activities or processes within the contract. The withdrawal process is triggered by invoking
/// this function, and the caller receives their entitled rewards accordingly.
///
function withdrawRewards(
) external;

/// @custom:selector <selector_hash>
///
/// @notice Sets a new permitted caller for a specific job type identified by the given key and job ID.
///
/// @param job_key An identifier specifying the type of job to update the permitted caller for.
/// @param job_id The unique identifier of the job for which the permitted caller is being updated.
/// @param new_permitted_caller The Ethereum address of the new permitted caller.
///
/// @dev This function provides flexibility in managing permitted callers for different job types.
/// The caller can specify the job key, job ID, and the new Ethereum address that will be granted permission
/// to initiate the specified job. It is important for the caller to ensure that the provided parameters
/// align with the ongoing processes and permissions within the contract.
///
function setPermittedCaller(
uint8 job_key,
uint32 job_id,
address new_permitted_caller
) external;
}
12 changes: 6 additions & 6 deletions precompiles/jobs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ where
/// # Returns
///
/// Returns an `EvmResult`, indicating the success or failure of the operation.
#[precompile::public("submit_dkg_phase_one_job(uint64,address[],uint8,address)")]
#[precompile::public("submitDkgPhaseOneJob(uint64,address[],uint8,address)")]
fn submit_dkg_phase_one_job(
handle: &mut impl PrecompileHandle,
expiry: u64,
Expand Down Expand Up @@ -126,7 +126,7 @@ where
/// # Returns
///
/// Returns an `EvmResult`, indicating the success or failure of the operation.
#[precompile::public("submit_dkg_phase_two_job(uint64,uint32,bytes)")]
#[precompile::public("submitDkgPhaseTwoJob(uint64,uint32,bytes)")]
fn submit_dkg_phase_two_job(
handle: &mut impl PrecompileHandle,
expiry: u64,
Expand Down Expand Up @@ -170,7 +170,7 @@ where
/// # Returns
///
/// Returns an `EvmResult`, indicating the success or failure of the operation.
#[precompile::public("submit_zksaas_phase_one_job(uint64,address[],address)")]
#[precompile::public("submitDkgzkSaasPhaseOneJob(uint64,address[],address)")]
fn submit_zksaas_phase_one_job(
handle: &mut impl PrecompileHandle,
expiry: u64,
Expand Down Expand Up @@ -222,7 +222,7 @@ where
/// # Returns
///
/// Returns an `EvmResult`, indicating the success or failure of the operation.
#[precompile::public("submit_zksaas_phase_two_job(uint64,uint32,bytes)")]
#[precompile::public("submitzkSaasPhaseTwoJob(uint64,uint32,bytes)")]
fn submit_zksaas_phase_two_job(
handle: &mut impl PrecompileHandle,
expiry: u64,
Expand Down Expand Up @@ -263,7 +263,7 @@ where
/// # Returns
///
/// Returns an `EvmResult`, indicating the success or failure of the operation.
#[precompile::public("withdraw_rewards()")]
#[precompile::public("withdrawRewards()")]
fn withdraw_rewards(handle: &mut impl PrecompileHandle) -> EvmResult {
// Convert caller's Ethereum address to Substrate account ID
let origin = Runtime::AddressMapping::into_account_id(handle.context().caller);
Expand Down Expand Up @@ -291,7 +291,7 @@ where
/// # Returns
///
/// Returns an `EvmResult`, indicating the success or failure of the operation.
#[precompile::public("set_permitted_caller(uint8,uint32,address)")]
#[precompile::public("setPermittedCaller(uint8,uint32,address)")]
fn set_permitted_caller(
handle: &mut impl PrecompileHandle,
job_key: u8,
Expand Down

0 comments on commit 4b12b30

Please sign in to comment.