-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add validation for new message type
- Loading branch information
Showing
12 changed files
with
712 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
pub mod txs; | ||
pub mod validator_set; | ||
pub mod block; | ||
pub mod commit; | ||
pub mod header; | ||
pub mod txs; | ||
pub mod validator_set; | ||
|
||
#[cfg(feature = "random")] | ||
pub mod random; | ||
|
||
// external messages | ||
pub mod registration; |
35 changes: 35 additions & 0 deletions
35
cosmwasm/enclaves/shared/block-verifier/src/verify/registration.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::VERIFIED_MESSAGES; | ||
use log::{debug, error}; | ||
use protobuf::Message; | ||
|
||
pub fn verify_reg_msg(certificate: &[u8]) -> bool { | ||
let mut verified_msgs = VERIFIED_MESSAGES.lock().unwrap(); | ||
let next = verified_msgs.get_next(); | ||
|
||
let result = if let Some(msg) = next { | ||
match cosmos_proto::registration::v1beta1::msg::RaAuthenticate::parse_from_bytes(&msg) { | ||
Ok(ra_msg) => { | ||
if ra_msg.certificate == certificate { | ||
return true; | ||
} | ||
error!("Error failed to validate registration message - 0x7535"); | ||
false | ||
} | ||
Err(e) => { | ||
debug!("Error decoding registation protobuf: {}", e); | ||
error!("Error decoding msg from block validator - 0xA0F2"); | ||
false | ||
} | ||
} | ||
} else { | ||
error!("Cannot verify new node unless msg is part of the current block"); | ||
false | ||
}; | ||
|
||
if !result { | ||
// if validation failed clear the message queue and prepare for next tx... or apphash | ||
verified_msgs.clear(); | ||
} | ||
|
||
result | ||
} |
61 changes: 57 additions & 4 deletions
61
cosmwasm/enclaves/shared/block-verifier/src/wasm_messages.rs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,9 @@ pub mod cosmwasm { | |
|
||
use super::base::coin; | ||
} | ||
|
||
pub mod registration { | ||
pub mod v1beta1 { | ||
pub mod msg; | ||
} | ||
} |
Oops, something went wrong.