Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump tendermint, cosmos sdk & rust & sgx-sdk to latest versions #1497

Merged
merged 33 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3e74c7e
Bump tendermint, cosmos sdk & rust & sgx-sdk to latest versions
Cashmaney Aug 2, 2023
1012162
Fix enclave tests & all the clippy stuff
Cashmaney Aug 3, 2023
abb64b9
Update Dockerfile
Cashmaney Aug 1, 2023
9e7253d
Fix docker image base
Cashmaney Aug 3, 2023
dbdd75d
Fucking A
assafmo Jul 30, 2023
2484f00
Add toolchain to v010 contract building
Cashmaney Aug 3, 2023
613e784
Add toolchain to v010 contract building
Cashmaney Aug 3, 2023
c9c3958
Merge remote-tracking branch 'origin/master' into more-fixes-for-sdk-…
Cashmaney Aug 3, 2023
dcb6d24
Fix HW CI again
Cashmaney Aug 3, 2023
f60178f
Fix HW CI again
Cashmaney Aug 3, 2023
70a340b
Trying multiple fixes for CI
Cashmaney Aug 6, 2023
d8c922f
Trying multiple fixes for CI
Cashmaney Aug 6, 2023
aa7f31b
maybe maybe maybe
Cashmaney Aug 6, 2023
a1fdbe7
revert
Cashmaney Aug 6, 2023
1426ea3
Another attempted fix
Cashmaney Aug 7, 2023
4f8a98d
Another attempted fix
Cashmaney Aug 7, 2023
073e270
Fixing Assaf's clippy warnings
Cashmaney Aug 7, 2023
0397f33
Merge branch 'master' into bump-all-deps
Cashmaney Aug 8, 2023
f8021db
Fixed go mod & small QoL for makefile
Cashmaney Aug 8, 2023
eb864a2
Merge remote-tracking branch 'origin/master' into bump-all-deps
Cashmaney Aug 21, 2023
989d4c8
Cherry pick attestation changes
Cashmaney Aug 10, 2023
3d68936
Removed whitelist in favor of double attestation
Cashmaney Aug 10, 2023
a5f1b3b
Update attestation.rs
Cashmaney Aug 13, 2023
c15a1c4
Clippy and SW compile
Cashmaney Aug 13, 2023
dd8f2d9
Clippy and SW compile
Cashmaney Aug 13, 2023
74f665f
Remove grace period stuff
Cashmaney Aug 21, 2023
12384bb
Remove grace period stuff
Cashmaney Aug 13, 2023
5390426
Fix all clippy warnings and stuff
Cashmaney Aug 21, 2023
05442ed
Fix all clippy warnings and stuff
Cashmaney Aug 21, 2023
c5882fd
Fix attestation API
Cashmaney Aug 21, 2023
5038b48
Fix attestation API
Cashmaney Aug 21, 2023
3219810
Update report.rs
Cashmaney Aug 21, 2023
1d6d003
Update cert.rs
Cashmaney Aug 21, 2023
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
37 changes: 10 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
run: |
mkdir -p "$HOME/.sgxsdk"
cd "$HOME/.sgxsdk"
SDK_BIN=sgx_linux_x64_sdk_2.17.101.1.bin
wget https://download.01.org/intel-sgx/sgx-linux/2.17.1/distro/ubuntu20.04-server/"$SDK_BIN"
SDK_BIN=sgx_linux_x64_sdk_2.20.100.4.bin
wget https://download.01.org/intel-sgx/sgx-linux/2.20/distro/ubuntu20.04-server/"$SDK_BIN"
chmod +x "$SDK_BIN"
echo yes | ./"$SDK_BIN"
- name: Cache cargo registry
Expand Down Expand Up @@ -43,27 +43,17 @@ jobs:
rustc --version
cargo +stable install xargo --version 0.3.25
xargo --version
- name: Download sccache
run: |
wget https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
tar xf ./sccache-*.tar.gz
mv ./sccache*/sccache "$HOME/sccache"
- name: Test enclave
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
export SGX_MODE=SW
RUSTC_WRAPPER="$HOME/sccache" make enclave-tests
make enclave-tests
make clean-enclave

