Skip to content
Open
27 changes: 27 additions & 0 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
panic = "unwind"

[workspace]
members = [
"node",
"pallets/*",
"runtime",
]
members = ["node", "pallets/*", "runtime"]

resolver = "2"

Expand All @@ -31,11 +27,13 @@ jsonrpsee = { version = "0.22.5", features = ["server"] }
libsecp256k1 = { version = "0.7", default-features = false, features = [
"hmac",
"static-context",
]}
] }
log = { version = "0.4.20", default-features = false }
num_enum = { version = "0.5.3", default-features = false }
sha3 = { version = "0.10.1", default-features = false }
scale-info = { version = "2.3.1", default-features = false, features = [ "derive" ] }
scale-info = { version = "2.3.1", default-features = false, features = [
"derive",
] }
similar-asserts = { version = "1.1.0" }
slices = "0.2.0"
smallvec = "1.10.0"
Expand Down Expand Up @@ -144,7 +142,9 @@ fc-storage = { git = "https://github.com/polkadot-evm/frontier", branch = "polka
fc-mapping-sync = { git = "https://github.com/polkadot-evm/frontier", branch = "polkadot-v1.11.0" }
fp-evm = { git = "https://github.com/polkadot-evm/frontier", branch = "polkadot-v1.11.0", default-features = false }
fp-rpc = { git = "https://github.com/polkadot-evm/frontier", default-features = false, branch = "polkadot-v1.11.0" }
fp-self-contained = { git = "https://github.com/polkadot-evm/frontier", default-features = false, branch = "polkadot-v1.11.0", features = ["serde"] }
fp-self-contained = { git = "https://github.com/polkadot-evm/frontier", default-features = false, branch = "polkadot-v1.11.0", features = [
"serde",
] }

# Cumulus
cumulus-client-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0" }
Expand Down Expand Up @@ -186,7 +186,7 @@ xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/par
# Staking
substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false }
pallet-parachain-staking = { path = "pallets/parachain-staking", default-features = false }
#pallet-evm-precompile-parachain-staking = { path = "precompiles/parachain-staking", default-features = false }
pallet-evm-precompile-parachain-staking = { path = "precompiles/parachain-staking", default-features = false }
# num-integer = { version = "0.1", default-features = false }
# sp-consensus-slots = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.11.0" }

Expand Down
55 changes: 55 additions & 0 deletions precompiles/parachain-staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[package]
name = "pallet-evm-precompile-parachain-staking"
authors = { workspace = true }
description = "A Precompile to make parachain staking accessible to pallet-evm"
edition = "2021"
version = "2.0.0"

[dependencies]
log = { workspace = true }
num_enum = { workspace = true }
rustc-hex = { workspace = true }

# Local
pallet-parachain-staking = { workspace = true }

# Substrate
frame-support = { workspace = true }
frame-system = { workspace = true }
codec = { workspace = true, features = ["max-encoded-len"] }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-std = { workspace = true }
sp-runtime = { workspace = true }

# Frontier
fp-evm = { workspace = true }
pallet-evm = { workspace = true, features = ["forbid-evm-reentrancy"] }
precompile-utils = { workspace = true }

[dev-dependencies]
derive_more = { workspace = true }
serde = { workspace = true }
sha3 = { workspace = true }

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

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

[features]
default = ["std"]
std = [
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-parachain-staking/std",
"codec/std",
"precompile-utils/std",
"sp-core/std",
"sp-std/std",
]
219 changes: 219 additions & 0 deletions precompiles/parachain-staking/StakingInterface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.8.0;

/**
* @author The Moonbeam Team, modified by: OriginTrail Team
* @title The interface through which solidity contracts will interact with Parachain Staking
* We follow this same interface including four-byte function selectors, in the precompile that
* wraps the pallet
* Address : 0x0000000000000000000000000000000000000800
*/

