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

Connect 4 nodes in block-producer, and create miden-node binary #85

Merged
merged 57 commits into from
Dec 12, 2023

Conversation

plafer
Copy link
Contributor

@plafer plafer commented Dec 6, 2023

Closes #17
Closes #42

Noteworthy changes/decisions:

  • store component now returns a default BlockHeader as the "genesis header"
  • genesis header uses timestamp = 0 (i.e. UNIX epoch)

@plafer plafer changed the title Start the node Connect 4 nodes in block-producer, and create miden-node binary Dec 7, 2023
Comment on lines 50 to 53
.map(|(account_id, account_hash)| AccountUpdate {
account_id: Some((*account_id).into()),
account_hash: Some(account_hash.into()),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestions:

should make the code a bit cleaner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed all of them to use convert, and created #99 to address the clones

Comment on lines +118 to +134
let nullifiers = {
let mut nullifiers = Vec::new();

for nullifier_record in response.nullifiers {
let nullifier = nullifier_record
.nullifier
.ok_or(TxInputsError::MalformedResponse(
"nullifier record contains empty nullifier".to_string(),
))?
.try_into()?;

// `block_num` is nonzero if already consumed; 0 otherwise
nullifiers.push((nullifier, nullifier_record.block_num != 0))
}

nullifiers.into_iter().collect()
};
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this can be replaced with try_convert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cannot use try_convert because I cannot implement TryFrom<NullifierTransactionInputRecord> for (RpoDigest, bool) where Error = TxInputsError, since TxInputsError lives in miden-node-block-producer (and our conversion code lives in miden-node-proto).

Related: #74 (comment)

hackaugusto and others added 6 commits December 11, 2023 15:16
`deadpool`'s method `interact` is blocking, it waits for the closure to
complete its execution before returning. This causes a deadlock, because
of the way state synchronization is performed in the store server.

In the store, the transaction is opened and data is written to the WAL
file, but not immedially committed. Before comiting the data, the
in-memory datastructures prevent read operations. This meanst the server
has to acquire the exclusive write lock. This operation demands
concurrency and synchronization among the DB and state components. This
required a change from a blocking to a concurrent API.

`deadpool` doesn't seem to have a native concurrent API, so a async task
was used instead. `tokio` does not support scoped tasks, so thread local
state can not be used across tasks, for this reason all the data was
modified from being borrowed to being owned, so that the data can be
moved in to the async task.
@plafer plafer marked this pull request as ready for review December 11, 2023 17:36
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left a few comments inline - most of them are pretty small.

block-producer/src/lib.rs Outdated Show resolved Hide resolved
rpc/src/lib.rs Outdated Show resolved Hide resolved
store/src/lib.rs Outdated Show resolved Hide resolved
block-producer/src/block_builder/mod.rs Outdated Show resolved Hide resolved
block-producer/src/block_builder/mod.rs Show resolved Hide resolved
node/Cargo.toml Outdated Show resolved Hide resolved
node/Cargo.toml Outdated Show resolved Hide resolved
block-producer/src/server/api.rs Outdated Show resolved Hide resolved
block-producer/src/server/api.rs Outdated Show resolved Hide resolved
block-producer/src/server/api.rs Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left just one minor nit inline.

Comment on lines 35 to 56
/// The depth of the SMT for created notes
pub(crate) const CREATED_NOTES_SMT_DEPTH: u8 = 13;

/// The maximum number of created notes per batch.
///
/// The created notes tree uses an extra depth to store the 2 components of `NoteEnvelope`.
/// That is, conceptually, notes sit at depth 12; where in reality, depth 12 contains the
/// hash of level 13, where both the `note_hash()` and metadata are stored (one per node).
pub(crate) const MAX_NUM_CREATED_NOTES_PER_BATCH: usize =
2_usize.pow((CREATED_NOTES_SMT_DEPTH - 1) as u32);

/// The number of transactions per batch
pub(crate) const SERVER_BATCH_SIZE: usize = 2;

/// The frequency at which blocks are produced
pub(crate) const SERVER_BLOCK_FREQUENCY: Duration = Duration::from_secs(10);

/// The frequency at which batches are built
pub(crate) const SERVER_BUILD_BATCH_FREQUENCY: Duration = Duration::from_secs(2);

/// Maximum number of batches per block
pub(crate) const SERVER_MAX_BATCHES_PER_BLOCK: usize = 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: since these are now in lib.rs, I think we should be able to get rid of pub(crate) modifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@plafer plafer merged commit 00b03af into main Dec 12, 2023
4 checks passed
@plafer plafer deleted the plafer-start-node branch December 12, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Txpool: implement driver which connects 4 main tasks Endpoint to receive client proven transactions
3 participants