From 2456db8bc7e114f34c4c49a9ec89e665d5e8de1d Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Thu, 24 Jun 2021 09:48:42 +0000 Subject: [PATCH] fixup! build: Remove the old clients --- .buildkite/benchmarks.pipeline.yml | 3 - .buildkite/code.pipeline.yml | 3 - .buildkite/longtests.pipeline.yml | 7 - .buildkite/rust/coverage.sh | 1 - .../scripts/download_e2e_test_artifacts.sh | 4 +- .buildkite/scripts/test_consim.sh | 48 --- Cargo.lock | 16 - Cargo.toml | 3 - tests/clients/simple-keyvalue/Cargo.toml | 18 -- tests/clients/simple-keyvalue/src/main.rs | 295 ------------------ 10 files changed, 1 insertion(+), 397 deletions(-) delete mode 100755 .buildkite/scripts/test_consim.sh delete mode 100644 tests/clients/simple-keyvalue/Cargo.toml delete mode 100644 tests/clients/simple-keyvalue/src/main.rs diff --git a/.buildkite/benchmarks.pipeline.yml b/.buildkite/benchmarks.pipeline.yml index 58e66b54e02..6abfe395e6d 100644 --- a/.buildkite/benchmarks.pipeline.yml +++ b/.buildkite/benchmarks.pipeline.yml @@ -62,13 +62,10 @@ steps: - label: Build Rust runtime loader command: - .buildkite/rust/build_generic.sh /workdir -p oasis-core-runtime-loader - - .buildkite/rust/build_generic.sh /workdir -p simple-keyvalue-client # Upload the built artifacts. - cd /var/tmp/artifacts/default/debug - buildkite-agent artifact upload oasis-core-runtime-loader - # Clients for E2E tests. - - buildkite-agent artifact upload simple-keyvalue-client plugins: <<: *docker_plugin diff --git a/.buildkite/code.pipeline.yml b/.buildkite/code.pipeline.yml index 0adb45ca5dd..a1f600d9c16 100644 --- a/.buildkite/code.pipeline.yml +++ b/.buildkite/code.pipeline.yml @@ -129,13 +129,10 @@ steps: - label: Build Rust runtime loader command: - .buildkite/rust/build_generic.sh /workdir -p oasis-core-runtime-loader - - .buildkite/rust/build_generic.sh /workdir -p simple-keyvalue-client # Upload the built artifacts. - cd /var/tmp/artifacts/default/debug - buildkite-agent artifact upload oasis-core-runtime-loader - # Clients for E2E tests. - - buildkite-agent artifact upload simple-keyvalue-client retry: <<: *retry_agent_failure plugins: diff --git a/.buildkite/longtests.pipeline.yml b/.buildkite/longtests.pipeline.yml index 18c207e468f..7353f615e36 100644 --- a/.buildkite/longtests.pipeline.yml +++ b/.buildkite/longtests.pipeline.yml @@ -52,17 +52,10 @@ steps: - label: Build Rust runtime loader command: - .buildkite/rust/build_generic.sh /workdir -p oasis-core-runtime-loader - - .buildkite/rust/build_generic.sh /workdir -p test-long-term-client - - .buildkite/rust/build_generic.sh /workdir -p simple-keyvalue-client - - .buildkite/rust/build_generic.sh /workdir -p simple-keyvalue-enc-client # Upload the built artifacts. - cd /var/tmp/artifacts/default/debug - buildkite-agent artifact upload oasis-core-runtime-loader - # Clients for E2E tests. - - buildkite-agent artifact upload test-long-term-client - - buildkite-agent artifact upload simple-keyvalue-client - - buildkite-agent artifact upload simple-keyvalue-enc-client plugins: <<: *docker_plugin diff --git a/.buildkite/rust/coverage.sh b/.buildkite/rust/coverage.sh index 0a427cee0cd..84143959a4f 100755 --- a/.buildkite/rust/coverage.sh +++ b/.buildkite/rust/coverage.sh @@ -49,7 +49,6 @@ cargo tarpaulin \ --out Xml \ --all \ --exclude simple-keyvalue \ - --exclude simple-keyvalue-client \ --exclude-files '*generated*' \ --exclude-files tests \ --exclude-files runtime/src/storage/mkvs/interop \ diff --git a/.buildkite/scripts/download_e2e_test_artifacts.sh b/.buildkite/scripts/download_e2e_test_artifacts.sh index 30c7f71bdda..6ddc017a0ad 100755 --- a/.buildkite/scripts/download_e2e_test_artifacts.sh +++ b/.buildkite/scripts/download_e2e_test_artifacts.sh @@ -29,9 +29,7 @@ download_artifact simple-keymanager target/default/debug 755 download_artifact simple-keymanager-upgrade.sgxs target/sgx/x86_64-fortanix-unknown-sgx/debug 755 download_artifact simple-keymanager-upgrade target/default/debug 755 -# Test simple-keyvalue runtime and clients. -download_artifact simple-keyvalue-client target/default/debug 755 - +# Test simple-keyvalue runtime. download_artifact simple-keyvalue.sgxs target/sgx/x86_64-fortanix-unknown-sgx/debug 755 download_artifact simple-keyvalue target/default/debug 755 download_artifact simple-keyvalue-upgrade.sgxs target/sgx/x86_64-fortanix-unknown-sgx/debug 755 diff --git a/.buildkite/scripts/test_consim.sh b/.buildkite/scripts/test_consim.sh deleted file mode 100755 index cc5e3e47fdb..00000000000 --- a/.buildkite/scripts/test_consim.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -############################################################ -# This script tests the Oasis Core project with the consensus -# simulator. -# -# Usage: -# test_consim.sh -############################################################ - -# Helpful tips on writing build scripts: -# https://buildkite.com/docs/pipelines/writing-build-scripts -set -euxo pipefail - -# Working directory. -WORKDIR=$PWD - -################# -# Run test suite. -################# - -echo ${WORKDIR} - -CONSIM_GENESIS=/tmp/consim-genesis.json - -# Generate the consensus sim genesis document. -${WORKDIR}/go/oasis-node/oasis-node \ - genesis init \ - --debug.test_entity \ - --debug.dont_blame_oasis \ - --chain.id test \ - --debug.allow_test_keys \ - --staking.token_symbol BUF \ - -g ${CONSIM_GENESIS} - -# Run the consensus simulator. -${WORKDIR}/go/oasis-node/oasis-node \ - debug consim \ - --datadir /tmp/consim-datadir \ - --log.level DEBUG \ - --log.file /tmp/consim-datadir/consim.log \ - -g ${CONSIM_GENESIS} \ - --debug.dont_blame_oasis \ - --debug.allow_test_keys \ - --consim.workload xfer \ - --consim.workload.xfer.iterations 10000 \ - --consim.num_kept 1 \ - --consim.memdb diff --git a/Cargo.lock b/Cargo.lock index dcef959f409..eefa7ff1ae1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2271,21 +2271,6 @@ dependencies = [ "serde", ] -[[package]] -name = "simple-keyvalue-client" -version = "0.0.0" -dependencies = [ - "clap", - "grpcio", - "io-context", - "oasis-core-client", - "oasis-core-runtime", - "rand 0.7.3", - "serde_bytes", - "simple-keyvalue-api", - "tokio 1.6.1", -] - [[package]] name = "simple_asn1" version = "0.5.3" @@ -2609,7 +2594,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0a38d31d7831c6ed7aad00aa4c12d9375fd225a6dd77da1d25b707346319a975" dependencies = [ "autocfg 1.0.1", - "num_cpus", "pin-project-lite 0.2.6", ] diff --git a/Cargo.toml b/Cargo.toml index 6b49670ff8a..a6678df1842 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,9 +11,6 @@ members = [ # Test runtimes. "tests/runtimes/simple-keyvalue", "tests/runtimes/simple-keymanager", - - # Test clients. - "tests/clients/simple-keyvalue", ] [profile.release] diff --git a/tests/clients/simple-keyvalue/Cargo.toml b/tests/clients/simple-keyvalue/Cargo.toml deleted file mode 100644 index a35602e29e0..00000000000 --- a/tests/clients/simple-keyvalue/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "simple-keyvalue-client" -version = "0.0.0" -authors = ["Oasis Protocol Foundation "] -description = "Key value test client" -edition = "2018" - -[dependencies] -oasis-core-client = { path = "../../../client" } -oasis-core-runtime = { path = "../../../runtime" } -simple-keyvalue-api = { path = "../../runtimes/simple-keyvalue/api" } - -clap = "2.29.1" -grpcio = "0.9.0" -io-context = "0.2.0" -rand = "0.7.3" -tokio = { version = "1", features = ["rt-multi-thread"] } -serde_bytes = "0.11.5" diff --git a/tests/clients/simple-keyvalue/src/main.rs b/tests/clients/simple-keyvalue/src/main.rs deleted file mode 100644 index 82c1a053f86..00000000000 --- a/tests/clients/simple-keyvalue/src/main.rs +++ /dev/null @@ -1,295 +0,0 @@ -// Allow until oasis-core#3572. -#![allow(deprecated)] - -#[macro_use] -extern crate clap; -extern crate grpcio; -extern crate io_context; -extern crate oasis_core_client; -extern crate oasis_core_runtime; -extern crate simple_keyvalue_api; -extern crate tokio; - -use std::{collections::BTreeMap, sync::Arc}; - -use clap::{App, Arg}; -use grpcio::EnvBuilder; -use io_context::Context; -use rand::{rngs::StdRng, Rng, SeedableRng}; -use serde_bytes::ByteBuf; -use tokio::runtime::Runtime; - -use oasis_core_client::{ - create_txn_api_client, - transaction::{Query, QueryCondition}, - Node, TxnClient, -}; -use oasis_core_runtime::{ - common::{crypto::hash::Hash, namespace::Namespace}, - consensus::{ - address::Address, - staking::{Account, Delegation}, - }, - storage::MKVS, -}; -use simple_keyvalue_api::{ - with_api, AddEscrow, Key, KeyValue, ReclaimEscrow, Transfer, UpdateRuntime, Withdraw, -}; - -with_api! { - create_txn_api_client!(SimpleKeyValueClient, api); -} - -fn main() { - let matches = App::new("Simple key/value runtime test client") - .arg( - Arg::with_name("runtime-id") - .long("runtime-id") - .takes_value(true) - .required(true), - ) - .arg( - Arg::with_name("node-address") - .long("node-address") - .takes_value(true) - .required(true), - ) - .arg(Arg::with_name("seed").long("seed").takes_value(true)) - .arg(Arg::with_name("repeat").long("repeat")) - .get_matches(); - - let node_address = matches.value_of("node-address").unwrap(); - let runtime_id = value_t_or_exit!(matches, "runtime-id", Namespace); - let nonce_seed = matches - .value_of("seed") - .unwrap_or("seeeeeeeeeeeeeeeeeeeeeeeeeeeeeed") - .as_bytes(); - let repeat = matches.is_present("repeat"); - - let h = Hash::digest_bytes(&nonce_seed); - let mut rng: StdRng = SeedableRng::from_seed(h.into()); - - println!("Initializing simple key/value runtime client!"); - let rt = Runtime::new().unwrap(); - let env = Arc::new(EnvBuilder::new().build()); - let node = Node::new(env, node_address); - let txn_client = TxnClient::new(node.channel(), runtime_id, None); - let kv_client = SimpleKeyValueClient::new(txn_client); - - // Check whether Runtime ID is also set remotely. - let r: Option = rt.block_on(kv_client.get_runtime_id(())).unwrap(); - assert_eq!(runtime_id.to_string(), r.expect("runtime_id")); - - let mut iteration = 0; - while iteration < 1 || repeat { - println!("Beginning client loop iteration..."); - iteration += 1; - - // Test simple [set,get] key calls - let mut kv = KeyValue { - key: String::from("hello_key"), - value: String::from("hello_value_from_") + &runtime_id.to_string(), - nonce: Some(rng.gen()), - }; - let mut k = Key { - key: kv.key.clone(), - nonce: Some(rng.gen()), - }; - println!( - "Storing \"{}\" as key and \"{}\" as value to database...", - kv.key, kv.value - ); - let r: Option = rt.block_on(kv_client.insert(kv.clone())).unwrap(); - if !repeat { - assert_eq!(r, None); // key should not exist in db before - } - kv.nonce = Some(rng.gen()); - - println!("Getting \"{}\"...", k.key); - let r = rt.block_on(kv_client.get(k.clone())).unwrap(); - match r { - Some(val) => { - println!("Got \"{}\"", val); - assert_eq!(val, kv.value) - } // key should exist in db - None => { - println!("Key not found"); - panic!("Key \"{}\" not found, but it should be.", kv.value) - } - } - k.nonce = Some(rng.gen()); - - // Test [set, get] long key calls - let mut long_kv = KeyValue { - key: String::from("Unlock the potential of your data without compromising security or privacy"), - value: String::from("The platform that puts data privacy first. From sharing medical records, to analyzing personal financial information etc."), - nonce: Some(rng.gen()), - }; - let mut long_k = Key { - key: long_kv.key.clone(), - nonce: Some(rng.gen()), - }; - println!("Storing long key and value to database..."); - let r: Option = rt.block_on(kv_client.insert(long_kv.clone())).unwrap(); - if !repeat { - assert_eq!(r, None); // key should not exist in db before - } - long_kv.nonce = Some(rng.gen()); - - println!("Testing runtime message emission..."); - rt.block_on(kv_client.consensus_transfer(Transfer { - nonce: rng.gen(), - transfer: Default::default(), - })) - .unwrap(); - - println!("Getting long key..."); - let r = rt.block_on(kv_client.get(long_k.clone())).unwrap(); - match r { - Some(val) => { - println!("Got correct long value"); - assert_eq!(val, long_kv.value) - } // key should exist in db - None => { - println!("Key not found"); - panic!("Long key not found, but it should be.") - } - } - long_k.nonce = Some(rng.gen()); - - // Test get_latest_block call. - println!("Getting latest block..."); - let snapshot = rt - .block_on(kv_client.txn_client().get_latest_block()) - .expect("get latest block snapshot"); - println!("Retrieved block: {:?}", snapshot.block); - println!("Accessing read-only state snapshot..."); - let r = snapshot - .get(Context::background(), kv.key.as_bytes()) - .expect("read-only state get"); - println!( - "Got \"{}\" ({:?})", - String::from_utf8(r.clone()).unwrap(), - r - ); - assert_eq!(&r[..], kv.value.as_bytes()); - - // Test get_block call. - for round in 0..=snapshot.block.header.round { - println!("Getting indexed block {}...", round); - let snapshot = rt - .block_on(kv_client.txn_client().get_block(round)) - .expect("get block snapshot") - .expect("block must exist"); - - println!("Retrieved block: {:?}", snapshot.block); - assert_eq!(snapshot.block.header.round, round); - } - - let latest_snapshot = snapshot; - let snapshot = rt - .block_on(kv_client.txn_client().get_block(100000)) - .expect("non-existent block must return None"); - assert!(snapshot.is_none(), "non-existent block must return None"); - - println!("Removing \"{}\" record from database...", k.key); - let r = rt.block_on(kv_client.remove(k.clone())).unwrap(); - if !repeat { - assert_eq!(r, Some(kv.value)); // key should exist in db while removing it - } - k.nonce = Some(rng.gen()); - - println!("Getting \"{}\" to check whether it still exists...", kv.key); - let r = rt.block_on(kv_client.get(k.clone())).unwrap(); - match r { - Some(_) => println!("Key still exists."), - None => println!("Key not found anymore"), - } - assert_eq!(r, None, "key should not exist anymore"); - k.nonce = Some(rng.gen()); - - // Test wait_block_indexed call. - println!("Waiting for block to be indexed..."); - let latest_round = latest_snapshot.block.header.round; - rt.block_on(kv_client.txn_client().wait_block_indexed(latest_round)) - .expect("wait block indexed"); - - // Test get_block_by_hash call. - println!( - "Querying block by hash ({:?})...", - latest_snapshot.block_hash - ); - let snapshot = rt - .block_on( - kv_client - .txn_client() - .get_block_by_hash(latest_snapshot.block_hash), - ) - .expect("query block snapshot") - .expect("block must exist"); - println!("Found block: {:?}", snapshot.block); - - // Test get_txs call. - println!("Fetching transaction inputs..."); - let txns = rt - .block_on( - kv_client - .txn_client() - .get_txs(snapshot.block.header.round, snapshot.block.header.io_root), - ) - .expect("get transactions"); - println!("Found transactions: {:?}", txns); - assert_eq!(txns.len(), 1); - - // Test query_tx call. - println!("Querying transaction tags (kv_op=insert)..."); - let snapshot = rt - .block_on(kv_client.txn_client().query_tx(b"kv_op", b"insert")) - .expect("query transaction snapshot") - .expect("transaction must exist"); - println!( - "Found transaction: index={} input={:?} output={:?}", - snapshot.index, snapshot.input, snapshot.output - ); - - // Test query_txs call. - println!("Querying transaction tags (kv_op=insert)..."); - let query = Query { - round_min: 0, - round_max: latest_round, - conditions: vec![QueryCondition { - key: b"kv_op".to_vec(), - values: vec![ByteBuf::from(b"insert".to_vec())], - }], - limit: 0, - }; - let txns = rt - .block_on(kv_client.txn_client().query_txs(query)) - .expect("query transactions"); - println!("Found transactions:"); - for txn in txns { - println!( - "round={} index={} input={:?} output={:?}", - txn.block_snapshot.block.header.round, txn.index, txn.input, txn.output - ); - } - } - - println!("Testing consensus queries:"); - let (accounts, delegations) = rt - .block_on(kv_client.consensus_accounts(())) - .expect("query consensus account"); - - for (addr, acc) in accounts { - println!("Account: {:?}: {:?}", addr, acc); - } - - println!("Delegations:"); - for (addr, dels) in delegations { - for (addr2, del) in dels { - println!("Escrow: {:?}: Delegator: {:?}: {:?}", addr, addr2, del); - } - } - - println!("Simple key/value client finished."); -}