interface ParachainStaking {
/// @dev Check whether the specified address is currently a staking delegator
/// Selector: 1f030587
/// @param delegator the address that we want to confirm is a delegator
/// @return A boolean confirming whether the address is a delegator
function is_delegator(address delegator) external view returns (bool);

/// @dev Check whether the specified address is currently a collator candidate
/// Selector: 8545c833
/// @param candidate the address that we want to confirm is a collator andidate
/// @return A boolean confirming whether the address is a collator candidate
function is_candidate(address candidate) external view returns (bool);

/// @dev Check whether the specifies address is currently a part of the active set
/// Selector: 8f6d27c7
/// @param candidate the address that we want to confirm is a part of the active set
/// @return A boolean confirming whether the address is a part of the active set
function is_selected_candidate(
address candidate
) external view returns (bool);

/// @dev Total points awarded to all collators in a particular round
/// Selector: 9799b4e7
/// @param round the round for which we are querying the points total
/// @return The total points awarded to all collators in the round
function points(uint256 round) external view returns (uint256);

/// @dev Get the minimum delegation amount
/// Selector: 72ce8933
/// @return The minimum delegation amount
function min_delegation() external view returns (uint256);

/// @dev Get the CandidateCount weight hint
/// Selector: 4b1c4c29
/// @return The CandidateCount weight hint
function candidate_count() external view returns (uint256);

/// @dev Get the current round number
/// Selector: 146ca531
/// @return The current round number
function round() external view returns (uint256);

/// @dev Get the CandidateDelegationCount weight hint
/// Selector: 815b796c
/// @param candidate The address for which we are querying the nomination count
/// @return The number of nominations backing the collator
function candidate_delegation_count(
address candidate
) external view returns (uint256);

/// @dev Get the DelegatorDelegationCount weight hint
/// Selector: fbc51bca
/// @param delegator The address for which we are querying the delegation count
/// @return The number of delegations made by the delegator
function delegator_delegation_count(
address delegator
) external view returns (uint256);

/// @dev Whether there exists a pending request for a delegation made by a delegator
/// Selector: 192e1db3
/// @param delegator the delegator that made the delegation
/// @param candidate the candidate for which the delegation was made
/// @return Whether a pending request exists for such delegation
function delegation_request_is_pending(
address delegator,
address candidate
) external view returns (bool);

/// @dev Whether there exists a pending exit for delegator
/// Selector: dc3ec64b
/// @param delegator the delegator that made the exit request
/// @return Whether a pending exit exists for delegator
function delegator_exit_is_pending(
address delegator
) external view returns (bool);

/// @dev Whether there exists a pending exit for candidate
/// Selector: eb613b8a
/// @param candidate the candidate for which the exit request was made
/// @return Whether a pending request exists for such delegation
function candidate_exit_is_pending(
address candidate
) external view returns (bool);

/// @dev Whether there exists a pending bond less request made by a candidate
/// Selector: 26ab05fb
/// @param candidate the candidate which made the request
/// @return Whether a pending bond less request was made by the candidate
function candidate_request_is_pending(
address candidate
) external view returns (bool);

/// @dev Join the set of collator candidates
/// Selector: 0a1bff60
/// @param amount The amount self-bonded by the caller to become a collator candidate
/// @param candidateCount The number of candidates in the CandidatePool
function join_candidates(uint256 amount, uint256 candidateCount) external;

/// @dev Request to leave the set of collator candidates
/// Selector: 60afbac6
/// @param candidateCount The number of candidates in the CandidatePool
function schedule_leave_candidates(uint256 candidateCount) external;

/// @dev Execute due request to leave the set of collator candidates
/// Selector: 3fdc4c30
/// @param candidate The candidate address for which the pending exit request will be executed
/// @param candidateDelegationCount The number of delegations for the candidate to be revoked
function execute_leave_candidates(
address candidate,
uint256 candidateDelegationCount
) external;

/// @dev Cancel request to leave the set of collator candidates
/// Selector: 0880b3e2
/// @param candidateCount The number of candidates in the CandidatePool
function cancel_leave_candidates(uint256 candidateCount) external;

/// @dev Temporarily leave the set of collator candidates without unbonding
/// Selector: 767e0450
function go_offline() external;

/// @dev Rejoin the set of collator candidates if previously had called `go_offline`
/// Selector: d2f73ceb
function go_online() external;

/// @dev Request to bond more for collator candidates
/// Selector: c57bd3a8
/// @param more The additional amount self-bonded
function candidate_bond_more(uint256 more) external;

/// @dev Request to bond less for collator candidates
/// Selector: 034c47bc
/// @param less The amount to be subtracted from self-bond and unreserved
function schedule_candidate_bond_less(uint256 less) external;

/// @dev Execute pending candidate bond request
/// Selector: a9a2b8b7
/// @param candidate The address for the candidate for which the request will be executed
function execute_candidate_bond_less(address candidate) external;

/// @dev Cancel pending candidate bond request
/// Selector: 583d0fdc
function cancel_candidate_bond_less() external;

/// @dev Make a delegation in support of a collator candidate
/// Selector: 829f5ee3
/// @param candidate The address of the supported collator candidate
/// @param amount The amount bonded in support of the collator candidate
/// @param candidateDelegationCount The number of delegations in support of the candidate
/// @param delegatorDelegationCount The number of existing delegations by the caller
function delegate(
address candidate,
uint256 amount,
uint256 candidateDelegationCount,
uint256 delegatorDelegationCount
) external;

/// @dev Request to leave the set of delegators
/// Selector: 65a5bbd0
function schedule_leave_delegators() external;

/// @dev Execute request to leave the set of delegators and revoke all delegations
/// Selector: a84a7468
/// @param delegator The leaving delegator
/// @param delegatorDelegationCount The number of active delegations to be revoked by delegator
function execute_leave_delegators(
address delegator,
uint256 delegatorDelegationCount
) external;

/// @dev Cancel request to leave the set of delegators
/// Selector: 2a987643
function cancel_leave_delegators() external;

/// @dev Request to revoke an existing delegation
/// Selector: 22266e75
/// @param candidate The address of the collator candidate which will no longer be supported
function schedule_revoke_delegation(address candidate) external;

/// @dev Bond more for delegators with respect to a specific collator candidate
/// Selector: f8331108
/// @param candidate The address of the collator candidate for which delegation shall increase
/// @param more The amount by which the delegation is increased
function delegator_bond_more(address candidate, uint256 more) external;

/// @dev Request to bond less for delegators with respect to a specific collator candidate
/// Selector: 00043acf
/// @param candidate The address of the collator candidate for which delegation shall decrease
/// @param less The amount by which the delegation is decreased (upon execution)
function schedule_delegator_bond_less(
address candidate,
uint256 less
) external;

/// @dev Execute pending delegation request (if exists && is due)
/// Selector: e42366a6
/// @param delegator The address of the delegator
/// @param candidate The address of the candidate
function execute_delegation_request(
address delegator,
address candidate
) external;

/// @dev Cancel pending delegation request (already made in support of input by caller)
/// Selector: 7284cf50
/// @param candidate The address of the candidate
function cancel_delegation_request(address candidate) external;
}
Loading