ChainSafe / gossamer

🕸️ Go Implementation of the Polkadot Host
https://chainsafe.github.io/gossamer
GNU Lesser General Public License v3.0
427 stars 110 forks source link

feat(dot/parachain): implement validate candidate from exhaustive #4036

Open edwardmack opened 3 weeks ago

edwardmack commented 3 weeks ago

Changes

This PR introduces code for candidate validation subsystem to validate candidates when all data validation data is provided. As described in Implementation Plan this PR implements:

Create tests to check for candidate validation exceptions based on possible errors generated by validate block function and reviewing code from polkadot test code

Tests

 go test github.com/ChainSafe/gossamer/dot/parachain/candidate-validation -v

Issues

closes: #3547 and #3995

axaysagathiya commented 2 weeks ago

We don't need to Encode or decode ValidationResultMessage, so we don't need to create VDT.

I have already commented above on how to use this struct.

Validation results can be either Valid or Invalid.

If the result is Invalid,
    set the IsValid field of ValidationResultMessage to false.
    also store the reason for invalidity in the Err field of ValidationResultMessage.

If the result is Valid,
    set the IsValid field of ValidationResultMessage to true.
    set the values of the CandidateCommitments and PersistedValidationData fields of ValidationResultMessage.

Reference from rust: https://github.com/paritytech/polkadot-sdk/blob/7ca0d65f19497ac1c3c7ad6315f1a0acb2ca32f8/polkadot/node/primitives/src/lib.rs#L346-L353

Let's schedule a meeting and work on this together if you are confused.

edwardmack commented 2 weeks ago

We don't need to Encode or decode ValidationResultMessage, so we don't need to create VDT.

I've removed the usage VDT for this type (and renamed it back to ValidationResult)

axaysagathiya commented 1 week ago

We don't need to Encode or decode ValidationResultMessage, so we don't need to create VDT.

I have already commented above on how to use this struct.

Validation results can be either Valid or Invalid.

If the result is Invalid,
    set the IsValid field of ValidationResultMessage to false.
    also store the reason for invalidity in the Err field of ValidationResultMessage.

If the result is Valid,
    set the IsValid field of ValidationResultMessage to true.
    set the values of the CandidateCommitments and PersistedValidationData fields of ValidationResultMessage.

Reference from rust: https://github.com/paritytech/polkadot-sdk/blob/7ca0d65f19497ac1c3c7ad6315f1a0acb2ca32f8/polkadot/node/primitives/src/lib.rs#L346-L353

Let's schedule a meeting and work on this together if you are confused.

Can you please add this comment to ValidationResult so that others can understand this structure?