Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b042a93
Make extrinsics extensible.
gavofyork Jul 11, 2019
37f6ae0
Rest of mockup. Add tips.
gavofyork Jul 11, 2019
2e5b1f4
Fix some build issues
gavofyork Jul 11, 2019
b7646ec
Runtiem builds :)
gavofyork Jul 11, 2019
a871c9f
Substrate builds.
kianenigma Jul 12, 2019
8e7c803
Fix a doc test
gavofyork Jul 13, 2019
a824b56
Compact encoding
gavofyork Jul 13, 2019
5de080f
Extract out the era logic into an extension
gavofyork Jul 15, 2019
a8789b9
Weight Check signed extension. (#3115)
kianenigma Jul 16, 2019
7d96429
Merge remote-tracking branch 'origin/master' into gav-extensble-trans…
gavofyork Jul 16, 2019
30b4ba7
Don't use len for weight - use data.
gavofyork Jul 16, 2019
2a9c9df
Merge remote-tracking branch 'origin/master' into gav-extensble-trans…
gavofyork Jul 19, 2019
342efb5
Operational Transaction; second attempt (#3138)
kianenigma Jul 19, 2019
b8f564e
Bump transaction version
jacogr Jul 19, 2019
07fdfe2
Merge branch 'gav-extensble-transactions' of github.com:paritytech/su…
jacogr Jul 19, 2019
7f33006
Master.into()
kianenigma Jul 19, 2019
36063fe
Merge branch 'gav-extensble-transactions' of github.com:paritytech/su…
kianenigma Jul 19, 2019
7a0fbc9
Fix weight mult test.
kianenigma Jul 19, 2019
84fa279
Fix more tests and improve doc.
kianenigma Jul 19, 2019
f4d4579
Bump.
kianenigma Jul 19, 2019
def6425
Merge remote-tracking branch 'origin/master' into gav-extensble-trans…
gavofyork Jul 20, 2019
d12713a
Make some tests work again.
kianenigma Jul 20, 2019
3350f9c
Fix subkey.
kianenigma Jul 20, 2019
b788507
Remove todos + bump.
kianenigma Jul 20, 2019
c8b0053
Merge branch 'master' of github.com:paritytech/substrate into gav-ext…
kianenigma Jul 22, 2019
383185d
Ignore expensive test.
kianenigma Jul 22, 2019
ec829fd
Bump.
kianenigma Jul 22, 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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into gav-extensble-trans…
…actions
  • Loading branch information
gavofyork committed Jul 20, 2019
commit def64251cd3b88d74806bcfb64b9fee240f37a80
20 changes: 20 additions & 0 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 @@ -85,6 +85,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_network_state(written_out: *mut u32) -> *mut u8 => {
let res = this.ext.offchain()
.map(|api| api.network_state())
.ok_or_else(|| "Calling unavailable API ext_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_network_state")?;

this.memory.write_primitive(written_out, len)
.map_err(|_| "Invalid attempt to write written_out in ext_network_state")?;

Ok(offset)
},
ext_authority_pubkey(
kind: u32,
written_out: *mut u32
) -> *mut u8 => {
let kind = offchain::CryptoKind::try_from(kind)
.map_err(|_| "crypto kind OOB while ext_authority_pubkey: wasm")?;

let res = this.ext.offchain()
.map(|api| api.authority_pubkey(kind))
.ok_or_else(|| "Calling unavailable API ext_authority_pubkey: 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_authority_pubkey")?;
this.memory.write_primitive(written_out, len)
.map_err(|_| "Invalid attempt to write written_out in ext_authority_pubkey")?;
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
46 changes: 45 additions & 1 deletion core/network/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use futures::{prelude::*, sync::mpsc};
use log::{warn, error, info};
use libp2p::core::{swarm::NetworkBehaviour, transport::boxed::Boxed, muxing::StreamMuxerBox};
use libp2p::{PeerId, Multiaddr, multihash::Multihash};
use parking_lot::Mutex;
use peerset::PeersetHandle;
use runtime_primitives::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId};

Expand Down Expand Up @@ -86,6 +87,8 @@ impl ReportHandle {
pub struct NetworkService<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> {
/// Number of peers we're connected to.
num_connected: Arc<AtomicUsize>,
/// The local external addresses.
external_addresses: Arc<Mutex<Vec<Multiaddr>>>,
/// Are we actively catching up with the chain?
is_major_syncing: Arc<AtomicBool>,
/// Local copy of the `PeerId` of the local node.
Expand Down Expand Up @@ -215,8 +218,11 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkWorker
Swarm::<B, S, H>::add_external_address(&mut swarm, addr.clone());
}

let external_addresses = Arc::new(Mutex::new(Vec::new()));

let service = Arc::new(NetworkService {
bandwidth,
external_addresses: external_addresses.clone(),
num_connected: num_connected.clone(),
is_major_syncing: is_major_syncing.clone(),
peerset: peerset_handle,
Expand All @@ -226,6 +232,7 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkWorker
});

Ok(NetworkWorker {
external_addresses,
num_connected,
is_major_syncing,
network_service: swarm,
Expand Down Expand Up @@ -295,7 +302,7 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkWorker
/// Get network state.
///
/// **Note**: Use this only for debugging. This API is unstable. There are warnings literaly
/// everywhere about this. Please don't use this function to retreive actual information.
/// everywhere about this. Please don't use this function to retrieve actual information.
pub fn network_state(&mut self) -> NetworkState {
let swarm = &mut self.network_service;
let open = swarm.user_protocol().open_peers().cloned().collect::<Vec<_>>();
Expand Down Expand Up @@ -487,6 +494,11 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> NetworkServic
pub fn num_connected(&self) -> usize {
self.num_connected.load(Ordering::Relaxed)
}

/// Returns the local external addresses.
pub fn external_addresses(&self) -> Vec<Multiaddr> {
self.external_addresses.lock().clone()
}
}

impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT>
Expand All @@ -500,6 +512,32 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT>
}
}

/// Trait for providing information about the local network state
pub trait NetworkStateInfo {
/// Returns the local external addresses.
fn external_addresses(&self) -> Vec<Multiaddr>;

/// Returns the local Peer ID.
fn peer_id(&self) -> PeerId;
}

impl<B, S, H> NetworkStateInfo for NetworkService<B, S, H>
where
B: runtime_primitives::traits::Block,
S: NetworkSpecialization<B>,
H: ExHashT,
{
/// Returns the local external addresses.
fn external_addresses(&self) -> Vec<Multiaddr> {
self.external_addresses.lock().clone()
}

/// Returns the local Peer ID.
fn peer_id(&self) -> PeerId {
self.local_peer_id.clone()
}
}

/// Messages sent from the `NetworkService` to the `NetworkWorker`.
///
/// Each entry corresponds to a method of `NetworkService`.
Expand All @@ -520,6 +558,8 @@ enum ServerToWorkerMsg<B: BlockT, S: NetworkSpecialization<B>> {
/// You are encouraged to poll this in a separate background thread or task.
#[must_use = "The NetworkWorker must be polled in order for the network to work"]
pub struct NetworkWorker<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> {
/// Updated by the `NetworkWorker` and loaded by the `NetworkService`.
external_addresses: Arc<Mutex<Vec<Multiaddr>>>,
/// Updated by the `NetworkWorker` and loaded by the `NetworkService`.
num_connected: Arc<AtomicUsize>,
/// Updated by the `NetworkWorker` and loaded by the `NetworkService`.
Expand Down Expand Up @@ -621,6 +661,10 @@ impl<B: BlockT + 'static, S: NetworkSpecialization<B>, H: ExHashT> Future for Ne

// Update the variables shared with the `NetworkService`.
self.num_connected.store(self.network_service.user_protocol_mut().num_connected_peers(), Ordering::Relaxed);
{
let external_addresses = Swarm::<B, S, H>::external_addresses(&self.network_service).cloned().collect();
*self.external_addresses.lock() = external_addresses;
}
self.is_major_syncing.store(match self.network_service.user_protocol_mut().sync_state() {
SyncState::Idle => false,
SyncState::Downloading => true,
Expand Down
1 change: 1 addition & 0 deletions core/offchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ parking_lot = "0.8.0"
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
runtime_primitives = { package = "sr-primitives", path = "../../core/sr-primitives" }
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
network = { package = "substrate-network", path = "../../core/network" }

[dev-dependencies]
env_logger = "0.6"
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.