Skip to content
Open
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
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM rust:1.70-slim-buster
RUN apt-get update -y && apt-get install git -y
RUN ls
RUN git clone \
https://github.com/puzzlehq/snarkos.git \
--depth 1
WORKDIR snarkos
RUN ["chmod", "+x", "build_ubuntu.sh"]
RUN ./build_ubuntu.sh
EXPOSE 5000/tcp
EXPOSE 3033/tcp
EXPOSE 4133/tcp
ENTRYPOINT ["./devnet.sh"]
9 changes: 9 additions & 0 deletions node/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,18 @@ impl<N: Network> Consensus<N> {

// Check that the transaction is not a fee transaction.
if transaction.is_fee() {
tracing::info!("\n\n Txn is a fee transaction, skipping tx: '{}'", fmt_id(transaction_id));
bail!("Transaction '{}' is a fee transaction {}", fmt_id(transaction_id), "(skipping)".dimmed());
}
// Check if the transaction was recently seen.
if self.seen_transactions.lock().put(transaction_id, ()).is_some() {
tracing::info!("\n\n Returning early, txn was already seen: '{}'", fmt_id(transaction_id));
// If the transaction was recently seen, return early.
return Ok(());
}
// Check if the transaction already exists in the ledger.
if self.ledger.contains_transmission(&TransmissionID::Transaction(transaction_id, checksum))? {
tracing::info!("\n\n Returning early, txn already exists in the ledger: '{}'", fmt_id(transaction_id));
bail!("Transaction '{}' exists in the ledger {}", fmt_id(transaction_id), "(skipping)".dimmed());
}
// Add the transaction to the memory pool.
Expand All @@ -396,6 +399,7 @@ impl<N: Network> Consensus<N> {
// If the memory pool of this node is full, return early.
let num_unconfirmed_transmissions = self.num_unconfirmed_transmissions();
if num_unconfirmed_transmissions >= Primary::<N>::MAX_TRANSMISSIONS_TOLERANCE {
tracing::info!("\n\n Returning early, node mem pool is full.");
return Ok(());
}
// Retrieve the transactions.
Expand Down Expand Up @@ -425,13 +429,18 @@ impl<N: Network> Consensus<N> {
// Iterate over the transactions.
for transaction in transactions.into_iter() {
let transaction_id = transaction.id();
tracing::info!("\n\n Adding the unconfirmed txn to the mem pool: '{}'", fmt_id(transaction_id));
trace!("Adding unconfirmed transaction '{}' to the memory pool...", fmt_id(transaction_id));
// Send the unconfirmed transaction to the primary.
if let Err(e) =
self.primary_sender().send_unconfirmed_transaction(transaction_id, Data::Object(transaction)).await
{
// If the BFT is synced, then log the warning.
if self.bft.is_synced() {
tracing::info!(
"\n\n BFT not synced, failed to add to the mempool the tx: '{}'",
fmt_id(transaction_id)
);
warn!(
"Failed to add unconfirmed transaction '{}' to the memory pool - {e}",
fmt_id(transaction_id)
Expand Down
3 changes: 3 additions & 0 deletions node/rest/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
) -> Result<ErasedJson, RestError> {
// Do not process the transaction if the node is too far behind.
if rest.routing.num_blocks_behind() > SYNC_LENIENCY {
tracing::info!("\n\n Node > 10 blocks behind, Tx not broadcasted: '{}'", fmt_id(tx.id()));
return Err(RestError(format!("Unable to broadcast transaction '{}' (node is syncing)", fmt_id(tx.id()))));
}

Expand All @@ -376,12 +377,14 @@ impl<N: Network, C: ConsensusStorage<N>, R: Routing<N>> Rest<N, C, R> {
// TODO: Should this be a blocking task?
let buffer = Vec::with_capacity(3000);
if tx.write_le(LimitedWriter::new(buffer, N::MAX_TRANSACTION_SIZE)).is_err() {
tracing::info!("\n\n Txn size exceeds the byte limit: '{}'", fmt_id(tx.id()));
return Err(RestError("Transaction size exceeds the byte limit".to_string()));
}

// If the consensus module is enabled, add the unconfirmed transaction to the memory pool.
if let Some(consensus) = rest.consensus {
// Add the unconfirmed transaction to the memory pool.
tracing::info!("\n\n Adding unconfirmed transaction to the mem pool: '{}'", fmt_id(tx.id()));
consensus.add_unconfirmed_transaction(tx.clone()).await?;
}

Expand Down