Skip to content

Commit cc6b835

Browse files
committed
enable cron
1 parent 9f7127f commit cc6b835

File tree

17 files changed

+48
-120
lines changed

17 files changed

+48
-120
lines changed

cosmwasm/enclaves/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmwasm/enclaves/execute/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ block-verifier = { path = "../shared/block-verifier", optional = true }
9191
time = "=0.3.17"
9292
ed25519-dalek = { version = "1.0", default-features = false }
9393
sha2 = "0.10"
94-
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false, features = ["rust-crypto"] }
95-
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false }
96-
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false, features = ["rust-crypto"] }
94+
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false, features = ["rust-crypto"] }
95+
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false }
96+
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false, features = ["rust-crypto"] }
9797
rsa = { version = "0.9", default-features = false, features = ["sha2"] }
9898
base64ct = { version = "1.6", default-features = false, features = ["alloc"] }
9999

cosmwasm/enclaves/execute/Enclave.edl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ enclave {
219219
[in, count=in_encrypted_random_len] const uint8_t* in_encrypted_random,
220220
uintptr_t in_encrypted_random_len,
221221
[out, count=32] uint8_t* decrypted,
222-
[out, count=32] uint8_t* next_validator_set_evidence,
223-
[in, count=in_cron_msgs_len] const uint8_t* in_cron_msgs,
224-
uintptr_t in_cron_msgs_len
222+
[out, count=32] uint8_t* next_validator_set_evidence
225223
);
226224
};
227225

cosmwasm/enclaves/execute/src/ecalls.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ pub unsafe extern "C" fn ecall_submit_block_signatures(
1717
in_encrypted_random_len: u32,
1818
decrypted_random: &mut [u8; 32],
1919
next_validator_set_evidence: &mut [u8; 32],
20-
in_cron_msgs: *const u8,
21-
in_cron_msgs_len: u32,
2220
) -> sgx_status_t {
2321
#[cfg(feature = "light-client-validation")]
2422
{
@@ -33,8 +31,6 @@ pub unsafe extern "C" fn ecall_submit_block_signatures(
3331
in_encrypted_random_len,
3432
decrypted_random,
3533
next_validator_set_evidence,
36-
in_cron_msgs,
37-
in_cron_msgs_len,
3834
)
3935
}
4036

cosmwasm/enclaves/shared/block-verifier/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ sgx_types = { rev = "d2d339cbb005f676bb700059bd51dc689c025f6b", git = "https://g
1919

2020
[dependencies]
2121
sha2 = "0.10"
22-
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false, features = ["rust-crypto"] }
23-
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false }
24-
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false, features = ["rust-crypto"] }
22+
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false, features = ["rust-crypto"] }
23+
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false }
24+
tendermint-light-client-verifier = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false, features = ["rust-crypto"] }
2525
lazy_static = "1.4.0"
2626
log = "0.4.17"
2727

