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

Feat/stackerdb miners contract #4188

Merged
merged 25 commits into from
Jan 9, 2024
Merged

Conversation

jcnelson
Copy link
Member

@jcnelson jcnelson commented Dec 18, 2023

Implements #4018, with the caveats listed in #4018 (namely, the .miners StackerDBConfig structure must be synthesized directly from chainstate due to a chicken-and-egg problem of needing .miners to reflect the latest sortition state before any blocks have been processed).

The code here is mostly complete and has some minimal unit tests. The following features need to be added:

  • The Nakamoto node needs to be upgraded to write its proposed block to the .miners contract. There's already a helper method in NakamotoBlockBuilder that will generate the chunk.

The following test coverage needs to be added:

  • A TestPeer-based unit test to verify that the StackerDBConfig for .miners is correctly synthesized after processing each Bitcoin block
  • See test_make_miners_stackerdb_config
  • A TestPeer-based unit test to verify that two nodes can be instantiated, which both track .miners, and a StackerDBChunkData post to one will show up on the other (i.e. this shows that StackerDB can propagate NakamotoBlocks for miners)
  • See miner_writes_proposed_block_to_stackerdb. Note this test does not have two nodes tracking miners but simply uses a stackerdb session to check that the block is found as expected in the appropriate slot. Does not bother to test stacker db propogation which is tested in other tests already. It also it not TestPeer based as the propose nakamoto block logic is found only within the Relayer for the neon node itself so really should be an integration test.
  • A Nakamoto integration test to ensure that the miner propagates the (unsigned) NakamotoBlock to the .miners contract
  • See above point.
    • Optional (can be a separate PR): test that the stacks signer receives the NakamotoBlock: will be done in another PR once stacks signer begins to process proposed blocks

As discussed earlier, I'm handing this off to @jferrant so I can focus on building out the Nakamoto p2p layer.

Closes #4018
Closes #3931

@jcnelson jcnelson requested review from kantai and jferrant December 18, 2023 22:33
@jcnelson jcnelson changed the base branch from master to next December 18, 2023 22:33
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

Attention: 218 lines in your changes are missing coverage. Please review.

Comparison is base (2285877) 83.01% compared to head (3cb02e0) 54.82%.

Files Patch % Lines
testnet/stacks-node/src/config.rs 60.38% 164 Missing ⚠️
stackslib/src/net/chat.rs 53.48% 20 Missing ⚠️
stackslib/src/net/stackerdb/mod.rs 81.08% 14 Missing ⚠️
testnet/stacks-node/src/nakamoto_node/miner.rs 79.48% 8 Missing ⚠️
stackslib/src/chainstate/nakamoto/mod.rs 96.47% 3 Missing ⚠️
stackslib/src/net/stackerdb/tests/sync.rs 50.00% 3 Missing ⚠️
testnet/stacks-node/src/neon_node.rs 89.47% 2 Missing ⚠️
...net/stacks-node/src/tests/nakamoto_integrations.rs 98.44% 2 Missing ⚠️
stackslib/src/chainstate/nakamoto/miner.rs 95.65% 1 Missing ⚠️
stackslib/src/net/stackerdb/tests/config.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             next    #4188       +/-   ##
===========================================
- Coverage   83.01%   54.82%   -28.20%     
===========================================
  Files         430      430               
  Lines      305627   304081     -1546     
===========================================
- Hits       253730   166699    -87031     
- Misses      51897   137382    +85485     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jferrant jferrant force-pushed the feat/stackerdb-miners-contract branch from 630fed8 to 2f34831 Compare December 19, 2023 19:05
Copy link
Member

@kantai kantai left a comment

Choose a reason for hiding this comment

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

This mostly LGTM, just a few comments and questions.

stackslib/src/chainstate/nakamoto/miner.rs Outdated Show resolved Hide resolved
stackslib/src/clarity_vm/clarity.rs Outdated Show resolved Hide resolved
stackslib/src/net/chat.rs Show resolved Hide resolved
stackslib/src/net/p2p.rs Outdated Show resolved Hide resolved
stackslib/src/net/p2p.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/tests/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/tests/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/tests/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/tests/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/tests/mod.rs Outdated Show resolved Hide resolved
@jferrant jferrant force-pushed the feat/stackerdb-miners-contract branch 8 times, most recently from 01bad91 to 8f78e89 Compare January 3, 2024 13:17
@jferrant jferrant marked this pull request as ready for review January 3, 2024 13:18
@jferrant jferrant force-pushed the feat/stackerdb-miners-contract branch from abbac79 to 2967c99 Compare January 3, 2024 14:42
@jferrant jferrant requested review from kantai and jferrant January 3, 2024 16:38
stackslib/src/net/mod.rs Outdated Show resolved Hide resolved
Copy link
Member Author

@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.

This overall LGTM. Thanks for taking it over @jferrant! Just a couple comments need to be addressed and then I'll approve.

@jferrant jferrant force-pushed the feat/stackerdb-miners-contract branch 2 times, most recently from 721fb8b to d9c3896 Compare January 8, 2024 15:57
jcnelson and others added 11 commits January 9, 2024 10:05
…lock

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
…s instance

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
…in view

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
…rivate key

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
…he block hash matches between observed and proposed blocks

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
@jferrant jferrant force-pushed the feat/stackerdb-miners-contract branch 2 times, most recently from eb8adb7 to c3d3884 Compare January 9, 2024 15:38
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
@jferrant jferrant force-pushed the feat/stackerdb-miners-contract branch from b4e3e33 to 4d111e4 Compare January 9, 2024 18:00
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Copy link
Member

@kantai kantai left a comment

Choose a reason for hiding this comment

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

Overall, LGTM, I just have one unresolved comment about the .miners contract. It seems like it doesn't actually need to exist, and would prefer to just remove it in that case.

@jcnelson
Copy link
Member Author

jcnelson commented Jan 9, 2024

Well, since I'm the one who opened it, I can't approve it, but LGTM. Thanks for carrying this over the finish line @jferrant! Just a couple comments to address before merging 🙏

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
@jferrant jferrant requested a review from kantai January 9, 2024 20:58
Copy link
Member

@kantai kantai left a comment

Choose a reason for hiding this comment

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

LGTM, appreciate you for getting this across the line @jferrant!

@jferrant jferrant merged commit 9b28e48 into next Jan 9, 2024
1 of 2 checks passed
@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 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
4 participants