HotShot icon indicating copy to clipboard operation
HotShot copied to clipboard

[VALIDATED_STATE] - Avoid duplication of state computation

Open shenkeyao opened this issue 1 year ago • 0 comments

What is this task and why do we need to work on it?

All nodes calculate the new state when calling validate_and_apply_header. A leader calculates the state one more time in BlockHeader::new because it needs the state to get the header. I.e., we calculate the new state twice in the leader node.

  1. BlockHeader::new will have to duplicate some of the validate_and_apply_header logic to include the new state commitment in the header.
  2. The full validate_and_apply_header.

This duplication is not obvious in hotshot since we only define the trait and the validate_and_apply_header function is implemented in the sequencer.

What work will need to be done to complete this task?

There may be multiple ways to avoid the duplication. One way could be passing the calculated new state from the parent task, so that the leader can just take it rather than calculating it again in validate_and_apply_header.

Are there any other details to include?

No response

What are the acceptance criteria to close this issue?

The state isn't unnecessarily computed twice.

Branch work will be merged to (if not the default branch)

No response

shenkeyao avatar Jan 25 '24 20:01 shenkeyao