Skip to content

Conversation

@kantai
Copy link
Contributor

@kantai kantai commented Oct 17, 2023

This PR implements a first version of mockamoto. It has several deficiencies at the moment, but those could be sorted in separate PRs (which is, perhaps, an argument for leaving those to a separate PR):

  1. It does not use the chain coordinator. This is pretty intentional, because I didn't want this entry-point to be dependent on the ongoing coordinator work. An update to use the chain coordinator (once that supports nakamoto) would be to simply insert mock data into the burnchain db rather than the sortition db (as this PR does).
  2. It does not mine transactions from the mempool: it just produces empty-ish blocks. There isn't really a hard problem to solve here, it's just a matter of doing the work of factoring the mempool iteration logic in the miner module into something that could be invoked by the mockamoto mining method.
  3. It only produces blocks that undergo tenure changes.
  4. The p2p stack doesn't use the new canonical chain tip lookup methods, so they will return incorrect stack tip information.

If those don't get covered by this PR, I'll open issues for them.

This is still a draft because right now, there's no associated unit tests -- it may also be worthwhile to just include some of the above features in this PR.

@codecov
Copy link

codecov bot commented Oct 17, 2023

Codecov Report

Merging #4001 (487126a) into next (e985b17) will decrease coverage by 0.01%.
Report is 3 commits behind head on next.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             next    #4001      +/-   ##
==========================================
- Coverage    0.16%    0.16%   -0.01%     
==========================================
  Files         350      351       +1     
  Lines      292190   292666     +476     
==========================================
  Hits          469      469              
- Misses     291721   292197     +476     
Files Coverage Δ
stackslib/src/chainstate/stacks/mod.rs 0.00% <ø> (ø)
stackslib/src/chainstate/stacks/db/accounts.rs 0.00% <0.00%> (ø)
stackslib/src/chainstate/stacks/db/blocks.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/main.rs 0.00% <0.00%> (ø)
stackslib/src/chainstate/stacks/transaction.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/neon_node.rs 0.00% <0.00%> (ø)
stackslib/src/clarity_vm/clarity.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/config.rs 0.00% <0.00%> (ø)
stackslib/src/chainstate/nakamoto/mod.rs 0.00% <0.00%> (ø)
testnet/stacks-node/src/mockamoto.rs 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zone117x
Copy link
Contributor

It only produces blocks that undergo tenure changes.

Does this mean the blocks include the new TenureChange transaction type? If so then would you recommend using this PR as a mocknet node in the API to start integrating the new tx type(s)?

@kantai
Copy link
Contributor Author

kantai commented Oct 25, 2023

Does this mean the blocks include the new TenureChange transaction type? If so then would you recommend using this PR as a mocknet node in the API to start integrating the new tx type(s)?

Yes, it does include the new transaction type. Once the mocknet node integrates with the chain coordinator work (which this PR doesn't yet), then yeah, the mocknet node is a good place to start integrating the new tx type. Until then, it won't emit events (events are emitted by the chain coordinator).

@saralab saralab requested review from jcnelson and obycode October 28, 2023 14:48
@saralab
Copy link
Contributor

saralab commented Oct 28, 2023

@kantai : Is this still a draft? Can I request reviews?

@kantai kantai changed the title DRAFT: initial implementation of mockamoto stack-node mode Initial implementation of mockamoto stack-node mode Oct 30, 2023
@kantai
Copy link
Contributor Author

kantai commented Oct 30, 2023

Yes its ready for reviews. This PR is ultimately pretty minor and will just be a good place for merging in the work from Jude's coordinator PR.

@muneeb-ali
Copy link
Member

Would having more reviewers help or is that not a bottleneck right now? I understand that only people currently on the Nakamoto WG are probably best for reviewing but just wondering if reviewing is something that needs more attention or not.

Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

Just had a couple of requests for added comments for clarity, but it looks great!

let coinbase_tx = coinbase_tx_signer.get_tx().unwrap();

let parent_block_id = StacksBlockId::new(&chain_tip_ch, &chain_tip_bh);
let tenure_change_tx_payload = TransactionPayload::TenureChange(TenureChangePayload {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here? I guess you're just including a tenure change in every block to test some more paths?

Ok(new_snapshot)
}

pub struct MockamotoNode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment on this struct, or a top-level commenting explaining what Mockamoto does and why it is useful? It doesn't need to be anything to complicated, since this is just temporary, but I think this will be helpful for others using it during development.

clarity_instance: &'a mut ClarityInstance,
sortition_dbconn: &'b dyn SortitionDBRef,
pox_constants: &PoxConstants,
chain_tip: &StacksHeaderInfo,
Copy link
Member

Choose a reason for hiding this comment

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

Can you help me understand why replacing chain_tip with parent_stacks_height and parent_burn_height is required? This seems needless to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It reduces the amount that needs to be mocked: the chain_tip argument is only used for obtaining the parent stacks height and parent burn height (for epoch checks, mostly). It also makes writing unit tests easier. An argument like chain_tip which includes a bunch of information that the function doesn't use confuses the interface.

Copy link
Member

@jcnelson jcnelson left a comment

Choose a reason for hiding this comment

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

Approving this to move things along, but please re-consider the change to setup_block's arguments.

@kantai kantai changed the base branch from feat/nakoordinator to next October 31, 2023 20:20
@kantai
Copy link
Contributor Author

kantai commented Nov 1, 2023

Merging -- if we want to change the setup_block interface back to accepting a StacksHeaderInfo struct, we can always do that later.

@kantai kantai merged commit d044e1b into next Nov 1, 2023
@blockstack-devops
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 9, 2024
@wileyj wileyj deleted the feat/mock-node branch March 11, 2025 21:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants