Skip to content

Whisk review implementor notes#1

Open
dapplion wants to merge 1 commit intonalinbhardwaj:whisk-curdleproofsfrom
dapplion:whisk-curdleproofs-review
Open

Whisk review implementor notes#1
dapplion wants to merge 1 commit intonalinbhardwaj:whisk-curdleproofsfrom
dapplion:whisk-curdleproofs-review

Conversation

@dapplion
Copy link

Various non-critical comments surfaced from implementing. Will annotated comments below on each line

| `DOMAIN_WHISK_SHUFFLE` | `DomainType('0x07100000')` |
| `DOMAIN_WHISK_PROPOSER_SELECTION` | `DomainType('0x07200000')` |
| `DOMAIN_WHISK_SHUFFLE` | `DomainType('0x08000000')` |
| `DOMAIN_WHISK_PROPOSER_SELECTION` | `DomainType('0x09000000')` |
Copy link
Author

Choose a reason for hiding this comment

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

In spec it's more common to use sequential domains

Comment on lines +67 to +68
def get_k_commitment(k: BLSFieldElement) -> BLSG1Point:
return bls.G1_to_bytes48(bls.multiply(bls.G1, k))
Copy link
Author

Choose a reason for hiding this comment

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

de-dup code and simplify crypto interface

whisk_tracker: WhiskTracker # Whisk tracker (r * G, k * r * G) [New in Whisk]
whisk_k_commitment: BLSG1Point # Whisk k commitment k * BLS_G1_GENERATOR [New in Whisk]
r_g: BLSG1Point # r * G
k_r_g: BLSG1Point # k * r * G
Copy link
Author

Choose a reason for hiding this comment

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

whisk_candidate_trackers: Vector[WhiskTracker, WHISK_CANDIDATE_TRACKERS_COUNT] # [New in Whisk]
whisk_proposer_trackers: Vector[WhiskTracker, WHISK_PROPOSER_TRACKERS_COUNT] # [New in Whisk]
whisk_trackers: List[WhiskTracker, VALIDATOR_REGISTRY_LIMIT] # Whisk tracker (r * G, k * r * G) [New in Whisk]
whisk_k_commitments: List[BLSG1Point, VALIDATOR_REGISTRY_LIMIT] # Whisk k commitment k * BLS_G1_GENERATOR [New in Whisk]
Copy link
Author

Choose a reason for hiding this comment

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

state.whisk_proposer_trackers[i] = state.whisk_candidate_trackers[index]


def select_whisk_candidate_trackers(state: BeaconState, epoch: Epoch) -> None:
Copy link
Author

Choose a reason for hiding this comment

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

Split select_* functions to re-use in fork transition

# ...
body: BeaconBlockBody
proposer_index: ValidatorIndex
whisk_opening_proof: ByteList[WHISK_MAX_OPENING_PROOF_SIZE] # [New in Whisk]
Copy link
Author

Choose a reason for hiding this comment

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

Best to add new fields in body and not in BeaconBlock obj, such that the BeaconBlockHeader maps to BeaconBlock with body as root

Comment on lines -89 to +92
M: BLSG1Point,
shuffle_proof: ByteList[WHISK_MAX_SHUFFLE_PROOF_SIZE]) -> bool:
"""
Verify `post_shuffle_trackers` is a permutation of `pre_shuffle_trackers`.
Note: whisk_shuffle_proof_m_commitment is included in whisk_shuffle_proof struct
Copy link
Author

@dapplion dapplion Mar 27, 2023

Choose a reason for hiding this comment

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

Merge M into shuffle_proof to drop one extra field from the block, and simplify crypto interface

# ...
process_whisk(state, block.body) # [New in Whisk]
whisk_process_shuffled_trackers(state, block.body) # [New in Whisk]
whisk_process_registration(state, block.body) # [New in Whisk]
Copy link
Author

@dapplion dapplion Mar 27, 2023

Choose a reason for hiding this comment

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

No strong reason here, just considered that it reads better than process_whisk calling whisk_process_shuffled_trackers internally. It communicates to implementers that there are two things which are not dependent on each other

Return the beacon proposer index at the current slot.
"""
print("get_beacon_proposer_index", state.latest_block_header.slot, state.slot)
# assert state.latest_block_header.slot == state.slot # sanity check `process_block_header` has been called
Copy link
Author

@dapplion dapplion Mar 27, 2023

Choose a reason for hiding this comment

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

Removed as I assume this is a debug artifact. I'm unsure if it's necessary to spec this function since it adds no new information. Is it necessary for the executable spec to work properly? @nalinbhardwaj

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.

1 participant