Skip to content

Commit

Permalink
[ᚬframework] Rebase master (nervosnetwork#73)
Browse files Browse the repository at this point in the history
* feat: metrics logger (nervosnetwork#43)

* add logger config

* add logger.metrics example

* Revert "add logger.metrics example"

This reverts commit 7c04ff3.

* add logger module instruction

* chore: add newline to the end of text file

* refactor: change serde to json crate to manipulate json

* chore: remove patch version in Cargo.toml depencencies

* chore: tips for running `make ci` before create PR (nervosnetwork#54)

* feat: support consensus tracing (nervosnetwork#53)

* feat: support consensus trace

* feat: avoid unsafe unwrap

* feat: check is_err when init_tracer to ensure  tracer init correctly

* feat: panic when init tracer failed

* chore: cargo fmt

* feat: return ProtocolResult for standard when init tracer

* feat: update tracer sdk

* refactor: remove unnecessary code

* chore: upgrade bytes to 0.5 (nervosnetwork#57)

Also upgrade prost to pinned git commit, ophelia to 0.2.
All of these are required to upgrade bytes.

* reafctor(consensus): redesign the consensus architecture (nervosnetwork#45)

* refactor rpc

* refactor: muta consensus

* fix CI

* chore(ci): reduce travis cache size (nervosnetwork#62)

* chore(ci): use sccache and limit its cache size to 2G (nervosnetwork#63)

* chore(ci): use sccache and limit its cache size to 2G

Try fix cahce timeout

* fix(ci): disable sccache to install it

* chore(ci): enable sccache

* chore(ci): remove cargo sweep from script.sh

* chore(ci): disable sccache on master (nervosnetwork#66)

* fix(consensus): empty block receipts root (nervosnetwork#61)

* fix: empty block receipts root

* upgrade rust toolchain version

* chore(ci): enable sccache (nervosnetwork#67)

* fix(ci): fail to install sccache after new rust-toolchain (nervosnetwork#68)

* feat(consensus): develop aggregate crypto with overlord (nervosnetwork#60)

* update ophelia

* feat: aggregated signature

* refactor(protocol): Adjust the data structure of transactions and receipts.

* feat(protocol/types): Add cycles_price for raw_transaction. (nervosnetwork#46)

* feat(protocol/traits): Add traits of binding. (nervosnetwork#47)

* feat(core/binding): Implementation of service state. (nervosnetwork#48)

* feat(core/binding-macro): Add `read` and `write` proc-macro. (nervosnetwork#49)

* feat(core/binding-macro): Add cycles proc-marco. (nervosnetwork#52)

* [ᚬframework] feat(core/binding): add default StoreBool, StoreUint64, StoreString (nervosnetwork#51)

* feat(core/binding): add DefaultStoreBool, DefaultStoreUint64, DefaultStoreString

* feat(core/binding): adjust tests path

* feat(core/binding): adjust code

* feat(core/binding): fix fmt

* feat(core/binding): change BigEndian to LittleEndian

* [ᚬframework] feat(core/binding): add StoreMap, StoreArray  (nervosnetwork#55)

* feat(core/binding): add StoreMap

* feat(core/binding): add StoreArray

* feat(core/binding): fix some issues

* feat(core/binding): add TODO comment

* [ᚬframework] feat(core/binding): add service_sdk, chain_querier, request_context (nervosnetwork#58)

* feat(core/binding): finish alloc type and chain querier of sdk

* feat(core/binding): add sdk test

* feat(core/binding): add service sdk and request context

* fix style

* [ᚬframework] feat(core/binding-macro): Add #[service] to automatically implement the service trait. (nervosnetwork#56)

* feat(core/binding-macro): Add #[service] to automatically implement the service trait.

* Documents do not run tests.

* split for impl

* fix read/write result

* update cargo.lock

* [ᚬframework] feat(core/binding-macro): Add #[init] attribute. (nervosnetwork#64)

* feat(core/binding-macro): Add #[init] attribute.

* fix typo

* fix binding trait

* chore: Add framework dir. (nervosnetwork#65)

* feat(core/binding-macro): Support for returning a struct. (nervosnetwork#70)

* feat(build-in-services): Add asset service.

* feat(framework): Service executor.

* exec hook

* fix stash

* fix typo

* fix typo

* fix overflow

* fix typo

* rebase master

* .

* [ᚬframework] feat(framework/binding): add Iterator and impl FixedCodec for rust primitive type (nervosnetwork#72)

Co-authored-by: Wenchao Hu <[email protected]>
Co-authored-by: yonghui <[email protected]>
Co-authored-by: zeroqn <[email protected]>
Co-authored-by: Eason Gao <[email protected]>
Co-authored-by: zhounan <[email protected]>
  • Loading branch information
6 people committed Dec 29, 2019
1 parent 29bdbc1 commit 868a631
Show file tree
Hide file tree
Showing 60 changed files with 423 additions and 1,296 deletions.
433 changes: 62 additions & 371 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ common-logger = { path = "./common/logger" }
common-config-parser = { path = "./common/config-parser" }
common-crypto = { path = "./common/crypto" }
protocol = { path = "./protocol" }
core-api = { path = "./core/api" }
# core-api = { path = "./core/api" }
core-storage = { path = "./core/storage" }
core-mempool = { path = "./core/mempool" }
core-network = { path = "./core/network" }
Expand All @@ -24,12 +24,12 @@ runtime = "0.3.0-alpha.7"
runtime-tokio = "0.3.0-alpha.6"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
log = "0.4"
clap = "2.33"
bytes = "0.4"
bytes = "0.5"
hex = "0.4"
rlp = "0.4"
toml = "0.5"

[workspace]
members = [
Expand All @@ -43,7 +43,7 @@ members = [
"common/metrics",
"common/pubsub",

"core/api",
# "core/api",
"core/consensus",
"core/mempool",
"core/network",
Expand Down
2 changes: 1 addition & 1 deletion binding-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ serde_json = "1.0"

[dev-dependencies]
framework = { path = "../framework" }
bytes = "0.4"
bytes = "0.5"
serde = { version = "1.0", features = ["derive"] }
12 changes: 5 additions & 7 deletions binding-macro/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,22 @@ impl RequestContext for MockRequestContext {
&self.method
}

fn get_timestamp(&self) -> u64 {
0
}

fn get_payload(&self) -> &str {
&self.payload
}

fn emit_event(&mut self, _message: String) -> ProtocolResult<()> {
fn emit_event(&self, _message: String) -> ProtocolResult<()> {
unimplemented!()
}
}

struct MockServiceSDK;

impl ServiceSDK for MockServiceSDK {
type ContextItem = MockRequestContext;

// Alloc or recover a `Map` by` var_name`
fn alloc_or_recover_map<Key: 'static + FixedCodec + PartialEq, Val: 'static + FixedCodec>(
&mut self,
Expand Down Expand Up @@ -339,10 +341,6 @@ impl ServiceSDK for MockServiceSDK {
unimplemented!()
}

fn get_request_context(&self) -> ProtocolResult<Self::ContextItem> {
unimplemented!()
}

// Call other read-only methods of `service` and return the results
// synchronously NOTE: You can use recursive calls, but the maximum call
// stack is 1024
Expand Down
2 changes: 1 addition & 1 deletion built-in-services/asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protocol = { path = "../../protocol" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rlp = "0.4"
bytes = "0.4"
bytes = "0.5"
derive_more = "0.15"
byteorder = "1.3"

Expand Down
12 changes: 5 additions & 7 deletions built-in-services/asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod types;
use bytes::Bytes;
use derive_more::{Display, From};

use binding_macro::{cycles, init, read, service, write};
use binding_macro::{cycles, init, service, write};
use protocol::traits::{RequestContext, ReturnEmpty, ServiceSDK, StoreMap, RETURN_EMPTY};
use protocol::types::Hash;
use protocol::{ProtocolError, ProtocolErrorKind, ProtocolResult};
Expand Down Expand Up @@ -65,8 +65,7 @@ impl<SDK: ServiceSDK> AssetService<SDK> {
payload: CreateAssetPayload,
) -> ProtocolResult<Asset> {
let caller = ctx.get_caller();
let payload_str =
serde_json::to_string(&payload).map_err(|e| ServiceError::JsonParse(e))?;
let payload_str = serde_json::to_string(&payload).map_err(ServiceError::JsonParse)?;

let id = Hash::digest(Bytes::from(payload_str + &caller.as_hex()));

Expand All @@ -82,8 +81,7 @@ impl<SDK: ServiceSDK> AssetService<SDK> {
};
self.assets.insert(id.clone(), asset.clone())?;

self.sdk
.set_account_value(&caller, id.clone(), payload.supply)?;
self.sdk.set_account_value(&caller, id, payload.supply)?;

Ok(asset)
}
Expand All @@ -98,7 +96,7 @@ impl<SDK: ServiceSDK> AssetService<SDK> {
let caller = ctx.get_caller();
let asset_id = payload.asset_id.clone();
let value = payload.value;
let to = payload.to.clone();
let to = payload.to;

if !self.assets.contains(&asset_id)? {
return Err(ServiceError::NotFoundAsset { id: asset_id }.into());
Expand All @@ -125,7 +123,7 @@ impl<SDK: ServiceSDK> AssetService<SDK> {
if overflow {
return Err(ServiceError::U64Overflow.into());
}
self.sdk.set_account_value(&caller, asset_id.clone(), v)?;
self.sdk.set_account_value(&caller, asset_id, v)?;

Ok(RETURN_EMPTY)
}
Expand Down
8 changes: 3 additions & 5 deletions built-in-services/asset/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn test_create_asset() {
assert_eq!(asset, new_asset);

let balance_res = service
.get_balance(context.clone(), GetBalancePayload {
.get_balance(context, GetBalancePayload {
asset_id: asset.id.clone(),
})
.unwrap();
Expand All @@ -53,7 +53,7 @@ fn test_create_asset() {
fn test_transfer() {
let cycles_limit = 1024 * 1024 * 1024; // 1073741824
let caller = Address::from_hex("0x755cdba6ae4f479f7164792b318b2a06c759833b").unwrap();
let context = mock_context(cycles_limit, caller.clone());
let context = mock_context(cycles_limit, caller);

let mut service = new_asset_service();

Expand Down Expand Up @@ -85,9 +85,7 @@ fn test_transfer() {

let context = mock_context(cycles_limit, to_address);
let balance_res = service
.get_balance(context, GetBalancePayload {
asset_id: asset.id.clone(),
})
.get_balance(context, GetBalancePayload { asset_id: asset.id })
.unwrap();
assert_eq!(balance_res.balance, 1024);
}
Expand Down
Loading

0 comments on commit 868a631

Please sign in to comment.