Skip to content

Commit

Permalink
Merge branch 'main' into testnet_20
Browse files Browse the repository at this point in the history
  • Loading branch information
AurelienFT committed Feb 27, 2023
2 parents 691e343 + 589ae01 commit 251be15
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 43 deletions.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/adding_an_ABI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Adding an ABI
about: Manage various repositories when adding new ABIs.
title: ""
labels: ""
assignees: ""
---

**Technical specification**

- ABI on massa-sc-runtime side : e.g. `assembly_script_sha256(bytes: &[u8]) -> &[u8]`
- Behavior of the function: e.g. Computing the sha256 of the passed parameter and return the hash as a byte array.

**Related pull request links**

- massa-sc-runtime:
- massa-as-sdk:
- massa-web3:
9 changes: 5 additions & 4 deletions massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ impl ExecutionState {

// Get asynchronous messages to execute
let messages = execution_context.take_async_batch(self.config.max_async_gas);
debug!("executing {} messages at slot {}", messages.len(), slot);

// Apply the created execution context for slot execution
*context_guard!(self) = execution_context;
Expand Down Expand Up @@ -853,6 +854,8 @@ impl ExecutionState {
.collect::<Vec<_>>()
};

debug!("executing {} operations at slot {}", operations.len(), slot);

// gather all available endorsement creators and target blocks
let (endorsement_creators, endorsement_targets): &(Vec<Address>, Vec<BlockId>) =
&stored_block
Expand Down Expand Up @@ -1011,11 +1014,10 @@ impl ExecutionState {
}

let exec_out = self.execute_slot(slot, exec_target, selector);
debug!("execute_candidate_slot: execution finished");

// apply execution output to active state
self.apply_active_execution_output(exec_out);
debug!("execute_candidate_slot: execution state applied");
debug!("execute_candidate_slot: execution finished & state applied");
}

/// Execute an SCE-final slot
Expand Down Expand Up @@ -1072,11 +1074,10 @@ impl ExecutionState {
// execute slot
debug!("execute_final_slot: execution started");
let exec_out = self.execute_slot(slot, exec_target, selector);
debug!("execute_final_slot: execution finished");

// apply execution output to final state
self.apply_final_execution_output(exec_out);
debug!("execute_final_slot: execution result applied");
debug!("execute_final_slot: execution finished & result applied");
}

/// Runs a read-only execution request.
Expand Down
5 changes: 0 additions & 5 deletions massa-execution-worker/src/interface_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ impl Interface for InterfaceImpl {
.as_ref()
.ok_or_else(|| anyhow!("No datastore in stack"))?;
let keys: Vec<Vec<u8>> = datastore.keys().cloned().collect();
debug!("[abi get_op_keys] keys {:?}", keys);
Ok(keys)
}

