Skip to content

Commit 2123217

Browse files
author
vlad
committed
on-chain machine-id WIP(3)
1 parent 55648f1 commit 2123217

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

cosmwasm/enclaves/execute/src/registration/offchain.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,13 @@ fn is_msg_machine_id(msg_in_block: &[u8], machine_id: &[u8]) -> bool {
724724
trace!("*** block msg: {:?}", hex::encode(msg_in_block));
725725

726726
// we expect a message of the form:
727-
// 0a 2d (addr, len=45 bytes) 100f1a14 (machine_id 20 bytes)
727+
// 0a 3d (addr, len=45 bytes)
728+
// 10 (proposal-id, varible length)
729+
// 1a 14 (machine_id 20 bytes)
728730

729-
if msg_in_block.len() != 71 {
731+
let msg_len = msg_in_block.len();
732+
733+
if msg_len < 71 {
730734
trace!("len mismatch: {}", msg_in_block.len());
731735
return false;
732736
}
@@ -736,12 +740,19 @@ fn is_msg_machine_id(msg_in_block: &[u8], machine_id: &[u8]) -> bool {
736740
return false;
737741
}
738742

739-
if &msg_in_block[47..51] != [0x10, 0x0f, 0x1a, 0x14].as_slice() {
743+
if &msg_in_block[47..48] != [0x10].as_slice() {
740744
trace!("wrong sub2");
741745
return false;
742746
}
743747

744-
if &msg_in_block[51..71] != machine_id {
748+
let offs = msg_len - 22;
749+
750+
if &msg_in_block[offs..offs + 2] != [0x1a, 0x14].as_slice() {
751+
trace!("wrong sub3");
752+
return false;
753+
}
754+
755+
if &msg_in_block[offs + 2..offs + 22] != machine_id {
745756
trace!("wrong mrenclave");
746757
return false;
747758
}

0 commit comments

Comments
 (0)