Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
50562c0
stash precompile changes in other branch and push pallet changes leak…
4meta5 Oct 20, 2022
9395e66
still leaking std
4meta5 Oct 20, 2022
8ed14e7
using sp std phantomdata did not fix
4meta5 Oct 21, 2022
315116a
ty @nanocryk for std leak fix
4meta5 Oct 21, 2022
8f24362
init referenda precompile needs tryfrom u8 for origins
4meta5 Oct 23, 2022
d83be8e
referenda submit precompile fn
4meta5 Oct 23, 2022
21ffc60
signed extrinsics for referenda precompile
4meta5 Oct 23, 2022
0eb6dc3
preimage precompile
4meta5 Oct 24, 2022
09e90db
init conviction voting precompile
4meta5 Oct 24, 2022
138a848
referenda delegate undelegate unlock
4meta5 Oct 25, 2022
8e1a709
fixes
4meta5 Oct 26, 2022
276d8a4
fix
4meta5 Oct 26, 2022
a940199
clean
4meta5 Oct 26, 2022
a9ab0e3
improve revert reasons for class and index inputs
4meta5 Oct 26, 2022
9067ba0
clean
4meta5 Oct 26, 2022
467e845
init accessors and clean
4meta5 Nov 3, 2022
c6c8d1b
Merge branch 'master' into amar-gov2-precompiles
4meta5 Nov 7, 2022
4d8f70a
referenda precompile
4meta5 Nov 16, 2022
a234655
clean
4meta5 Nov 16, 2022
def4e70
Merge branch 'master' into amar-gov2-precompiles
4meta5 Nov 21, 2022
e86512c
clean and init referenda precompile interface
4meta5 Nov 21, 2022
66e5164
into master
4meta5 Jan 2, 2023
c389722
fix merge
4meta5 Jan 4, 2023
5bb1673
try mock referenda precompile but did not succeed
4meta5 Jan 4, 2023
e7c765b
save
4meta5 Jan 6, 2023
c5e2220
fix referenda mock
nanocryk Jan 9, 2023
d05803f
add dot sol files for preimage and voting
4meta5 Jan 9, 2023
b784aca
add to moonbase precompiles
4meta5 Jan 9, 2023
f1c55b5
fix
4meta5 Jan 10, 2023
58620ed
precompile existence test fix
4meta5 Jan 10, 2023
6ed417f
update solidity addresses as per moonbase config
4meta5 Jan 10, 2023
2fcef74
rename standard vote to vote in conviction voting pallet
4meta5 Jan 11, 2023
8723589
start moving origins out of pallet and using additional generic instead
4meta5 Jan 11, 2023
a1f469e
fix finish moving pallet custom origins back into runtime
4meta5 Jan 11, 2023
3e4e868
into master
4meta5 Jan 11, 2023
72f78a1
Merge branch 'master' into amar-gov2-precompiles
librelois Jan 12, 2023
e1f84ca
add opengov precompiles in proxy evm filter
librelois Jan 12, 2023
6064e97
SolidityConvert no longer necessary
4meta5 Jan 12, 2023
19c2914
rm SolidityConvert and add Conviction enum
4meta5 Jan 12, 2023
046a7ac
use trackId as input for submit instead of origin and convert from tr…
4meta5 Jan 12, 2023
7839709
camelCase error msgs
4meta5 Jan 12, 2023
3357394
Update precompiles/referenda/src/lib.rs
4meta5 Jan 12, 2023
5efa9d5
fix conviction precompile interface
4meta5 Jan 12, 2023
145f6f9
fix referenda precompile interface
4meta5 Jan 12, 2023
694378d
test to ensure all tracks have min enactment period less than vote lo…
4meta5 Jan 12, 2023
9bfd9ff
update tracks based on wiki
4meta5 Jan 12, 2023
a11ee95
revert accidental commit
4meta5 Jan 12, 2023
a1941ec
fix referenda precompile unit tests
4meta5 Jan 12, 2023
6e99180
update config based on polkadot 6372 gov2 config tweaks
4meta5 Jan 12, 2023
83e5a1c
fix
4meta5 Jan 12, 2023
362fef7
Configure moonriver OpenGov (#2038)
4meta5 Jan 17, 2023
af079a9
into master
4meta5 Jan 17, 2023
db81510
remove TryFrom u8 impl for Origin unused
4meta5 Jan 17, 2023
d3a8bda
split convictionVoting vote into voteYes and voteNo so can add voteAb…
4meta5 Jan 17, 2023
4c3e81b
fix consistent conversion test
4meta5 Jan 17, 2023
fd381a7
Merge branch 'master' into amar-gov2-precompiles
4meta5 Jan 17, 2023
be79f7c
follow suggestions
4meta5 Jan 17, 2023
dea9998
add doc note to removeOtherVote
4meta5 Jan 17, 2023
052a56e
into master
4meta5 Jan 17, 2023
d4782eb
fix
4meta5 Jan 17, 2023
3cccdb4
Merge branch 'master' into amar-gov2-precompiles
crystalin Jan 18, 2023
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
166 changes: 137 additions & 29 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ members = [
"precompiles/batch",
"precompiles/call-permit",
"precompiles/collective",
"precompiles/conviction-voting",
"precompiles/crowdloan-rewards",
"precompiles/pallet-democracy",
"precompiles/parachain-staking",
"precompiles/preimage",
"precompiles/proxy",
"precompiles/randomness",
"precompiles/referenda",
"precompiles/relay-encoder",
"precompiles/utils",
"precompiles/utils/macro",
Expand Down
57 changes: 57 additions & 0 deletions precompiles/conviction-voting/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[package]
name = "pallet-evm-precompile-conviction-voting"
authors = [ "PureStake" ]
description = "A Precompile to make pallet-conviction-voting calls encoding accessible to pallet-evm"
edition = "2021"
version = "0.1.0"

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

# Moonbeam
precompile-utils = { path = "../utils", default-features = false }

# Substrate
frame-support = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }
frame-system = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }
pallet-conviction-voting = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }
parity-scale-codec = { version = "3.0.0", default-features = false, features = [ "derive" ] }
sp-core = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }
sp-runtime = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }
sp-std = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }

