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

Introduce first groundwork for Wasm executor #27

Merged
merged 51 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4f5c5b6
Introduce first groundwork for Wasm executor.
gavofyork Dec 5, 2017
6237848
Remove old Rust-runtime code.
gavofyork Dec 6, 2017
293cf5d
Avoid commiting compled files.
gavofyork Dec 6, 2017
66b636e
Add runtime precompile.
gavofyork Dec 6, 2017
c7e7456
Rename so module makes more sense.
gavofyork Dec 6, 2017
0cfd67e
Further renaming.
gavofyork Dec 6, 2017
3011edf
Ensure tests work.
gavofyork Dec 6, 2017
a74b4fa
Allow bringing in of externalities.
gavofyork Dec 7, 2017
6dac275
Nice macros for imports.
gavofyork Dec 9, 2017
08f7b26
Allow passing in of data through allocators.
gavofyork Dec 11, 2017
1ace6b2
Can now pass in bytes to WasmExecutor.
gavofyork Dec 11, 2017
27e5fed
Additional cleanup.
gavofyork Dec 11, 2017
13dcd89
Switch usages of `OutData` to `u64`
gavofyork Dec 11, 2017
84b9f84
convert to safe but extremely verbose type conversion.
gavofyork Dec 11, 2017
7f31899
Remove StaticExternalities distinction.
gavofyork Dec 11, 2017
edf061e
Remove another unused use.
gavofyork Dec 11, 2017
edb6bea
Refactor wasm utils out
gavofyork Dec 11, 2017
9f59f48
Remove extraneous copies that weren't really testing anything.
gavofyork Dec 11, 2017
287b29d
Try to use wasm 0.15
gavofyork Dec 31, 2017
1bd55fe
Make it work!
gavofyork Dec 31, 2017
36e254a
Call-time externalities working.
gavofyork Jan 1, 2018
cd651a3
Add basic externalities.
gavofyork Jan 1, 2018
a8f9cca
Merge branch 'with-wasm-0.15' into with-wasm
gavofyork Jan 1, 2018
4404846
Fix grumbles and note unwraps to be sorted.
gavofyork Jan 1, 2018
b1d963a
Test storage externality.
gavofyork Jan 3, 2018
319d9c0
Fix nits.
gavofyork Jan 3, 2018
7ec9221
Merge branch 'master' into with-wasm
gavofyork Jan 3, 2018
2934d94
Compile collation logic.
gavofyork Jan 3, 2018
5998aa1
Move back to refs. Yey.
gavofyork Jan 3, 2018
3f4085a
Remove "object" id for storage access.
gavofyork Jan 4, 2018
4be0537
Fix test.
gavofyork Jan 4, 2018
01d7019
Fix up rest of tests.
gavofyork Jan 4, 2018
db1adee
remove unwrap.
gavofyork Jan 4, 2018
87c54f7
Expose set/get code in externalities
gavofyork Jan 5, 2018
471ea1e
Add validator set.
gavofyork Jan 5, 2018
fa35993
Introduce validator set into externalities and test.
gavofyork Jan 5, 2018
a0f64df
Add another external function.
gavofyork Jan 6, 2018
e736d46
Remove code and validators; use storage for everything.
gavofyork Jan 6, 2018
234297c
Introduce validators function.
gavofyork Jan 6, 2018
3f8a96d
Tests (and a fix) for the validators getter.
gavofyork Jan 6, 2018
6636520
Allow calls into runtime to return data.
gavofyork Jan 7, 2018
964659e
Remove unneeded trace.
gavofyork Jan 7, 2018
8ca1b7b
Make runtime printing a bit nicer.
gavofyork Jan 7, 2018
74156a2
Create separate runtimes for testing and polkadot.
gavofyork Jan 8, 2018
611a7ac
Remove commented code.
gavofyork Jan 8, 2018
c3afecc
Use new path.
gavofyork Jan 8, 2018
ea4d6c5
Refactor into shared support module.
gavofyork Jan 8, 2018
709693d
Fix warning.
gavofyork Jan 8, 2018
ec1e6b6
Remove unwraps.
gavofyork Jan 8, 2018
5c0ec3d
Make macro a little less unhygenic.
gavofyork Jan 8, 2018
79ab46f
Add wasm files.
gavofyork Jan 8, 2018
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target/
**/*.rs.bk
*.swp
runtime/**/target/
**/._*
20 changes: 17 additions & 3 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ members = [
"candidate-agreement",
"client",
"collator",
"contracts",
"executor",
"primitives",
"rpc",
"rpc_servers",
"serializer",
"state_machine",
"validator",
]
exclude = [
"runtime"
]
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ env_logger = "0.4"
error-chain = "0.11"
log = "0.3"
polkadot-client = { path = "../client", version = "0.1" }
polkadot-contracts = { path = "../contracts", version = "0.1" }
polkadot-executor = { path = "../executor", version = "0.1" }
polkadot-primitives = { path = "../primitives", version = "0.1" }
polkadot-rpc-servers = { path = "../rpc_servers", version = "0.1" }
4 changes: 2 additions & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

