Skip to content

Commit

Permalink
Roll up 4-15-20 (#2)
Browse files Browse the repository at this point in the history
* introduce mc-grpc-build and use it mobilecoind-api (#41)

* introduce mc-grpc-build and use it mobilecoind-api

* delete old autogenerated code

* build issue fix and comments

* grpc-build -> build-grpc

* comment and lock file

* readme and lock file

* use mcbuild-utils

* Propose Values in Slot (#16)

* Adds a status call to the Java client (#44)

* Adds transaction receipt and status checks to Java client

* Document parameters for status function

* Balance fix (#46)

* Client fixes

* Better error display

* Pep8

* Small fixups in mc-crypto-box README, per joey feedback (#45)

I tried to make the commentary about the user-provided nonce
more accurate as well

* Rewrite the README for digestible crate (#47)

* Rewrite the README for digestible crate

* Add another sentence

* Add another sentence about framing, after reading again

* Fix typo

* Update public/crypto/digestible/README.md

Co-Authored-By: sugargoat <[email protected]>

* Update public/crypto/digestible/README.md

Co-Authored-By: sugargoat <[email protected]>

* Update public/crypto/digestible/README.md

Co-Authored-By: sugargoat <[email protected]>

* Try to fix the sentences sarah commented on, fixup conclusion

Co-authored-by: sugargoat <[email protected]>

* Updates README for java client and a couple of minor fixes (#54)

* Fix missing check (#51)

* Fix missing check

* Speed up grpc install

* Better wording

* Update path for test network (#55)

* Update READMEs with sigstruct (#7)

* Update READMEs with sigstruct

* Add css info

* Add signed enclave info

* Remove aws

* Fix typo

* Remove privkey option and provide signed and css to consensus

* Add IAS_MODE to mobilecoind

Co-authored-by: Eran Rundstein <[email protected]>
Co-authored-by: Robb Walters <[email protected]>
Co-authored-by: tsegaran <[email protected]>
Co-authored-by: garbageslam <[email protected]>
  • Loading branch information
5 people authored Apr 15, 2020
1 parent eb6bf1c commit c6d940d
Show file tree
Hide file tree
Showing 16 changed files with 656 additions and 283 deletions.
8 changes: 4 additions & 4 deletions consensus/scp/play/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Notes:

## Usage with a Jenkins cloud deployed network

1. Log files are stored in `/home/deploybot/scp-debug-dump/<node id>`, e.g. `/home/deploybot/scp-debug-dump/node3.alpha.mobilecoin.com:8443/`.
1. You will need to SSH into the machine (as the `mobilecoin` user), and grab the logs: `sudo tar -czvf /home/mobilecoin/scp.tgz -C /home/deploybot/scp-debug-dump/ .`
1. From your machine, scp the files: `scp mobilecoin@node3.alpha.mobilecoin.com:~/scp.tgz .`
1. Extract the archive and run `scp_play` (inside `public/`): `MC_LOG=trace cargo run -p scp_play -- --scp-debug-dump /tmp/node3.alpha.mobilecoin.com:8443/`
1. Log files are stored in `$HOME/scp-debug-dump/<node id>`, e.g. `$HOME/scp-debug-dump/node3.test.mobilecoin.com:8443/`.
1. You will need to SSH into the machine (as the `mobilecoin` user), and grab the logs: `sudo tar -czvf /home/mobilecoin/scp.tgz -C $HOME/scp-debug-dump/ .`
1. From your machine, scp the files: `scp mobilecoin@node3.test.mobilecoin.com:~/scp.tgz .`
1. Extract the archive and run `scp_play` (inside `public/`): `MC_LOG=trace cargo run -p scp_play -- --scp-debug-dump /tmp/node3.test.mobilecoin.com:8443/`
105 changes: 60 additions & 45 deletions consensus/scp/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! A node determines whether transactions are valid, and participates in voting with the members of its quorum set.
use crate::{
core_types::{CombineFn, SlotIndex, ValidityFn, Value},
msg::{ExternalizePayload, Msg, NominatePayload, Topic},
msg::{ExternalizePayload, Msg, Topic},
quorum_set::QuorumSet,
slot::{Slot, SlotMetrics},
};
Expand Down Expand Up @@ -101,6 +101,33 @@ impl<V: Value, ValidationError: Display> Node<V, ValidationError> {
// Return slot.
self.pending.get_mut(&slot_index).unwrap()
}

fn externalize(
&mut self,
slot_index: SlotIndex,
payload: &ExternalizePayload<V>,
) -> Result<(), String> {
// Check for invalid values. This should be redundant, but may be helpful during development.
let mut externalized_invalid_values = false;
for value in &payload.C.X {
if let Err(e) = (self.validity_fn)(value) {
externalized_invalid_values = true;
log::error!(
self.logger,
"Slot {} externalized invalid value: {:?}, {}",
slot_index,
value,
e
);
}
}
if externalized_invalid_values {
return Err("Slot Externalized invalid values.".to_string());
}

self.externalized.put(slot_index, payload.clone());
Ok(())
}
}

/// A node capable of participating in SCP.
Expand Down Expand Up @@ -171,19 +198,31 @@ impl<V: Value, ValidationError: Display> ScpNode<V> for Node<V, ValidationError>
return Ok(None);
}

self.handle(&Msg::new(
self.ID.clone(),
self.Q.clone(),
slot_index,
Topic::Nominate(NominatePayload {
X: valid_values,
Y: Default::default(),
}),
))
let slot = self.get_or_create_pending_slot(slot_index);
let outbound = slot.propose_values(&valid_values)?;

match &outbound {
None => Ok(None),
Some(msg) => {
if let Topic::Externalize(ext_payload) = &msg.topic {
self.externalize(msg.slot_index, ext_payload)?;
}
Ok(outbound)
}
}
}

/// Handle incoming message from the network.
fn handle(&mut self, msg: &Msg<V>) -> Result<Option<Msg<V>>, String> {
if msg.sender_id == self.ID {
log::error!(
self.logger,
"node.handle received message from self: {:?}",
msg
);
return Ok(None);
}

// Log an error if another node Externalizes different values.
if let Topic::Externalize(received_externalized_payload) = &msg.topic {
if let Some(our_externalized_payload) = self.externalized.get(&msg.slot_index) {
Expand All @@ -204,24 +243,19 @@ impl<V: Value, ValidationError: Display> ScpNode<V> for Node<V, ValidationError>
}
}

// If the node messaged itself, it means someone called `.nominate()`. We always forward
// those messages down to the slot. If the message came from anywhere else, we'd only pass
// it down if we haven't seen it before.
if self.ID != msg.sender_id {
// Calculate message hash.
let serialized_msg = mcserial::serialize(&msg).expect("failed serializing msg");
let msg_hash = fast_hash(&serialized_msg);

// If we've already seen this message, we don't need to do anything.
// We use `get()` instead of `contains()` to update LRU state.
if self.seen_msg_hashes.get(&msg_hash).is_some() {
return Ok(None);
}
// Calculate message hash.
let serialized_msg = mcserial::serialize(&msg).expect("failed serializing msg");
let msg_hash = fast_hash(&serialized_msg);

// Store message so it doesn't get processed again.
self.seen_msg_hashes.put(msg_hash, ());
// If we've already seen this message, we don't need to do anything.
// We use `get()` instead of `contains()` to update LRU state.
if self.seen_msg_hashes.get(&msg_hash).is_some() {
return Ok(None);
}

// Store message so it doesn't get processed again.
self.seen_msg_hashes.put(msg_hash, ());

// Process message using the Slot.
let slot = self.get_or_create_pending_slot(msg.slot_index);
let outbound = slot.handle(msg)?;
Expand All @@ -230,27 +264,8 @@ impl<V: Value, ValidationError: Display> ScpNode<V> for Node<V, ValidationError>
None => Ok(None),
Some(msg) => {
if let Topic::Externalize(ext_payload) = &msg.topic {
let invalid_ext_values: Vec<(&V, String)> = ext_payload
.C
.X
.iter()
.map(|val| (val, (self.validity_fn)(val)))
.filter(|(_val, result)| result.is_err())
.map(|(val, result)| (val, result.unwrap_err().to_string()))
.collect();

if !invalid_ext_values.is_empty() {
let err = format!(
"Slot {} externalized invalid values! {:?}",
msg.slot_index, invalid_ext_values
);
log::error!(self.logger, "{}", err);
return Err(err);
} else {
self.externalized.put(msg.slot_index, ext_payload.clone());
}
self.externalize(msg.slot_index, ext_payload)?;
}

Ok(outbound)
}
}
Expand Down
Loading

0 comments on commit c6d940d

Please sign in to comment.