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

Add genesis config hash as extra data to migration ready transaction #2479

Open
wants to merge 2 commits into
base: albatross
Choose a base branch
from

Conversation

Eligioo
Copy link
Member

@Eligioo Eligioo commented May 17, 2024

What's in this pull request?

  • Fix PoW to PoS chain migration where the candidate block was also migrated into the PoS history store
  • Migration ready transactions now include a genesis config hash as extra data. This way validator ready transactions that have a different starting point are not counted towards the total validator readiness.

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

@Eligioo Eligioo requested a review from jsdanielh May 17, 2024 10:54
pow-migration/src/lib.rs Outdated Show resolved Hide resolved
@Eligioo Eligioo force-pushed the stefan/migration-ready-tx branch from 9910539 to eaab34c Compare May 17, 2024 12:05
pow-migration/src/monitor/mod.rs Show resolved Hide resolved
"Generating ready transaction"
);
OutgoingTransaction {
from: validator,
to: Address::burn_address().to_user_friendly_address(),
value: 1, //Lunas
fee: 0,
data: None,
data: Some(hash.to_hex()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Which is the reason why we want this in hex rather than the raw hash?

Copy link
Member Author

Choose a reason for hiding this comment

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

The PoW RPC specs expects OutgoingTransaction.data to be a String. A raw Blake2bHash doesn't implement that. I could have gone for to_string but to_hex is something we control and have defined which is a little more consistent.

// Here we filter by current epoch
// Check if the txn contains extra data and matches our genesis block hash
if let Some(txn_data) = &txn.data {
if *txn_data != genesis_config_hex {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, why in hex?

// Here we filter by the readiness criteria, TBD
// Check if the txn contains extra data and matches our genesis block hash
if let Some(txn_data) = &txn.data {
if *txn_data != genesis_config_hex {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, why in hex?

pow-migration/src/lib.rs Show resolved Hide resolved
let filtered_txns: Vec<TransactionDetails> = transactions
.into_iter()
.filter(|txn| {
// Here we filter by current epoch
// Check if the txn contains extra data and matches our genesis block hash
if let Some(txn_data) = &txn.data {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to factorize the txn data check in a function to avoid code duplication

@@ -111,7 +127,16 @@ pub async fn check_validators_ready(
let filtered_txns: Vec<TransactionDetails> = transactions
.into_iter()
.filter(|txn| {
// Here we filter by the readiness criteria, TBD
// Check if the txn contains extra data and matches our genesis block hash
if let Some(txn_data) = &txn.data {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to factorize the txn data check in a function to avoid code duplication

@styppo styppo added this to the Nimiq PoS Mainnet milestone May 20, 2024
@sisou sisou changed the title Add genesis hash as extra data to migration ready transaction Add genesis config hash as extra data to migration ready transaction May 22, 2024
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.

None yet

4 participants