Build-Contracts:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Download sccache
run: |
wget https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
tar xf ./sccache-*.tar.gz
mv ./sccache*/sccache "$HOME/sccache"
- name: Install Requirements
run: |
rustup target add wasm32-unknown-unknown
Expand Down Expand Up @@ -120,8 +110,8 @@ jobs:
run: |
mkdir -p "$HOME/.sgxsdk"
cd "$HOME/.sgxsdk"
SDK_BIN=sgx_linux_x64_sdk_2.17.101.1.bin
wget https://download.01.org/intel-sgx/sgx-linux/2.17.1/distro/ubuntu20.04-server/"$SDK_BIN"
SDK_BIN=sgx_linux_x64_sdk_2.20.100.4.bin
wget https://download.01.org/intel-sgx/sgx-linux/2.20/distro/ubuntu20.04-server/"$SDK_BIN"
chmod +x "$SDK_BIN"
echo yes | ./"$SDK_BIN"
- name: Download LocalSecret
Expand All @@ -140,9 +130,11 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: contract.wasm
path: ./x/compute/internal/keeper/testdata/
- uses: actions/download-artifact@v3
with:
name: contract-v2.wasm
path: ./x/compute/internal/keeper/testdata/
- uses: actions/download-artifact@v3
with:
name: v1-contract.wasm
Expand All @@ -154,24 +146,20 @@ jobs:
- uses: actions/download-artifact@v3
with:
name: contract_with_floats.wasm
path: ./x/compute/internal/keeper/testdata/
- uses: actions/download-artifact@v3
with:
name: too-high-initial-memory.wasm
path: ./x/compute/internal/keeper/testdata/
- uses: actions/download-artifact@v3
with:
name: static-too-high-initial-memory.wasm
path: ./x/compute/internal/keeper/testdata/
- name: Setup Files
run: |
find "$(pwd)" -name \*.wasm
cp libgo_cosmwasm.so ./go-cosmwasm/api/libgo_cosmwasm.so
cp librust_cosmwasm_enclave.signed.so ./go-cosmwasm/librust_cosmwasm_enclave.signed.so
# cp /opt/mount/librandom_api.so /usr/lib/librandom_api.so
# cp /opt/mount/tendermint_enclave.signed.so /usr/lib/tendermint_enclave.signed.so
cp contract.wasm ./x/compute/internal/keeper/testdata/contract.wasm
cp contract-v2.wasm ./x/compute/internal/keeper/testdata/contract-v2.wasm
cp too-high-initial-memory.wasm ./x/compute/internal/keeper/testdata/too-high-initial-memory.wasm
cp contract_with_floats.wasm ./x/compute/internal/keeper/testdata/contract_with_floats.wasm
cp static-too-high-initial-memory.wasm ./x/compute/internal/keeper/testdata/static-too-high-initial-memory.wasm
find "$(pwd)" -name \*.wasm
- name: Test x/registration
run: |
Expand Down Expand Up @@ -232,11 +220,6 @@ jobs:
rustc --version
cargo +stable install xargo --version 0.3.25
xargo --version
- name: Download sccache
run: |
wget https://github.com/mozilla/sccache/releases/download/0.2.13/sccache-0.2.13-x86_64-unknown-linux-musl.tar.gz
tar xf ./sccache-*.tar.gz
mv ./sccache*/sccache "$HOME/sccache"
- name: Clippy
run: |
source "$HOME/.sgxsdk/sgxsdk/environment"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
- "*"
branches:
- "*"
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "third_party/incubator-teaclave-sgx-sdk"]
path = third_party/incubator-teaclave-sgx-sdk
url = https://github.com/scrtlabs/incubator-teaclave-sgx-sdk
branch = secret-new-1.1.5
branch = secret-1.x
4 changes: 2 additions & 2 deletions check-hw/Cargo.lock

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

2 changes: 1 addition & 1 deletion check-hw/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env;

