Skip to content

Commit

Permalink
Services precompile (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
1xstj authored Sep 23, 2024
1 parent 8165ee2 commit 186c8f5
Show file tree
Hide file tree
Showing 13 changed files with 2,033 additions and 220 deletions.
58 changes: 58 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ members = [
"precompiles/verify-schnorr-signatures",
"precompiles/verify-bls381-signature",
"precompiles/multi-asset-delegation",
"precompiles/services",
"tangle-subxt",
"evm-tracer",
]
Expand Down Expand Up @@ -316,6 +317,7 @@ pallet-evm-precompile-verify-ecdsa-secp256r1-signature = { path = "precompiles/v
pallet-evm-precompile-verify-ecdsa-stark-signature = { path = "precompiles/verify-ecdsa-stark-signature", default-features = false }
pallet-evm-precompile-verify-schnorr-signatures = { path = "precompiles/verify-schnorr-signatures", default-features = false }
pallet-evm-precompile-verify-bls381-signature = { path = "precompiles/verify-bls381-signature", default-features = false }
pallet-evm-precompile-services = { path = "precompiles/services", default-features = false }

# Precompiles utils
postcard = { version = "1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion pallets/services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use sp_runtime::{traits::Get, DispatchResult};
mod functions;
mod impls;
mod rpc;
mod traits;
pub mod traits;
pub mod types;

#[cfg(test)]
Expand Down
137 changes: 137 additions & 0 deletions precompiles/services/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
[package]
name = "pallet-evm-precompile-services"
version = "0.1.0"
authors = { workspace = true }
edition = "2021"
description = "A Precompile to make pallet-services calls encoding accessible to pallet-evm"

[dependencies]

# Moonbeam
precompile-utils = { workspace = true }

# Substrate
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-balances = { workspace = true }
pallet-multi-asset-delegation = { workspace = true }
parity-scale-codec = { workspace = true, features = ["derive"] }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

# Frontier
fp-evm = { workspace = true }
pallet-evm = { workspace = true, features = ["forbid-evm-reentrancy"] }
tangle-primitives = { workspace = true }
pallet-services = { workspace = true }

[dev-dependencies]
derive_more = { workspace = true }
hex-literal = { workspace = true }
serde = { workspace = true }
sha3 = { workspace = true }
ethereum = { workspace = true, features = ["with-codec"] }
ethers = "2.0"
hex = { workspace = true }
num_enum = { workspace = true }
libsecp256k1 = { workspace = true }
serde_json = { workspace = true }
smallvec = { workspace = true }
sp-keystore = { workspace = true }

# Moonbeam
precompile-utils = { workspace = true, features = ["std", "testing"] }

# Substrate
pallet-balances = { workspace = true, features = ["std"] }
pallet-assets = { workspace = true, features = ["std"] }
pallet-timestamp = { workspace = true, features = ["std"] }
scale-info = { workspace = true, features = ["derive", "std"] }
sp-io = { workspace = true, features = ["std"] }

# Frontier Primitive
fp-account = { workspace = true }
fp-consensus = { workspace = true }
fp-dynamic-fee = { workspace = true }
fp-ethereum = { workspace = true }
fp-rpc = { workspace = true }
fp-self-contained = { workspace = true }
fp-storage = { workspace = true }

# Frontier FRAME
pallet-base-fee = { workspace = true }
pallet-dynamic-fee = { workspace = true }
pallet-ethereum = { workspace = true }
pallet-evm = { workspace = true }
pallet-evm-chain-id = { workspace = true }

pallet-evm-precompile-blake2 = { workspace = true }
pallet-evm-precompile-bn128 = { workspace = true }
pallet-evm-precompile-curve25519 = { workspace = true }
pallet-evm-precompile-ed25519 = { workspace = true }
pallet-evm-precompile-modexp = { workspace = true }
pallet-evm-precompile-sha3fips = { workspace = true }
pallet-evm-precompile-simple = { workspace = true }

pallet-session = { workspace = true }
pallet-staking = { workspace = true }
sp-staking = { workspace = true }
frame-election-provider-support = { workspace = true }

[features]
default = ["std"]
std = [
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-evm/std",
"pallet-multi-asset-delegation/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"tangle-primitives/std",
"pallet-assets/std",
"pallet-services/std",
"hex/std",
"scale-info/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-std/std",
"sp-io/std",
"tangle-primitives/std",
"pallet-balances/std",
"pallet-timestamp/std",
"fp-account/std",
"fp-consensus/std",
"fp-dynamic-fee/std",
"fp-ethereum/std",
"fp-evm/std",
"fp-rpc/std",
"fp-self-contained/std",
"fp-storage/std",
"pallet-base-fee/std",
"pallet-dynamic-fee/std",
"pallet-ethereum/std",
"pallet-evm/std",
"pallet-evm-chain-id/std",

"pallet-evm-precompile-modexp/std",
"pallet-evm-precompile-sha3fips/std",
"pallet-evm-precompile-simple/std",
"pallet-evm-precompile-blake2/std",
"pallet-evm-precompile-bn128/std",
"pallet-evm-precompile-curve25519/std",
"pallet-evm-precompile-ed25519/std",
"precompile-utils/std",
"serde/std",
"pallet-session/std",
"pallet-staking/std",
"sp-staking/std",
"frame-election-provider-support/std",
]
52 changes: 52 additions & 0 deletions precompiles/services/Services.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.0;

/// @title ServicesPrecompile Interface
/// @dev This interface is meant to interact with the ServicesPrecompile in the Tangle network.
interface ServicesPrecompile {

/// @notice Create a new service blueprint
/// @param blueprint_data The blueprint data encoded as bytes
function createBlueprint(bytes calldata blueprint_data) external;

/// @notice Register an operator for a specific blueprint
/// @param blueprint_id The ID of the blueprint to register for
/// @param preferences The operator's preferences encoded as bytes
/// @param registration_args The registration arguments encoded as bytes
function registerOperator(uint256 blueprint_id, bytes calldata preferences, bytes calldata registration_args) external;

/// @notice Unregister an operator from a specific blueprint
/// @param blueprint_id The ID of the blueprint to unregister from
function unregisterOperator(uint256 blueprint_id) external;

/// @notice Request a service from a specific blueprint
/// @param blueprint_id The ID of the blueprint
/// @param permitted_callers_data The permitted callers for the service encoded as bytes
/// @param service_providers_data The service providers encoded as bytes
/// @param request_args_data The request arguments encoded as bytes
function requestService(uint256 blueprint_id, bytes calldata permitted_callers_data, bytes calldata service_providers_data, bytes calldata request_args_data) external;

/// @notice Terminate a service
/// @param service_id The ID of the service to terminate
function terminateService(uint256 service_id) external;

/// @notice Approve a service request
/// @param request_id The ID of the service request to approve
function approve(uint256 request_id) external;

/// @notice Reject a service request
/// @param request_id The ID of the service request to reject
function reject(uint256 request_id) external;

/// @notice Call a job in the service
/// @param service_id The ID of the service
/// @param job The job index (as uint8)
/// @param args_data The arguments of the job encoded as bytes
function callJob(uint256 service_id, uint8 job, bytes calldata args_data) external;

/// @notice Submit the result of a job call
/// @param service_id The ID of the service
/// @param call_id The ID of the call
/// @param result_data The result data encoded as bytes
function submitResult(uint256 service_id, uint256 call_id, bytes calldata result_data) external;
}
Loading

0 comments on commit 186c8f5

Please sign in to comment.