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/tenure change validation #4114

Merged
merged 45 commits into from
Dec 12, 2023
Merged

Feat/tenure change validation #4114

merged 45 commits into from
Dec 12, 2023

Conversation

jcnelson
Copy link
Member

@jcnelson jcnelson commented Dec 1, 2023

This PR addresses #4014 by way of #4053. Tenure-change transactions are now fully validated. In particular:

  • Tenures can now span multiple sortitions if there was no new miner chosen
  • Nakamoto can keep making blocks even if a miner does not produce any blocks in its sortition
  • Tenures can have their runtime budgets extended

Leaving as a draft for now so I can add more unit tests and let CI run on the existing ones.

@jcnelson jcnelson marked this pull request as ready for review December 1, 2023 20:31
@jcnelson jcnelson marked this pull request as draft December 1, 2023 20:31
@jcnelson
Copy link
Member Author

jcnelson commented Dec 1, 2023

Not sure why but CI does not want to run.

Copy link
Collaborator

@xoloki xoloki left a comment

Choose a reason for hiding this comment

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

Minor comments about crypto libs and little things, but LGTM. However I'm not well versed in this code.

stacks-common/src/types/chainstate.rs Outdated Show resolved Hide resolved
stacks-common/src/util/secp256k1.rs Outdated Show resolved Hide resolved
@@ -156,6 +157,7 @@ impl From<&WSTSSignature> for SchnorrSignature {
SchnorrSignature(buf)
}
}
*/

impl Secp256k1PublicKey {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally we'd also move away from other libsecp256k1 wrappers. p256k1 wraps everything, including public keys, ecdsa/schnorr sigs, etc.

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.

Have a few comments. Most are superficial, but there's a handful that I think merit some discussion.

stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Show resolved Hide resolved
stackslib/src/chainstate/stacks/db/transactions.rs Outdated Show resolved Hide resolved
stackslib/src/clarity_vm/clarity.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jbencin jbencin left a comment

Choose a reason for hiding this comment

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

Made some comments, minor stuff. I'll let Aaron give the second approval though because I'm not confident that I understand all the details here

stackslib/src/chainstate/nakamoto/mod.rs Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
stackslib/src/chainstate/nakamoto/mod.rs Outdated Show resolved Hide resolved
parent_microblocks_cost: ExecutionCost::zero(),
anchored_block_cost: block_execution_cost,
parent_burn_block_hash,
parent_burn_block_height,
parent_burn_block_height: u32::try_from(parent_burn_block_height).unwrap_or(0), // shouldn't be fatal
Copy link
Contributor

Choose a reason for hiding this comment

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

If parent_burn_block_height is to large for u32 should it default to u32::MAX?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted the error to be very obvious

@jcnelson jcnelson marked this pull request as ready for review December 7, 2023 14:50
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 looks good to me, I just had a few comments which are mostly superficial. This PR also currently breaks the stacks-node target, so that must be fixed before it can be approved.

$ cargo check
...
error: could not compile `stacks-node` (bin "stacks-node") due to 7 previous errors; 2 warnings emitted

@jcnelson jcnelson requested review from kantai and jbencin December 8, 2023 17:32
@@ -118,45 +118,6 @@ impl Default for Secp256k1PublicKey {
}
}

pub struct SchnorrSignature(pub [u8; 65]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really nice to see this go XD Didn't like it in there to begin with.

…o return the height, and add a backwards-compatible wrapper. In addition, add a test method for setting the canonical tip
assert_eq!(matured_reward.parent_miner.coinbase, 1000_000_000);
}

if i < 11 {
Copy link
Collaborator

@jferrant jferrant Dec 11, 2023

Choose a reason for hiding this comment

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

Super nit especially since in a test, but this would be clearer to me with a match on a std::cmp
Like so

    match i.cmp(&11) {
        Ordering::Less => {...},
        Ordering::Greater => {...},
        Ordering::Equal => {...},
    }

} else {
assert_eq!(miner_reward.coinbase, 1000_000_000);
}
if i < 10 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar to above comment.

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, thanks for the changes!

@jcnelson jcnelson merged commit 58e15c8 into next Dec 12, 2023
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 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants