Skip to content

Implement PoT entropy injection#1939

Merged
nazar-pc merged 3 commits intomainfrom
pot-entropy-injection
Sep 11, 2023
Merged

Implement PoT entropy injection#1939
nazar-pc merged 3 commits intomainfrom
pot-entropy-injection

Conversation

@nazar-pc
Copy link
Copy Markdown
Member

@nazar-pc nazar-pc commented Sep 8, 2023

Most of the complex logic went into #1929 with verification, this is just a straightforward implementation of the entropy injection.

I have tested various edge-cases locally and added some static assertions in the runtime. If you modify those values for whatever reason, you still need to make sure things compile or else you'll get into broken invariants and inevitably get errors sooner or later.

Let me know if something doesn't make sense or you have questions about anything.

Next step is to implement voting (right now it is broken) and then fix tests (sp-lightclient will also need to be adjusted). I also have some concerns and local patches for gossip, also verifiction cache is susceptible to gossiping attacks, so I will have to adjust that as well and have a discussion about how to implement it securely.

Major things lacking from eventual implementation:

  • voting
  • checkpoints in justifications
  • optimistic verification during major sync

Code contributor checklist:

Copy link
Copy Markdown
Contributor

@shamil-gadelshin shamil-gadelshin left a comment

Choose a reason for hiding this comment

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

The changes introduce a lot of calculations, side-effects, and code branches. Can we have tests for the code (we have a mock runtime)?


// Entropy injection interval must be bigger than injection delay or else we may end up in a
// situation where we'll need to do more than one injection at the same slot
const_assert!(POT_ENTROPY_INJECTION_INTERVAL as u64 > POT_ENTROPY_INJECTION_DELAY);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can it be changed? If yes - we need to add a check POT_ENTROPY_INJECTION_INTERVAL > 0 because we have a division in the code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Theoretically yes, but I don't think we'll need to change them, they are supposed to be constants.

vedhavyas
vedhavyas previously approved these changes Sep 8, 2023
Copy link
Copy Markdown
Contributor

@vedhavyas vedhavyas left a comment

Choose a reason for hiding this comment

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

Make sense. I think testing these would be easier once we have sp-lightclient is updated

Copy link
Copy Markdown
Member Author

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

The changes introduce a lot of calculations, side-effects, and code branches. Can we have tests for the code (we have a mock runtime)?

We should, but there is no good infrastructure for it right now. Also tests in sp-lightclient and pallet-subspace are disabled when pot feature is enabled because they don't even compile. When fixed pallet-subspace will likely be updated to cover many of the cases. But I definitely agree that many automated tests are necessary here.


// Entropy injection interval must be bigger than injection delay or else we may end up in a
// situation where we'll need to do more than one injection at the same slot
const_assert!(POT_ENTROPY_INJECTION_INTERVAL as u64 > POT_ENTROPY_INJECTION_DELAY);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Theoretically yes, but I don't think we'll need to change them, they are supposed to be constants.

@nazar-pc nazar-pc requested a review from dariolina September 11, 2023 15:19
dariolina
dariolina previously approved these changes Sep 11, 2023
@nazar-pc nazar-pc force-pushed the pot-entropy-injection branch from e4a60e9 to 5443c10 Compare September 11, 2023 15:36
@nazar-pc nazar-pc force-pushed the pot-entropy-injection branch from 5443c10 to b000948 Compare September 11, 2023 15:57
Base automatically changed from pot-parameters-change-and-sync to main September 11, 2023 16:00
@nazar-pc nazar-pc dismissed stale reviews from dariolina, shamil-gadelshin, and vedhavyas September 11, 2023 16:00

The base branch was changed.

@nazar-pc nazar-pc merged commit 34a3e95 into main Sep 11, 2023
@nazar-pc nazar-pc deleted the pot-entropy-injection branch September 11, 2023 16:02
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.

4 participants