fn main() {
let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/intel/sgxsdk".to_string());
let sdk_dir = env::var("SGX_SDK").unwrap_or_else(|_| "/opt/sgxsdk".to_string());

println!("cargo:rustc-link-search=native=../go-cosmwasm/lib");
println!("cargo:rustc-link-lib=static=Enclave_u");
Expand Down
4 changes: 2 additions & 2 deletions cosmwasm/Cargo.lock

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

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.61
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use core::time;
use mem::MaybeUninit;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::ptr::null;
use std::{mem, thread};

//// consts
Expand Down Expand Up @@ -1697,9 +1698,11 @@ fn pass_null_pointer_to_imports_should_throw<S: Storage, A: Api, Q: Querier>(
) -> HandleResponse {
let null_ptr_slice: &[u8] = unsafe { MaybeUninit::zeroed().assume_init() };

use std::ptr;

match &pass_type[..] {
"read_db_key" => {
deps.storage.get(null_ptr_slice);
unsafe { deps.storage.get(null_ptr_slice) };
}
"write_db_key" => {
deps.storage.set(null_ptr_slice, b"write value");
Expand Down
26 changes: 13 additions & 13 deletions cosmwasm/enclaves/Cargo.lock

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

2 changes: 1 addition & 1 deletion cosmwasm/enclaves/Xargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ panic_unwind = { path = "../../third_party/incubator-teaclave-sgx-sdk/sgx_panic_
sgx_tdh = { path = "../../third_party/incubator-teaclave-sgx-sdk/sgx_tdh", stage = 4 }
sgx_tseal = { path = "../../third_party/incubator-teaclave-sgx-sdk/sgx_tseal", stage = 4 }
sgx_tprotected_fs = { path = "../../third_party/incubator-teaclave-sgx-sdk/sgx_tprotected_fs", stage = 4 }
std = { git = "https://github.com/apache/teaclave-sgx-sdk.git", rev = "c70a82f708fd20e9fd0377990dde097d14024f7a", stage = 5, features = [
std = { path = "../../third_party/incubator-teaclave-sgx-sdk/xargo/sgx_tstd", stage = 5, features = [
"net",
"backtrace",
"untrusted_fs",
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/execute/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
######## SGX SDK Settings ########

FEATURES ?=
SGX_SDK ?= $(HOME)/.sgxsdk/sgxsdk
SGX_SDK ?= /opt/sgxsdk
SGX_MODE ?= HW
SGX_ARCH ?= x64
BUILD_PROFILE ?= release
Expand Down
3 changes: 1 addition & 2 deletions cosmwasm/enclaves/execute/src/registration/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn create_attestation_certificate(
let (prv_k, pub_k) = ecc_handle.create_key_pair().unwrap();

// this is the ed25519 public key we want to encode
let encoded_pubkey = base64::encode(&kp.get_pubkey());
let encoded_pubkey = base64::encode(kp.get_pubkey());

let (key_der, cert_der) =
super::cert::gen_ecc_cert(encoded_pubkey, &prv_k, &pub_k, &ecc_handle)?;
Expand Down Expand Up @@ -181,7 +181,6 @@ pub fn get_mr_enclave() -> [u8; 32] {

//input: pub_k: &sgx_ec256_public_t, todo: make this the pubkey of the node
#[cfg(feature = "SGX_MODE_HW")]
#[allow(const_err)]
pub fn create_attestation_report(
pub_k: &[u8; 32],
sign_type: sgx_quote_sign_type_t,
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/execute/src/registration/offchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ pub unsafe extern "C" fn ecall_key_gen(
pub unsafe extern "C" fn ecall_get_genesis_seed(
pk: *const u8,
pk_len: u32,
seed: &mut [u8; SINGLE_ENCRYPTED_SEED_SIZE as usize],
seed: &mut [u8; SINGLE_ENCRYPTED_SEED_SIZE],
) -> sgx_types::sgx_status_t {
validate_mut_ptr!(
seed.as_mut_ptr(),
Expand Down
14 changes: 2 additions & 12 deletions cosmwasm/enclaves/execute/src/registration/persistency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@ use enclave_utils::storage::rewrite_on_untrusted;
use sgx_types::SgxResult;

pub fn write_public_key(kp: &KeyPair, save_path: &str) -> SgxResult<()> {
if let Err(status) =
rewrite_on_untrusted(base64::encode(&kp.get_pubkey()).as_bytes(), save_path)
{
return Err(status);
}

Ok(())
rewrite_on_untrusted(base64::encode(kp.get_pubkey()).as_bytes(), save_path)
}

pub fn write_seed(seed: &[u8], save_path: &str) -> SgxResult<()> {
if let Err(status) = rewrite_on_untrusted(base64::encode(seed).as_bytes(), save_path) {
return Err(status);
}

Ok(())
rewrite_on_untrusted(base64::encode(seed).as_bytes(), save_path)
}

pub fn write_master_pub_keys(key_manager: &Keychain) -> SgxResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/execute/src/registration/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ impl AttestationReport {
warn!("Error unpacking enclave quote body");
Error::ReportParseError
})?;
let quote_raw = base64::decode(&quote_encoded.as_bytes()).map_err(|_| {
let quote_raw = base64::decode(quote_encoded.as_bytes()).map_err(|_| {
warn!("Error decoding encoded quote body");
Error::ReportParseError
})?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn encrypt_seed(
.encrypt_siv(seed_to_share.as_slice(), Some(&authenticated_data))
{
Ok(r) => {
if r.len() != SINGLE_ENCRYPTED_SEED_SIZE as usize {
if r.len() != SINGLE_ENCRYPTED_SEED_SIZE {
error!(
"Seed encryption failed. Got seed of unexpected length: {:?}",
r.len()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn create_socket_to_service(host_name: &str) -> Result<c_int, CryptoError> {
return Err(CryptoError::IPv4LookupError);
}

let sock = TcpStream::connect(&addr.unwrap()).map_err(|err| {
let sock = TcpStream::connect(addr.unwrap()).map_err(|err| {
trace!(
"Error while trying to connect to service with addr: {:?}, err: {:?}",
addr,
Expand Down Expand Up @@ -311,10 +311,6 @@ pub fn get_next_consensus_seed_from_service(
}
};

if let Err(e) = opt_seed {
return Err(e);
}

let mut seed = opt_seed?;

// XOR the seed with the genesis seed
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-02-23
nightly-2022-10-22
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ pub fn check_tx_in_current_block(tx_sign_bytes: &[u8]) -> bool {
// this isn't an attack vector since this can happen anyway by manipulating the state between executions
while verified_msgs.remaining() > 0 {
if let Some(verified_msg) = verified_msgs.get_next() {
trace!("input tx_sign_bytes: {:?}", hex::encode(&tx_sign_bytes));
trace!("input tx_sign_bytes: {:?}", hex::encode(tx_sign_bytes));
trace!("light client msg: {:?}", hex::encode(&verified_msg));
if is_subslice(tx_sign_bytes, &verified_msg) {
return true;
Expand Down
Loading