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

Crowdloan rewards precompiles #607

Merged
merged 36 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
13933d3
First sketch of claim
girazoki Jul 15, 2021
015ed47
Fmt and leftovers
girazoki Jul 15, 2021
d939d68
Catching up on tests
girazoki Jul 15, 2021
cfe4c9c
First tests working
girazoki Jul 15, 2021
89876c5
Crowdloan precompiles start working
girazoki Jul 15, 2021
44dc9de
New reward info precompile
girazoki Jul 15, 2021
d2dc52d
std in vec
girazoki Jul 15, 2021
b6ffffd
workspace fixing and lint
girazoki Jul 15, 2021
6fb519e
More fmt
girazoki Jul 15, 2021
18b7439
Add to all runtimes
girazoki Jul 15, 2021
c15f240
Only moonbase tests working
girazoki Jul 15, 2021
dadfcbd
Forgot ignore in moonriver
girazoki Jul 19, 2021
2f24e98
Undoing the ignore for moonriver
girazoki Jul 19, 2021
9a3ce46
add tracing subscriber to display logs
nanocryk Jul 19, 2021
5781902
precompile add to test
girazoki Jul 19, 2021
f55772a
Revert "add tracing subscriber to display logs"
girazoki Jul 19, 2021
33edeec
Check for target gas when reading storage
girazoki Jul 19, 2021
5d40a97
Merge remote-tracking branch 'upstream/master' into crowdloan_rewards…
girazoki Jul 19, 2021
41c9ab0
Add common package for precompile utils
girazoki Jul 20, 2021
58ac463
Update toml file
girazoki Jul 20, 2021
30e021a
Add update_reward_address precompile
girazoki Jul 20, 2021
322e0db
Add update_reward_address with ignore to rest of the runtimes
girazoki Jul 20, 2021
fdc829b
fmt
girazoki Jul 20, 2021
e35a3cf
fmt plus other review comments
girazoki Jul 20, 2021
3f18dc3
Better solidity writing
girazoki Jul 21, 2021
f8d9fe8
Input bounds
girazoki Jul 21, 2021
111f3fe
Remove trace log from common function
girazoki Jul 21, 2021
b886737
Clean parachain-staking-precompile traces
girazoki Jul 21, 2021
84fbade
Revert introduced error
girazoki Jul 21, 2021
4326731
utils
nanocryk Jul 22, 2021
cfe0956
Adapt to new precompile-utils
girazoki Jul 22, 2021
faf6222
Merge remote-tracking branch 'upstream/master' into crowdloan_rewards…
girazoki Jul 22, 2021
fc60b01
Revert "Clean parachain-staking-precompile traces"
girazoki Jul 22, 2021
d80ea6a
Clean parachain-staking
girazoki Jul 22, 2021
10b023c
Remove leftovers from previous utils
girazoki Jul 22, 2021
cb32a65
fmt
girazoki Jul 22, 2021
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
36 changes: 36 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
'node',
'node/cli',
'node/service',
'bin/utils/moonkey'
'bin/utils/moonkey',
]
exclude = [
'bin/utils/moonkey'
Expand Down
47 changes: 47 additions & 0 deletions precompiles/crowdloan-rewards/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[package]
name = "crowdloan-rewards-precompiles"
version = "0.6.0"
authors = ["PureStake"]
edition = "2018"
description = "A Precompile to make crowdloan rewards accessible to pallet-evm"

[dependencies]
log = "0.4"
rustc-hex = { version = "2.0.1", default-features = false }

codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
evm = { version = "0.27.0", default-features = false, features = ["with-codec"] }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
pallet-evm = { git = "https://github.com/purestake/frontier", default-features = false, branch = "moonbeam-polkadot-v0.9.8" }
pallet-crowdloan-rewards = { git = "https://github.com/purestake/crowdloan-rewards", default-features = false, branch = "main" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }

[dev-dependencies]
hex = "0.4"
hex-literal = "0.3.1"
4meta5 marked this conversation as resolved.
Show resolved Hide resolved
sp-runtime = { git="https://github.com/paritytech/substrate", branch="polkadot-v0.9.8" }
pallet-balances = { git="https://github.com/paritytech/substrate", branch="polkadot-v0.9.8" }
pallet-timestamp = { git="https://github.com/paritytech/substrate", branch="polkadot-v0.9.8" }
pallet-scheduler = { git="https://github.com/paritytech/substrate", branch="polkadot-v0.9.8" }
max-encoded-len = { git="https://github.com/paritytech/substrate", branch="polkadot-v0.9.8", features=["derive"] }
serde = "1.0.100"
derive_more = "0.99"
cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }

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

/// 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
interface CrowdloanRewards {
// First some simple accessors
function is_contributor(address contributor) external view returns (bool);
function reward_info(address contributor) external view returns (uint256, uint256);
// Now the dispatchables


/// Request to leave the set of candidates. If successful, the account is immediately
/// removed from the candidate pool to prevent selection as a collator, but unbonding is
/// executed with a delay of `BondDuration` rounds.
function claim() external;

}

// These are the selectors generated by remix following this advice
// https://ethereum.stackexchange.com/a/73405/9963
// Eventually we will probably want a better way of generating these and copying them to Rust
4meta5 marked this conversation as resolved.
Show resolved Hide resolved

{
"53440c90": "is_contributor(address)"
"76f70249": "reward_info(address)"
"4e71d92d": "claim()"
}
Loading