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

Changing log levels a bit to make running localsecret easier to parse #950

Merged
merged 2 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn init(

let validated_msg = validate_msg(&decrypted_msg, contract_code.hash())?;

trace!(
info!(
"Init input after decryption: {:?}",
String::from_utf8_lossy(&validated_msg)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub fn validate_contract_key(
let enclave_key = KEY_MANAGER
.get_consensus_state_ikm()
.map_err(|_err| {
warn!("Error extracting consensus_state_key");
error!("Error extracting consensus_state_key");
false
})
.unwrap();
Expand Down Expand Up @@ -160,7 +160,7 @@ pub fn verify_params(
env: &Env,
msg: &SecretMessage,
) -> Result<(), EnclaveError> {
info!("Verifying message signatures for: {:?}", sig_info);
debug!("Verifying message signatures for: {:?}", sig_info);

// If there's no callback signature - it's not a callback and there has to be a tx signer + signature
if let Some(callback_sig) = &sig_info.callback_sig {
Expand Down Expand Up @@ -284,7 +284,7 @@ fn verify_callback_sig(
msg,
sent_funds,
) {
info!("Message verified! msg.sender is the calling contract");
debug!("Message verified! msg.sender is the calling contract");
return Ok(());
}

Expand Down Expand Up @@ -337,7 +337,7 @@ fn verify_contract(msg: &CosmWasmMsg, env: &Env) -> bool {
// Contract address is relevant only to execute, since during sending an instantiate message the contract address is not yet known
match msg {
CosmWasmMsg::Execute { contract, .. } => {
info!("Verifying contract address..");
debug!("Verifying contract address..");
let is_verified = env.contract.address == *contract;
if !is_verified {
trace!(
Expand Down Expand Up @@ -371,7 +371,7 @@ fn verify_message_params(
signer_public_key: &CosmosPubKey,
sent_msg: &SecretMessage,
) -> bool {
info!("Verifying sender..");
debug!("Verifying sender..");

let msg_sender = match CanonicalAddr::from_human(&env.message.sender) {
Ok(msg_sender) => msg_sender,
Expand All @@ -394,7 +394,7 @@ fn verify_message_params(
// since it didn't find a matching signed message
let msg = get_verified_msg(messages, &msg_sender, sent_msg);
if msg.is_none() {
warn!("Message verification failed!");
debug!("Message verification failed!");
trace!(
"Message sent to contract {:?} by {:?} does not match any signed messages {:?}",
sent_msg.to_vec(),
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/shared/contract-engine/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub fn write_encrypted_key(

let scrambled_field_name = field_name_digest(key, contract_key);

info!(
debug!(
"Writing to scrambled field name: {:?}",
scrambled_field_name
);
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/enclaves/shared/contract-engine/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub fn encrypt_output(
) -> Result<Vec<u8>, EnclaveError> {
let key = calc_encryption_key(&nonce, &user_public_key);

trace!(
info!(
"Output before encryption: {:?}",
String::from_utf8_lossy(&output)
);
Expand Down
12 changes: 6 additions & 6 deletions cosmwasm/enclaves/shared/contract-engine/src/module_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,20 @@ fn compile_module(
code: &[u8],
operation: ContractOperation,
) -> Result<wasmi::Module, EnclaveError> {
info!("Deserializing Wasm contract");
debug!("Deserializing Wasm contract");

// Create a parity-wasm module first, so we can inject gas metering to it
// (you need a parity-wasm module to use the pwasm-utils crate)
let mut p_modlue: Module =
elements::deserialize_buffer(code).map_err(|_| EnclaveError::InvalidWasm)?;

info!("Deserialized Wasm contract");
debug!("Deserialized Wasm contract");

info!("Validating WASM memory demands");
debug!("Validating WASM memory demands");

validate_memory(&mut p_modlue)?;

info!("Validated WASM memory demands");
debug!("Validated WASM memory demands");

// Set the gas costs for wasm op-codes (there is an inline stack_height limit in WasmCosts)
let wasm_costs = WasmCosts::default();
Expand All @@ -114,13 +114,13 @@ fn compile_module(
let contract_module = pwasm_utils::inject_gas_counter(p_modlue, &gas_rules(&wasm_costs))
.map_err(|_| EnclaveError::FailedGasMeteringInjection)?;

info!("Trying to create Wasmi module from parity...");
debug!("Trying to create Wasmi module from parity...");

// Create a wasmi module from the parity module
let module = wasmi::Module::from_parity_wasm_module(contract_module)
.map_err(|_err| EnclaveError::InvalidWasm)?;

info!("Created Wasmi module from parity. Now checking for floating points...");
debug!("Created Wasmi module from parity. Now checking for floating points...");

// Skip the floating point check in queries and handles.
// We know that the contract must be valid at this point,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ impl WasmiApi for ContractInstance {
self.gas_left(),
)?;

trace!(
"query_chain() got answer from outside with gas {} and result {:?}",
info!(
"query_chain() got answer from chain. Gas used: {}. Result: {:?}",
gas_used,
String::from_utf8_lossy(&answer)
);
Expand Down
6 changes: 3 additions & 3 deletions cosmwasm/enclaves/shared/contract-engine/src/wasm/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Engine {
}

pub fn init(&mut self, env_ptr: u32, msg_ptr: u32) -> Result<u32, EnclaveError> {
info!("Invoking init() in wasm");
info!("Invoking contract init");

match self
.module
Expand Down Expand Up @@ -73,7 +73,7 @@ impl Engine {
}

pub fn handle(&mut self, env_ptr: u32, msg_ptr: u32) -> Result<u32, EnclaveError> {
info!("Invoking handle() in wasm");
info!("Invoking contract handle");

// Itzik: leaving this here as an example in case we will want to do something like this in the future

Expand Down Expand Up @@ -122,7 +122,7 @@ impl Engine {
}

pub fn query(&mut self, msg_ptr: u32) -> Result<u32, EnclaveError> {
info!("Invoking query() in wasm");
info!("Invoking contract query");

match self
.module
Expand Down
3 changes: 2 additions & 1 deletion deployment/docker/devimage/bootstrap_init_no_stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ then
cp ~/node_key.json ~/.secretd/config/node_key.json
perl -i -pe 's/"stake"/"uscrt"/g' ~/.secretd/config/genesis.json
perl -i -pe 's/"172800s"/"90s"/g' ~/.secretd/config/genesis.json # voting period 2 days -> 90 seconds
perl -i -pe 's/"1814400s"/"80s"/g' ~/.secretd/config/genesis.json # voting period 2 days -> 90 seconds

perl -i -pe 's/enable-unsafe-cors = false/enable-unsafe-cors = true/g' ~/.secretd/config/app.toml # enable cors

Expand Down Expand Up @@ -70,5 +71,5 @@ gunicorn --bind 0.0.0.0:5000 svc &
# Setup secretcli
cp $(which secretd) $(dirname $(which secretd))/secretcli

source /opt/sgxsdk/environment && RUST_BACKTRACE=1 secretd start --rpc.laddr tcp://0.0.0.0:26657 --bootstrap
source /opt/sgxsdk/environment && RUST_BACKTRACE=1 LOG_LEVEL=INFO secretd start --rpc.laddr tcp://0.0.0.0:26657 --bootstrap

3 changes: 3 additions & 0 deletions deployment/docker/local/bootstrap_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ then
cp ~/node_key.json ~/.secretd/config/node_key.json

perl -i -pe 's/"stake"/"uscrt"/g' ~/.secretd/config/genesis.json

perl -i -pe 's/"1814400s"/"80s"/g' ~/.secretd/config/genesis.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool


secretcli keys add a
secretcli keys add b
secretcli keys add c
Expand Down