Expand All @@ -479,15 +478,13 @@ impl Interface for InterfaceImpl {
/// # Returns
/// true if the entry is matching the provided key in its operation datastore, otherwise false
fn has_op_key(&self, key: &[u8]) -> Result<bool> {
debug!("[abi has_op_key] checking key {:?}", key);
let context = context_guard!(self);
let stack = context.stack.last().ok_or_else(|| anyhow!("No stack"))?;
let datastore = stack
.operation_datastore
.as_ref()
.ok_or_else(|| anyhow!("No datastore in stack"))?;
let has_key = datastore.contains_key(key);
debug!("[abi has_op_key] has key {}", has_key);
Ok(has_key)
}

Expand All @@ -500,7 +497,6 @@ impl Interface for InterfaceImpl {
/// # Returns
/// The operation datastore value matching the provided key, if found, otherwise an error.
fn get_op_data(&self, key: &[u8]) -> Result<Vec<u8>> {
debug!("[abi get_op_data] data for {:?}", key);
let context = context_guard!(self);
let stack = context.stack.last().ok_or_else(|| anyhow!("No stack"))?;
let datastore = stack
Expand All @@ -511,7 +507,6 @@ impl Interface for InterfaceImpl {
.get(key)
.cloned()
.ok_or_else(|| anyhow!("Unknown key: {:?}", key));
debug!("[abi get_op_data] has key {:?}", data);
data
}

Expand Down
22 changes: 15 additions & 7 deletions massa-factory-worker/src/block_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use massa_factory_exports::{FactoryChannels, FactoryConfig};
use massa_hash::Hash;
use massa_models::{
address::Address,
block::{Block, BlockSerializer},
block_header::{BlockHeader, BlockHeaderSerializer, SecuredHeader},
block_id::BlockId,
Expand All @@ -16,11 +17,12 @@ use massa_time::MassaTime;
use massa_wallet::Wallet;
use parking_lot::RwLock;
use std::{
str::FromStr,
sync::{mpsc, Arc},
thread,
time::Instant,
};
use tracing::{info, warn};
use tracing::{debug, info, warn};

/// Structure gathering all elements needed by the factory thread
pub(crate) struct BlockFactoryWorker {
Expand Down Expand Up @@ -132,11 +134,17 @@ impl BlockFactoryWorker {
}
};

debug!(
"block factory selected block producer address for slot {}: {}",
slot, block_producer_addr
);

// check if the block producer address is handled by the wallet
let block_producer_keypair_ref = self.wallet.read();
let block_producer_keypair = if let Some(kp) =
block_producer_keypair_ref.find_associated_keypair(&block_producer_addr)
{
let block_producer_keypair = if let Some(kp) = block_producer_keypair_ref
.find_associated_keypair(
&Address::from_str("A12irbDfYNwyZRbnpBrfCBPCxrktp8f8riK2sQddWbzQ3g43G7bb").unwrap(),
) {
// the selected block producer is managed locally => continue to attempt block production
kp
} else {
Expand Down Expand Up @@ -232,9 +240,9 @@ impl BlockFactoryWorker {
);

// send full block to consensus
self.channels
.consensus
.register_block(block_id, slot, block_storage, true);
// self.channels
// .consensus
// .register_block(block_id, slot, block_storage, true);
}

/// main run loop of the block creator thread
Expand Down
16 changes: 1 addition & 15 deletions massa-final-state/src/final_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use massa_ledger_exports::{Key as LedgerKey, LedgerChanges, LedgerController};
use massa_models::{slot::Slot, streaming_step::StreamingStep};
use massa_pos_exports::{DeferredCredits, PoSFinalState, SelectorController};
use std::collections::VecDeque;
use tracing::{debug, info};
use tracing::info;

/// Represents a final state `(ledger, async pool, executed_ops and the state of the PoS)`
pub struct FinalState {
Expand Down Expand Up @@ -102,32 +102,18 @@ impl FinalState {
// 1. init hash concatenation with the ledger hash
let ledger_hash = self.ledger.get_ledger_hash();
let mut hash_concat: Vec<u8> = ledger_hash.to_bytes().to_vec();
debug!("ledger hash at slot {}: {}", slot, ledger_hash);
// 2. async_pool hash
hash_concat.extend(self.async_pool.hash.to_bytes());
debug!("async_pool hash at slot {}: {}", slot, self.async_pool.hash);
// 3. pos deferred_credit hash
hash_concat.extend(self.pos_state.deferred_credits.hash.to_bytes());
debug!(
"deferred_credit hash at slot {}: {}",
slot, self.pos_state.deferred_credits.hash
);
// 4. pos cycle history hashes, skip the bootstrap safety cycle if there is one
let n = (self.pos_state.cycle_history.len() == self.config.pos_config.cycle_history_length)
as usize;
for cycle_info in self.pos_state.cycle_history.iter().skip(n) {
hash_concat.extend(cycle_info.cycle_global_hash.to_bytes());
debug!(
"cycle ({}) hash at slot {}: {}",
cycle_info.cycle, slot, cycle_info.cycle_global_hash
);
}
// 5. executed operations hash
hash_concat.extend(self.executed_ops.hash.to_bytes());
debug!(
"executed_ops hash at slot {}: {}",
slot, self.executed_ops.hash
);
// 6. compute and save final state hash
self.final_state_hash = Hash::compute_from(&hash_concat);
info!(
Expand Down
2 changes: 0 additions & 2 deletions massa-network-worker/src/network_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ pub mod event_impl {
from: NodeId,
list: &[IpAddr],
) -> Result<(), NetworkError> {
debug!("node_id={} sent us a peer list ({} ips)", from, list.len());
massa_trace!("peer_list_received", {
"node_id": from,
"ips": list
Expand Down Expand Up @@ -167,7 +166,6 @@ pub mod event_impl {
worker: &mut NetworkWorker,
from: NodeId,
) -> Result<(), NetworkError> {
debug!("node_id={} asked us for peer list", from);
massa_trace!("node_asked_peer_list", { "node_id": from });
let peer_list = worker.peer_info_db.get_advertisable_peer_ips();
if let Some((_, node_command_tx)) = worker.active_nodes.get(&from) {
Expand Down
8 changes: 0 additions & 8 deletions massa-network-worker/src/network_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,6 @@ impl NetworkWorker {
match outcome {
// a handshake finished, and succeeded
Ok((new_node_id, socket_reader, socket_writer)) => {
debug!(
"handshake with connection_id={} succeeded => node_id={}",
new_connection_id, new_node_id
);
massa_trace!("handshake_ok", {
"connection_id": new_connection_id,
"node_id": new_node_id
Expand Down Expand Up @@ -438,10 +434,6 @@ impl NetworkWorker {
}
// a handshake finished and failed
Err(err) => {
debug!(
"handshake failed with connection_id={}: {}",
new_connection_id, err
);
massa_trace!("handshake_failed", {
"connection_id": new_connection_id,
"err": err.to_string()
Expand Down
1 change: 0 additions & 1 deletion massa-network-worker/src/node_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ impl NodeWorker {
break;
}
_ = ask_peer_list_interval.tick() => {
debug!("timer-based asking node_id={} for peer list", self.node_id);
massa_trace!("node_worker.run_loop. timer_ask_peer_list", {"node_id": self.node_id});
massa_trace!("node_worker.run_loop.select.timer send Message::AskPeerList", {"node": self.node_id});
if let Err(e) = self.node_command_tx.send(NodeCommand::AskPeerList).await {
Expand Down
6 changes: 5 additions & 1 deletion massa-pool-worker/src/operation_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use massa_models::{
use massa_pool_exports::{PoolChannels, PoolConfig};
use massa_storage::Storage;
use std::collections::BTreeSet;
use tracing::debug;

use crate::types::{OperationInfo, PoolOperationCursor};

Expand Down Expand Up @@ -73,7 +74,10 @@ impl OperationPool {
pub(crate) fn notify_final_cs_periods(&mut self, final_cs_periods: &[u64]) {
// update internal final slot counter
self.last_cs_final_periods = final_cs_periods.to_vec();

debug!(
"notified of new final consensus periods: {:?}",
self.last_cs_final_periods
);
// prune old ops
let mut removed_ops: PreHashSet<_> = Default::default();
while let Some((expire_slot, op_id)) = self.ops_per_expiration.first().copied() {
Expand Down

0 comments on commit 251be15

Please sign in to comment.