-
Notifications
You must be signed in to change notification settings - Fork 697
Feat/tenure change validation #4114
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
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
ab8a906
chore: getters for previous mock miner's block-commits and blocks
jcnelson 4348679
refactor: use new matured miner reward struct
jcnelson 7e47dfa
feat: implement full tenure-change validation by tracking highest-pro…
jcnelson 948595c
testing: expand unit testing for tenure-start block validation, coinb…
jcnelson 13b0f1b
testing: require nodes to begin Nakamoto off of an epoch2 block, and …
jcnelson bf865d4
chore: sync with tenure-change struct
jcnelson b753a7c
feat: add support for tenure budget extension
jcnelson 60fee44
feat: tenure-changes identify current and previous tenures by consens…
jcnelson 3a700cb
testing: find the last anchored block in the mock miner even if it's …
jcnelson a0386c2
chore: try_as_tenure_change()
jcnelson 461b282
chore: add reset_cost() function for tenure-change budget extension
jcnelson ad1f178
chore: log block rejection
jcnelson a276e50
chore: tenure-change requires prev_consensus_hash
jcnelson 690fcdc
Merge branch 'next' into feat/tenure-change-validation
jcnelson 5f92195
fix: workspace dependency
jcnelson d650b72
chore: remove commented-out code
jcnelson 38af405
chore: cargo fmt
jcnelson e1283ef
testing: return the snapshots created in a fork run
jcnelson 63b2039
testing: expand test coverage over more NakamotoChainState methods, a…
jcnelson 2fe8fb3
chore: alter the Nakamoto block miner so it just takes the coinbase a…
jcnelson 0d8b1d3
feat: flesh out tenure-extension handling, and also, move all tenure-…
jcnelson 5139cf6
feat: test that the query to find the highest tenure works even if th…
jcnelson 6e34e3b
chore: refactor test code so that the caller supplies the tenure-chan…
jcnelson 76009a9
chore: API sync
jcnelson 158f58f
chore: don't reset execution cost in response to a tx
jcnelson 071fd3b
chore: require a tenure-change tx in addition to a coinbase
jcnelson c46c776
feat: derive tenure extension from a tenure change
jcnelson 259f481
chore: API sync
jcnelson cddf031
chore: don't allow a transaction to reset the runtime cost
jcnelson 48e6b00
chore: need &mut for sortition handle
jcnelson aa9cbb7
feat: move all tenure-control logic into its own file
jcnelson f23694d
Merge branch 'next' into feat/tenure-change-validation
jcnelson 37e134b
chore: address PR feedback and get testnet to build
jcnelson 3f02431
Merge branch 'next' into feat/tenure-change-validation
jcnelson 8155592
chore: extend SortitionDB::get_canonical_stacks_tip_block_hash to als…
jcnelson ded3b54
chore: modify tests to work with new NakamotoChainState::get_highest_…
jcnelson 863ae14
chore: pull forward canonical block header pointer
jcnelson 5dfbb25
chore: API sync
jcnelson 6934d7d
chore: remove dead code
jcnelson e52e570
chore: query highest tenure from memoized canonical stacks chain tip
jcnelson 375db58
fix: get fork test to work with new highest-tenure query
jcnelson 0b835e0
Merge branch 'feat/tenure-change-validation' of https://github.com/st…
jcnelson 221b4ba
Merge branch 'next' into feat/tenure-change-validation
jcnelson 6ef458f
Merge branch 'next' into feat/tenure-change-validation
jcnelson f751c40
Merge branch 'next' into feat/tenure-change-validation
jcnelson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,45 +118,6 @@ impl Default for Secp256k1PublicKey { | |
} | ||
} | ||
|
||
pub struct SchnorrSignature(pub [u8; 65]); | ||
impl_array_newtype!(SchnorrSignature, u8, 65); | ||
impl_array_hexstring_fmt!(SchnorrSignature); | ||
impl_byte_array_newtype!(SchnorrSignature, u8, 65); | ||
impl_byte_array_serde!(SchnorrSignature); | ||
pub const SCHNORR_SIGNATURE_ENCODED_SIZE: u32 = 65; | ||
|
||
impl Default for SchnorrSignature { | ||
/// Creates a default Schnorr Signature. Note this is not a valid signature. | ||
fn default() -> Self { | ||
Self([0u8; 65]) | ||
} | ||
} | ||
|
||
impl SchnorrSignature { | ||
/// Attempt to convert a Schnorr signature to a WSTS Signature | ||
pub fn to_wsts_signature(&self) -> Option<WSTSSignature> { | ||
// TODO: update wsts to add a TryFrom for a [u8; 65] and a slice to a Signature | ||
let point_bytes: [u8; 33] = self.0[..33].try_into().ok()?; | ||
let scalar_bytes: [u8; 32] = self.0[33..].try_into().ok()?; | ||
let point = Point::try_from(&Compressed::from(point_bytes)).ok()?; | ||
let scalar = Scalar::from(scalar_bytes); | ||
Some(WSTSSignature { | ||
R: point, | ||
z: scalar, | ||
}) | ||
} | ||
} | ||
|
||
/// Convert a WSTS Signature to a SchnorrSignature | ||
impl From<&WSTSSignature> for SchnorrSignature { | ||
fn from(signature: &WSTSSignature) -> Self { | ||
let mut buf = [0u8; 65]; | ||
buf[..33].copy_from_slice(&signature.R.compress().data); | ||
buf[33..].copy_from_slice(&signature.z.to_bytes()); | ||
SchnorrSignature(buf) | ||
} | ||
} | ||
|
||
impl Secp256k1PublicKey { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we'd also move away from other |
||
#[cfg(any(test, feature = "testing"))] | ||
pub fn new() -> Secp256k1PublicKey { | ||
|
@@ -744,6 +705,7 @@ mod tests { | |
); | ||
} | ||
|
||
/* | ||
#[test] | ||
fn test_schnorr_signature_serde() { | ||
use wsts::traits::Aggregator; | ||
|
@@ -820,4 +782,5 @@ mod tests { | |
assert!(reverted_signature.verify(&aggregate_public_key, msg)); | ||
} | ||
} | ||
*/ | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.