Skip to content

Commit

Permalink
Dusty release 1.2.1 (#199)
Browse files Browse the repository at this point in the history
* Lockdrop: block number instead for time for bounds

* Bump version

* [CI]: bump rust version
  • Loading branch information
akru authored Jul 14, 2020
1 parent 71b1d5f commit e09b622
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: 'nightly-2020-02-02'
rust-version: 'nightly-2020-07-01'
targets: 'wasm32-unknown-unknown'
- name: Checkout the source code
uses: actions/checkout@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dockerpush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: 'nightly-2020-02-02'
rust-version: 'nightly-2020-07-01'
targets: 'wasm32-unknown-unknown'
- name: Checkout the source code
uses: actions/checkout@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: choco install llvm
- uses: hecrj/setup-rust-action@v1
with:
rust-version: 'nightly-2020-04-04'
rust-version: 'nightly-2020-07-01'
targets: 'wasm32-unknown-unknown'
- name: Checkout the source coder
uses: actions/checkout@master
Expand Down
8 changes: 4 additions & 4 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 bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-cli"
version = "1.2.0"
version = "1.2.1"
authors = ["Stake Technologies <[email protected]>"]
description = "Plasm node implementation in Rust."
build = "build.rs"
Expand Down
4 changes: 2 additions & 2 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ fn make_genesis(
dollar_rate: (9_000, 200),
vote_threshold: 1,
positive_votes: 1,
// Max time bounds for testing purposes
time_bounds: (0, 2_594_459_790_000u64),
// Start from launch for testing purposes
lockdrop_bounds: (0, 1_000_000),
}),
pallet_session: Some(SessionConfig {
keys: keys
Expand Down
2 changes: 1 addition & 1 deletion bin/node/primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-primitives"
version = "1.2.0"
version = "1.2.1"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-rpc"
version = "1.2.0"
version = "1.2.1"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "plasm-runtime"
version = "1.2.0"
version = "1.2.1"
authors = ["Stake Technologies <[email protected]>"]
edition = "2018"
build = "build.rs"
Expand Down
4 changes: 2 additions & 2 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to equal spec_version. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 3,
impl_version: 3,
spec_version: 4,
impl_version: 4,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};
Expand Down
25 changes: 13 additions & 12 deletions frame/plasm-lockdrop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ decl_error! {
/// Authorities reject this claim request.
NotApproved,
/// Lockdrop isn't run now, request could not be processed.
OutOfTime,
OutOfBounds,
}
}

Expand Down Expand Up @@ -286,7 +286,7 @@ decl_storage! {
/// Positive votes = approve votes - decline votes.
PositiveVotes get(fn positive_votes) config(): AuthorityVote;
/// Timestamp bounds of lockdrop held period.
TimeBounds get(fn time_bounds) config(): (T::Moment, T::Moment);
LockdropBounds get(fn lockdrop_bounds) config(): (T::BlockNumber, T::BlockNumber);
}
}

Expand Down Expand Up @@ -324,7 +324,8 @@ decl_module! {
);

if !<Claims<T>>::contains_key(claim_id) {
ensure!(Self::time_guard(), Error::<T>::OutOfTime);
let now = <frame_system::Module<T>>::block_number();
ensure!(Self::is_active(now), Error::<T>::OutOfBounds);

let amount = match params {
Lockdrop::Bitcoin { value, duration, .. } => {
Expand Down Expand Up @@ -472,10 +473,10 @@ decl_module! {

/// Set lockdrop held time.
#[weight = 50_000]
fn set_time_bounds(origin, from: T::Moment, to: T::Moment) {
fn set_bounds(origin, from: T::BlockNumber, to: T::BlockNumber) {
ensure_root(origin)?;
ensure!(from < to, "wrong arguments");
<TimeBounds<T>>::put((from, to));
<LockdropBounds<T>>::put((from, to));
}

/// Set minimum of positive votes required for lock approve.
Expand All @@ -493,10 +494,11 @@ decl_module! {
}

// Runs after every block within the context and current state of said block.
fn offchain_worker(_now: T::BlockNumber) {
debug::RuntimeLogger::init();
fn offchain_worker(now: T::BlockNumber) {
// Launch if validator and lockdrop is active
if sp_io::offchain::is_validator() && Self::is_active(now) {
debug::RuntimeLogger::init();

if sp_io::offchain::is_validator() {
match Self::offchain() {
Err(_) => debug::error!(
target: "lockdrop-offchain-worker",
Expand Down Expand Up @@ -646,10 +648,9 @@ impl<T: Trait> Module<T> {
None
}

/// Check that current time suits lockdrop time bounds.
fn time_guard() -> bool {
let now = T::Time::now();
let bounds = <TimeBounds<T>>::get();
/// Check that block suits lockdrop bounds.
fn is_active(now: T::BlockNumber) -> bool {
let bounds = <LockdropBounds<T>>::get();
now >= bounds.0 && now < bounds.1
}
}
Expand Down
2 changes: 1 addition & 1 deletion frame/plasm-lockdrop/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
dollar_rate: (9_000, 200),
vote_threshold: 3,
positive_votes: 2,
time_bounds: (0, 100_000_000),
lockdrop_bounds: (0, 1_000_000),
}
.assimilate_storage(&mut storage);

Expand Down

0 comments on commit e09b622

Please sign in to comment.