Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Introduce srml/im-online #3079

Merged
merged 45 commits into from
Jul 20, 2019
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1e77e12
Fix grammar and typo
cmichi Jul 9, 2019
cfbec8c
Extend network service
cmichi Jul 9, 2019
5252851
Extend offchain API
cmichi Jul 9, 2019
1d5151b
Support creating unsigned UncheckedExtrinsic
cmichi Jul 9, 2019
2c89345
Introduce srml/im-online
cmichi Jul 9, 2019
e9a9028
Bump impl and spec version
cmichi Jul 10, 2019
dc531dc
Fix web-wasm test
cmichi Jul 10, 2019
da1679b
Merge branch 'master' into cmichi-srml-im-online
cmichi Jul 10, 2019
eeb4df5
Apply suggestions from code review
cmichi Jul 10, 2019
4895cad
Replace transmute with from_raw_parts
cmichi Jul 10, 2019
b8fe709
Replace PeerId.to_string() with .to_base58()
cmichi Jul 10, 2019
2256919
Merge branch 'cmichi-srml-im-online' of github.com:paritytech/substra…
cmichi Jul 10, 2019
0d1289b
Update Cargo.lock
cmichi Jul 10, 2019
44cd516
Bump impl and spec version (again)
cmichi Jul 10, 2019
73f2bb5
Merge branch 'master' into cmichi-srml-im-online
cmichi Jul 15, 2019
56d25bd
Apply suggestions from code review
cmichi Jul 15, 2019
5dc0298
Address comments
cmichi Jul 16, 2019
5f43208
Add public function is_online_in_current_session()
cmichi Jul 16, 2019
24adc6c
Bump spec_version
cmichi Jul 16, 2019
ec5f3e8
Merge branch 'master' into cmichi-srml-im-online
cmichi Jul 16, 2019
0d38749
Fix doc tests
cmichi Jul 16, 2019
fdbb2b4
Improve comments
cmichi Jul 16, 2019
39cd034
Remove superfluous line
cmichi Jul 16, 2019
d256a3c
Name parameters consistently
cmichi Jul 16, 2019
a7d9894
Implement comments
cmichi Jul 17, 2019
41091af
Switch From to TryFrom
cmichi Jul 17, 2019
9bee5bf
Use Vec instead of HashSet
cmichi Jul 17, 2019
f67d935
Fix tests
cmichi Jul 17, 2019
c7c0414
Merge branch 'master' into cmichi-srml-im-online
cmichi Jul 17, 2019
73fbc29
Revert me: local testing
cmichi Jul 9, 2019
2e80426
Merge branch 'cmichi-srml-im-online' of github.com:paritytech/substra…
cmichi Jul 18, 2019
e650c98
Fix check if already sent during session
cmichi Jul 18, 2019
f88d9ee
Fix typos
cmichi Jul 18, 2019
0fb8a6b
Consistent terminology
cmichi Jul 18, 2019
607df96
Revert "Revert me: local testing"
cmichi Jul 18, 2019
0210000
Introduce IsMember trait
cmichi Jul 19, 2019
7554808
Implement misc comments
cmichi Jul 19, 2019
f20a19b
Remove unused function
cmichi Jul 19, 2019
e4ab8da
Fix test
cmichi Jul 19, 2019
e3cea15
Fix external_addresses being written
cmichi Jul 19, 2019
c5828e8
Merge branch 'master' into cmichi-srml-im-online
cmichi Jul 19, 2019
3f88973
Fix test
cmichi Jul 19, 2019
537842d
Add necessary trait bound
cmichi Jul 19, 2019
1e50257
Do not increment version
cmichi Jul 19, 2019
e73329f
Update lib.rs
gavofyork Jul 19, 2019
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
67 changes: 49 additions & 18 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ members = [
"srml/system",
"srml/timestamp",
"srml/treasury",
"srml/im-online",
"node/cli",
"node/executor",
"node/primitives",
Expand Down
37 changes: 37 additions & 0 deletions core/executor/src/wasm_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use wasmi::{
};
use state_machine::{Externalities, ChildStorageKey};
use crate::error::{Error, Result};
use parity_codec::Encode;
use primitives::{blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Pair};
use primitives::offchain;
use primitives::hexdisplay::HexDisplay;
Expand Down Expand Up @@ -767,6 +768,42 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,

Ok(offset)
},
ext_local_network_state(msg_len: *mut u32) -> *mut u8 => {
cmichi marked this conversation as resolved.
Show resolved Hide resolved
let res = this.ext.offchain()
.map(|api| api.local_network_state())
.ok_or_else(|| "Calling unavailable API ext_local_network_state: wasm")?;

let encoded = res.encode();
let len = encoded.len() as u32;
let offset = this.heap.allocate(len)? as u32;
this.memory.set(offset, &encoded)
.map_err(|_| "Invalid attempt to set memory in ext_local_network_state")?;

this.memory.write_primitive(msg_len, len)
cmichi marked this conversation as resolved.
Show resolved Hide resolved
.map_err(|_| "Invalid attempt to write msg_len in ext_local_network_state")?;

Ok(offset)
},
ext_local_authority_pubkey(
kind: u32,
written_out: *mut u32
) -> *mut u8 => {
let kind = offchain::CryptoKind::try_from(kind)
.map_err(|_| "crypto kind OOB while ext_decrypt: wasm")?;
cmichi marked this conversation as resolved.
Show resolved Hide resolved

let res = this.ext.offchain()
.map(|api| api.local_authority_pubkey(kind))
.ok_or_else(|| "Calling unavailable API ext_decrypt: wasm")?;
cmichi marked this conversation as resolved.
Show resolved Hide resolved

let encoded = res.encode();
let len = encoded.len() as u32;
let offset = this.heap.allocate(len)? as u32;
this.memory.set(offset, &encoded)
.map_err(|_| "Invalid attempt to set memory in ext_http_response_headers")?;
cmichi marked this conversation as resolved.
Show resolved Hide resolved
this.memory.write_primitive(written_out, len)
.map_err(|_| "Invalid attempt to write written_out in ext_http_response_headers")?;
cmichi marked this conversation as resolved.
Show resolved Hide resolved
Ok(offset)
},
ext_decrypt(
key: u32,
kind: u32,
Expand Down
1 change: 1 addition & 0 deletions core/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ pub mod test;
pub use chain::{Client as ClientHandle, FinalityProofProvider};
pub use service::{
NetworkService, NetworkWorker, TransactionPool, ExHashT, ReportHandle,
NetworkStateInfo,
};
pub use protocol::{PeerInfo, Context, consensus_gossip, message, specialization};
pub use protocol::sync::SyncState;
Expand Down
Loading