extern crate env_logger;
extern crate polkadot_client as client;
extern crate polkadot_contracts as contracts;
extern crate polkadot_executor as executor;
extern crate polkadot_primitives as primitives;
extern crate polkadot_rpc_servers as rpc;

Expand Down Expand Up @@ -54,7 +54,7 @@ pub fn run<I, T>(args: I) -> error::Result<()> where

// Create client
let blockchain = DummyBlockchain;
let executor = contracts::executor();
let executor = executor::executor();
let client = client::Client::new(blockchain, executor);

let address = "127.0.0.1:9933".parse().unwrap();
Expand Down
26 changes: 18 additions & 8 deletions client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ extern crate error_chain;

pub mod error;

use primitives::{block, Address, H256};
use primitives::contract::{CallData, OutData, StorageData};
use primitives::{block};
use primitives::contract::{CallData, StorageKey, StorageData};
use state_machine::backend::Backend;

use self::error::ResultExt;
Expand All @@ -44,6 +44,14 @@ pub trait Blockchain {
fn header(&self, hash: &block::HeaderHash) -> Result<Option<block::Header>, Self::Error>;
}

/// Information regarding the result of a call.
pub struct CallResult {
/// The data that was returned from the call.
pub return_data: Vec<u8>,
/// The changes made to the state by the call.
pub changes: state_machine::OverlayedChanges,
}

/// Polkadot Client
#[derive(Debug)]
pub struct Client<B, E> {
Expand Down Expand Up @@ -72,25 +80,27 @@ impl<B, E> Client<B, E> where
}

/// Return single storage entry of contract under given address in state in a block of given hash.
pub fn storage(&self, hash: &block::HeaderHash, address: &Address, key: &H256) -> error::Result<StorageData> {
pub fn storage(&self, hash: &block::HeaderHash, key: &StorageKey) -> error::Result<StorageData> {
self.state_at(hash)?
.storage(address, key)
.storage(&key.0)
.map(|x| StorageData(x.to_vec()))
.chain_err(|| error::ErrorKind::Backend)
}

/// Execute a call to a contract on top of state in a block of given hash.
pub fn call(&self, hash: &block::HeaderHash, address: &Address, method: &str, call_data: &CallData) -> error::Result<OutData> {
///
/// No changes are made.
pub fn call(&self, hash: &block::HeaderHash, method: &str, call_data: &CallData) -> error::Result<CallResult> {
let state = self.state_at(hash)?;
let mut changes = state_machine::OverlayedChanges::default();

Ok(state_machine::execute(
let _ = state_machine::execute(
&state,
&mut changes,
&self.executor,
address,
method,
call_data,
)?)
)?;
Ok(CallResult { return_data: vec![], changes })
}
}
38 changes: 0 additions & 38 deletions contracts/src/auth.rs

This file was deleted.

64 changes: 0 additions & 64 deletions contracts/src/balances.rs

This file was deleted.

Loading