Skip to content

Commit 4dabc19

Browse files
RIg410boozook
andauthored
Updated libra version (#167, DFI-578)
* Updated libra version. * Change dvm-proto rev. * fix ipc test (there's depends on OS's impl, so speed of shutting down and closing (unlinking) channel can be so much various). Co-authored-by: Alexander Koz <a@koz.email>
1 parent cd6b176 commit 4dabc19

File tree

11 files changed

+268
-433
lines changed

11 files changed

+268
-433
lines changed

Diff for: Cargo.lock

+120-149
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: cli/src/bin/dvm.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ use dvm_cli::init;
3131
use futures::join;
3232
use dvm_info::config::InfoServiceConfig;
3333
use dvm_cli::info_service::create_info_service;
34-
use dvm_net::api::grpc::vm_grpc::vm_access_vector_server::VmAccessVectorServer;
3534

3635
const MODULE_CACHE: usize = 1000;
3736

@@ -118,8 +117,7 @@ async fn main_internal(options: Options) -> Result<()> {
118117
// comp services
119118
.add_service(VmCompilerServer::new(compiler_service.clone()))
120119
.add_service(VmMultipleSourcesCompilerServer::new(compiler_service))
121-
.add_service(VmScriptMetadataServer::new(metadata_service.clone()))
122-
.add_service(VmAccessVectorServer::new(metadata_service))
120+
.add_service(VmScriptMetadataServer::new(metadata_service))
123121
// serve
124122
.serve_ext_with_shutdown(options.address, serv_term_rx.map(|_| ()))
125123
.map(|res| {

Diff for: libra/Cargo.toml

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ authors = [
99
edition = "2018"
1010

1111
[dependencies]
12-
move-lang = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
13-
move-vm-types = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
14-
move-core-types = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
15-
libra-state-view = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
16-
libra-types = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
17-
lcs = { git = "https://github.com/dfinance/libra.git", package = "libra-canonical-serialization", branch = "09.07.2020" }
18-
compiler = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
19-
libra-logger = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
20-
vm = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
21-
libra-vm = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
22-
move-vm-runtime = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
23-
move-vm-natives = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
24-
bytecode-verifier = { git = "https://github.com/dfinance/libra.git", branch = "29.07.2020" }
12+
move-lang = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
13+
move-vm-types = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
14+
move-core-types = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
15+
libra-state-view = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
16+
libra-types = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
17+
lcs = { git = "https://github.com/dfinance/libra.git", package = "libra-canonical-serialization", branch = "05.08.2020" }
18+
compiler = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
19+
libra-logger = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
20+
vm = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
21+
libra-vm = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
22+
move-vm-runtime = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
23+
move-vm-natives = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }
24+
bytecode-verifier = { git = "https://github.com/dfinance/libra.git", branch = "05.08.2020" }

Diff for: libra/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ pub mod account {
3030
}
3131

3232
pub mod result {
33-
pub use move_core_types::vm_status::{StatusCode, VMStatus, DiscardedVMStatus, KeptVMStatus};
33+
pub use move_core_types::vm_status::{
34+
StatusCode, VMStatus, DiscardedVMStatus, KeptVMStatus, AbortLocation as AbortLoc,
35+
};
3436
pub use vm::errors::{Location, VMResult, PartialVMResult, PartialVMError, VMError};
3537
}
3638

Diff for: net/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ log = "0.4.8"
1919

2020
[dependencies.dvm-api]
2121
git = "https://github.com/dfinance/dvm-proto.git"
22-
rev = "bfdcef619a2694c73585be6be5a5665ab23dae92"
22+
rev = "06b76cf8c1830d6381ea4de3267d1bfc88fd0fb0"
2323

2424
[target.'cfg(windows)'.dependencies]
2525
winapi = { version = "0.3", features = ["winbase", "winnt", "accctrl", "aclapi", "securitybaseapi", "minwinbase", "winbase"] }

Diff for: net/tests/smoke.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ mod ipc {
253253
{
254254
let (cl, errs) = client(URI);
255255
cl.join().expect("client should not crash");
256-
assert_eq!(1, errs.load(Ordering::Acquire));
256+
assert!(errs.load(Ordering::Acquire) >= 1);
257257
}
258258
}
259259

Diff for: runtime/src/resources.rs

+42
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,45 @@ pub fn time_metadata() -> StructTag {
7878
type_params: vec![],
7979
}
8080
}
81+
82+
#[cfg(test)]
83+
mod tests {
84+
use crate::resources::{time_metadata, block_metadata, oracle_metadata};
85+
86+
#[test]
87+
pub fn test_oracle_metadata() {
88+
let vector = oracle_metadata("DFI", "BTC").access_vector();
89+
assert_eq!(
90+
vector,
91+
hex::decode("01b1a724361d17c9866b12e199ecdb17eb5cb16630b647bbc997fe65362920e3bb")
92+
.unwrap()
93+
);
94+
95+
let vector = oracle_metadata("BTC", "ETH").access_vector();
96+
assert_eq!(
97+
vector,
98+
hex::decode("01a7183ec0c4d32fd9a2705e1e6844035c5238598bf45167742e9db3735af96cc1")
99+
.unwrap()
100+
);
101+
}
102+
103+
#[test]
104+
pub fn test_time_metadata() {
105+
let vector = time_metadata().access_vector();
106+
assert_eq!(
107+
vector,
108+
hex::decode("01bb4980dfba817aaa64cb4b3a75ee1e1d8352111dead64c5c4f05fb7b4c85bb3e")
109+
.unwrap()
110+
);
111+
}
112+
113+
#[test]
114+
pub fn test_block_metadata() {
115+
let vector = block_metadata().access_vector();
116+
assert_eq!(
117+
vector,
118+
hex::decode("01ada6f79e8eddfdf986687174de1000df3c5fa45e9965ece812fed33332ec543a")
119+
.unwrap()
120+
);
121+
}
122+
}

Diff for: services/src/metadata.rs

+1-107
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
use libra::{prelude::*, vm::*};
1+
use libra::prelude::*;
22
use lang::bytecode::extract_script_params;
33
use crate::{tonic, api};
44
use tonic::{Request, Response, Status};
55
use api::grpc::vm_grpc::vm_script_metadata_server::VmScriptMetadata;
6-
use api::grpc::vm_grpc::vm_access_vector_server::VmAccessVector;
76
use api::grpc::vm_grpc::{Signature, VmScript, VmTypeTag};
87
use info::metrics::meter::ScopeMeter;
98
use info::metrics::execution::ExecutionResult;
10-
use dvm_net::api::grpc::vm_grpc::{AccessVector, StructIdent, LcsTag, LcsType};
11-
use std::convert::TryFrom;
12-
use anyhow::Error;
139

1410
/// Metadata service.
1511
/// Provides a function to retrieve metadata for the script.
@@ -61,105 +57,3 @@ impl VmScriptMetadata for MetadataService {
6157
Ok(Response::new(Signature::new(&arg_types)))
6258
}
6359
}
64-
65-
#[tonic::async_trait]
66-
impl VmAccessVector for MetadataService {
67-
async fn get_access_vector(
68-
&self,
69-
request: Request<StructIdent>,
70-
) -> Result<Response<AccessVector>, Status> {
71-
let mut meter = ScopeMeter::new("get_access_vector");
72-
match Ident::try_from(request.into_inner()) {
73-
Ok(ident) => {
74-
meter.set_result(ExecutionResult::new(true, 200, 0));
75-
Ok(Response::new(AccessVector {
76-
access_vector: ident.as_ref().access_vector(),
77-
}))
78-
}
79-
Err(err) => {
80-
meter.set_result(ExecutionResult::new(false, 400, 0));
81-
Err(Status::unimplemented(format!(
82-
"Unsupported struct signature. {}",
83-
err
84-
)))
85-
}
86-
}
87-
}
88-
}
89-
90-
/// StructTag wrapper.
91-
struct Ident(StructTag);
92-
93-
impl AsRef<StructTag> for Ident {
94-
fn as_ref(&self) -> &StructTag {
95-
&self.0
96-
}
97-
}
98-
99-
impl Into<StructTag> for Ident {
100-
fn into(self) -> StructTag {
101-
self.0
102-
}
103-
}
104-
105-
impl TryFrom<StructIdent> for Ident {
106-
type Error = Error;
107-
108-
fn try_from(value: StructIdent) -> Result<Self, Self::Error> {
109-
let type_params = value
110-
.type_params
111-
.into_iter()
112-
.map(|p| TypeIdent::try_from(p).map(|t| t.into()))
113-
.collect::<Result<Vec<TypeTag>, Error>>()?;
114-
115-
Ok(Ident(StructTag {
116-
address: AccountAddress::try_from(value.address)?,
117-
module: Identifier::new(value.module)?,
118-
name: Identifier::new(value.name)?,
119-
type_params,
120-
}))
121-
}
122-
}
123-
124-
/// TypeTag wrapper.
125-
struct TypeIdent(TypeTag);
126-
127-
impl Into<TypeTag> for TypeIdent {
128-
fn into(self) -> TypeTag {
129-
self.0
130-
}
131-
}
132-
133-
impl TryFrom<LcsTag> for TypeIdent {
134-
type Error = Error;
135-
136-
fn try_from(value: LcsTag) -> Result<Self, Self::Error> {
137-
let lcs_type =
138-
LcsType::from_i32(value.type_tag).ok_or_else(|| anyhow!("Invalid type tag."))?;
139-
140-
let tag = match lcs_type {
141-
LcsType::LcsBool => TypeTag::Bool,
142-
LcsType::LcsU64 => TypeTag::U64,
143-
LcsType::LcsVector => {
144-
let vec_type = value
145-
.vector_type
146-
.ok_or_else(|| anyhow!("Vector_Type is required for LcsType::LcsVector."))?;
147-
TypeTag::Vector(Box::new(
148-
TypeIdent::try_from(vec_type.as_ref().clone())?.into(),
149-
))
150-
}
151-
LcsType::LcsAddress => TypeTag::Address,
152-
LcsType::LcsU8 => TypeTag::U8,
153-
LcsType::LcsU128 => TypeTag::U128,
154-
LcsType::LcsSigner => TypeTag::Signer,
155-
LcsType::LcsStruct => {
156-
let struct_ident = value
157-
.struct_ident
158-
.ok_or_else(|| anyhow!("StructIdent is required for LcsType::LcsStruct."))?;
159-
TypeTag::Struct(Ident::try_from(struct_ident)?.into())
160-
}
161-
};
162-
163-
Ok(TypeIdent(tag))
164-
}
165-
}

0 commit comments

Comments
 (0)