cosmwasm/enclaves/shared/block-verifier/src/submit_block_signatures.rs

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ pub unsafe fn submit_block_signatures_impl(
3737
in_encrypted_random_len: u32,
3838
decrypted_random: &mut [u8; 32],
3939
next_validator_set_evidence: &mut [u8; 32],
40-
in_cron_msgs: *const u8,
41-
in_cron_msgs_len: u32,
4240
) -> sgx_status_t {
4341
if let Err(e) = validate_inputs(
4442
in_header,
@@ -64,12 +62,6 @@ pub unsafe fn submit_block_signatures_impl(
6462
&[]
6563
};
6664

67-
let cron_msgs_slice = if in_cron_msgs_len != 0 && !in_cron_msgs.is_null() {
68-
slice::from_raw_parts(in_cron_msgs, in_cron_msgs_len as usize)
69-
} else {
70-
&[]
71-
};
72-
7365
let (validator_set, height) = {
7466
let extra = KEY_MANAGER.extra_data.lock().unwrap();
7567
let validator_set = match extra.decode_validator_set() {
@@ -94,55 +86,13 @@ pub unsafe fn submit_block_signatures_impl(
9486

9587
let txs = unwrap_or_return!(crate::verify::txs::validate_txs(txs_slice, &header));
9688

97-
let cron_msgs = if !cron_msgs_slice.is_empty() {
98-
let msgs = crate::txs::txs_from_bytes(cron_msgs_slice).map_err(|e| {
99-
error!("Error parsing cron msgs from proto: {:?}", e);
100-
sgx_status_t::SGX_ERROR_INVALID_PARAMETER
101-
});
102-
if msgs.is_err() {
103-
error!("Error parsing cron msgs from proto: {:?}", msgs);
104-
return sgx_status_t::SGX_ERROR_INVALID_PARAMETER;
105-
}
106-
Some(msgs.unwrap())
107-
} else {
108-
None
109-
};
110-
11189
let mut message_verifier = VERIFIED_BLOCK_MESSAGES.lock().unwrap();
11290

11391
if message_verifier.remaining() != 0 {
11492
// new block, clear messages
11593
message_verifier.clear();
11694
}
11795

118-
if let Some(implicit_hash_val) = header.header.implicit_hash {
119-
let mut hasher = Sha256::new();
120-
hasher.update(cron_msgs_slice);
121-
let hash_result = hasher.finalize();
122-
let hash_result: [u8; 32] = hash_result.into();
123-
124-
let implicit_hash = tendermint::Hash::Sha256(hash_result);
125-
126-
if implicit_hash != implicit_hash_val {
127-
error!("Implicit hash does not match header implicit hash");
128-
return sgx_status_t::SGX_ERROR_INVALID_PARAMETER;
129-
}
130-
} else if !cron_msgs_slice.is_empty() {
131-
error!("Implicit hash not specified, yet implicit msgs provided");
132-
return sgx_status_t::SGX_ERROR_INVALID_PARAMETER;
133-
}
134-
135-
if let Some(cron_msgs) = cron_msgs {
136-
for msg in cron_msgs {
137-
let parsed_cron_msg = unwrap_or_return!(tx_from_bytes(msg.as_slice()).map_err(|_| {
138-
error!("Unable to parse tx bytes from proto");
139-
sgx_status_t::SGX_ERROR_INVALID_PARAMETER
140-
}));
141-
142-
message_verifier.append_msg_from_tx(parsed_cron_msg);
143-
}
144-
}
145-
14696
for tx in txs.iter() {
14797
// doing this a different way makes the code unreadable or requires creating a copy of
14898

cosmwasm/enclaves/shared/block-verifier/src/verify/header.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ pub fn validate_block_header(
4444
signed_header: &signed_header,
4545
validators: validator_set,
4646
next_validators: None,
47-
implicit_hash: signed_header.header.implicit_hash,
4847
};
4948

5049
let result = verify_block(&untrusted_block);

cosmwasm/enclaves/shared/utils/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ serde = { git = "https://github.com/mesalock-linux/serde-sgx", features = [
3232
"derive"
3333
] }
3434
serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" }
35-
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false }
36-
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.6", default-features = false, features = ["rust-crypto"] }
35+
tendermint-proto = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false }
36+
tendermint = { git = "https://github.com/scrtlabs/tendermint-rs", tag = "v0.38.0-secret.7-beta", default-features = false, features = ["rust-crypto"] }
3737
enclave_crypto = { path = "../crypto" }

cosmwasm/packages/sgx-vm/src/random.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ extern "C" {
1818
in_encrypted_random_len: u32,
1919
decrypted_random: &mut [u8; 32],
2020
next_validator_set_evidence: &mut [u8; 32],
21-
in_cron_msgs: *const u8,
22-
in_cron_msgs_len: u32,
2321
) -> sgx_status_t;
2422
}
2523

@@ -28,7 +26,6 @@ pub fn untrusted_submit_block_signatures(
2826
commit: &[u8],
2927
txs: &[u8],
3028
encrypted_random: &[u8],
31-
cron_msgs: &[u8],
3229
) -> SgxResult<([u8; 32], [u8; 32])> {
3330
debug!("Hello from just before - untrusted_submit_block_signatures");
3431

@@ -39,7 +36,7 @@ pub fn untrusted_submit_block_signatures(
3936
// this is here so we can
4037
loop {
4138
let (retval, decrypted, next_validator_set_evidence, status) =
42-
submit_block_signature_impl(header, commit, txs, encrypted_random, cron_msgs)?;
39+
submit_block_signature_impl(header, commit, txs, encrypted_random)?;
4340
if status != sgx_status_t::SGX_SUCCESS {
4441
return Err(status);
4542
} else if retval != sgx_status_t::SGX_SUCCESS {
@@ -69,7 +66,6 @@ fn submit_block_signature_impl(
6966
commit: &[u8],
7067
txs: &[u8],
7168
encrypted_random: &[u8],
72-
cron_msgs: &[u8],
7369
) -> SgxResult<(sgx_status_t, [u8; 32], [u8; 32], sgx_status_t)> {
7470
// Bind the token to a local variable to ensure its
7571
// destructor runs in the end of the function
@@ -102,8 +98,6 @@ fn submit_block_signature_impl(
10298
encrypted_random.len() as u32,
10399
&mut random_decrypted,
104100
&mut next_validator_set_evidence,
105-
cron_msgs.as_ptr(),
106-
cron_msgs.len() as u32,
107101
)
108102
};
109103

deployment/dockerfiles/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ENV FEATURES=${FEATURES}
7070
ENV FEATURES_U=${FEATURES_U}
7171
ENV MITIGATION_CVE_2020_0551=${MITIGATION_CVE_2020_0551}
7272

73-
RUN git clone --branch header-implicit-hash --depth 1 https://github.com/scrtlabs/tm-secret-enclave.git
73+
RUN git clone --branch pass-scheduled-msgs --depth 1 https://github.com/scrtlabs/tm-secret-enclave.git
7474

7575
WORKDIR tm-secret-enclave
7676

0 commit comments

Comments
 (0)