# Frontier
fp-evm = { git = "https://github.com/purestake/frontier", branch = "moonbeam-polkadot-v0.9.32", default-features = false }
pallet-evm = { git = "https://github.com/purestake/frontier", branch = "moonbeam-polkadot-v0.9.32", default-features = false, features = [ "forbid-evm-reentrancy" ] }

[dev-dependencies]
derive_more = "0.99"
hex-literal = "0.3.3"
serde = "1.0.100"
sha3 = "0.9"

# Moonbeam
precompile-utils = { path = "../utils", features = [ "testing" ] }

# Substrate
pallet-balances = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32" }
pallet-timestamp = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32" }
scale-info = { version = "2.0", default-features = false, features = [ "derive" ] }
sp-io = { git = "https://github.com/purestake/substrate", branch = "moonbeam-polkadot-v0.9.32", default-features = false }

[features]
default = [ "std" ]
std = [
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-conviction-voting/std",
"pallet-evm/std",
"parity-scale-codec/std",
"parity-scale-codec/std",
"precompile-utils/std",
"sp-runtime/std",
"sp-std/std",
]
97 changes: 97 additions & 0 deletions precompiles/conviction-voting/ConvictionVoting.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.8.3;

/// @dev The Conviction Voting contract's address.
address constant Conviction_Voting_ADDRESS = 0x0000000000000000000000000000000000000812;

/// @dev The Conviction Voting contract's instance.
ConvictionVoting constant Conviction_Voting_CONTRACT = ConvictionVoting(
Conviction_Voting_ADDRESS
);

/// @author The Moonbeam Team
/// @title Pallet Conviction Voting Interface
/// @title The interface through which solidity contracts will interact with the Conviction Voting pallet
/// @custom:address 0x0000000000000000000000000000000000000812
interface ConvictionVoting {
/// @dev Defines the conviction multiplier type.
/// The values start at `0` and are represented as `uint8`.
/// None => 0.1x votes, unlocked.
/// Locked1x => 1x votes, locked for an enactment period following a successful vote.
/// Locked2x => 2x votes, locked for 2x enactment periods following a successful vote
/// Locked3x => 3x votes, locked for 4x...
/// Locked4x => 4x votes, locked for 8x...,
/// Locked5x => 5x votes, locked for 16x...
/// Locked6x => 6x votes, locked for 32x...
enum Conviction {
None,
Locked1x,
Locked2x,
Locked3x,
Locked4x,
Locked5x,
Locked6x
}

/// @dev Vote yes in a poll.
/// @custom:selector da9df518
/// @param pollIndex Index of poll
/// @param voteAmount Balance locked for vote
/// @param conviction Conviction multiplier for length of vote lock
function voteYes(
uint32 pollIndex,
uint256 voteAmount,
Conviction conviction
) external;

/// @dev Vote no in a poll.
/// @custom:selector cc600eba
/// @param pollIndex Index of poll
/// @param voteAmount Balance locked for vote
/// @param conviction Conviction multiplier for length of vote lock
function voteNo(
uint32 pollIndex,
uint256 voteAmount,
Conviction conviction
) external;

/// @dev Remove vote in poll
/// @custom:selector 79cae220
/// @param pollIndex Index of the poll
function removeVote(uint32 pollIndex) external;

/// @dev Remove vote in poll for other voter
/// @custom:selector cbcb9276
//// @param target The voter to have vote removed. The removed vote must already be expired.
/// @param trackId The trackId
/// @param pollIndex the poll index
function removeOtherVote(
address target,
uint16 trackId,
uint32 pollIndex
) external;

/// @dev Delegate to a representative for the vote trackId
/// @custom:selector 681750e8
/// @param trackId The trackId
/// @param representative The representative for the trackId
/// @param conviction The conviction multiplier
/// @param amount delegated to representative for this vote trackId
function delegate(
uint16 trackId,
address representative,
Conviction conviction,
uint256 amount
) external;

/// @dev Undelegate for the trackId
/// @custom:selector 98be4094
/// @param trackId The trackId
function undelegate(uint16 trackId) external;

/// @dev Unlock tokens locked for trackId
/// @custom:selector 4259d98c
/// @param trackId The trackId
/// @param target The target address
function unlock(uint16 trackId, address target) external;
}
Loading