-
Notifications
You must be signed in to change notification settings - Fork 2
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 report structs #29
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package block | ||
|
||
import ( | ||
"github.com/eigerco/strawberry/internal/crypto" | ||
"github.com/eigerco/strawberry/internal/time" | ||
) | ||
|
||
// WorkResultError represents the type of error that occurred during work execution | ||
type WorkResultError int | ||
|
||
// WorkResultError represents the possible errors for a work result | ||
const ( | ||
NoError WorkResultError = iota | ||
OutOfGas // ∞: Out of gas error | ||
Panic // ☇: Panic error | ||
BadCode // BAD: Service's code not available | ||
CodeTooLarge // BIG: Code available but exceeds maximum size | ||
) | ||
|
||
// GuaranteesExtrinsic represents the E_G extrinsic | ||
type GuaranteesExtrinsic struct { | ||
Guarantees []Guarantee | ||
} | ||
|
||
// Guarantee represents a single guarantee within the E_G extrinsic | ||
type Guarantee struct { | ||
CoreIndex uint32 // Index of the core this guarantee is for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my understanding of the paper the core index is taken from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The paper defines it that way. Not sure about the reason for this redundancy, maybe somewhere we will take this index without the need to deserialize the work report. Gavin knows for sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
WorkReport WorkReport // The work report being guaranteed | ||
Credential Credential // The credential proving the guarantee's validity | ||
Timeslot time.Timeslot // The timeslot when this guarantee was made | ||
} | ||
|
||
// Credential represents the credential a in the document | ||
type Credential struct { | ||
Signatures []CredentialSignature | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not trying to nitpick, but should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My question is not as much regarding the naming, as if we need this Credential struct at all and if we should use the sequence of signatures in the parent struct directly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, sorry didn't read correctly. Yeah, doesn't make sense. I'll update it, thanks! |
||
} | ||
|
||
// CredentialSignature represents a single signature within the credential | ||
type CredentialSignature struct { | ||
ValidatorIndex uint32 // Index of the validator providing this signature | ||
Signature [crypto.Ed25519SignatureSize]byte // The Ed25519 signature | ||
} | ||
|
||
// WorkReport represents a report of completed work | ||
type WorkReport struct { | ||
Specification WorkPackageSpecification | ||
Context RefinementContext | ||
CoreIndex uint16 // N_C | ||
AuthorizerHash crypto.Hash // H | ||
Output []byte // Y a set of octet strings | ||
Results []WorkResult // r ∈ ⟦L⟧_1:I: Sequence of 1 to I work results | ||
} | ||
|
||
// WorkPackageSpecification defines the specification of a work package | ||
type WorkPackageSpecification struct { | ||
Hash crypto.Hash // h ∈ H: Work package hash | ||
Length uint32 // l ∈ N_L: Auditable work bundle length (N_L is the set of blob length values) | ||
ErasureRoot crypto.Hash // u ∈ H: Erasure root | ||
SegmentRoot crypto.Hash // e ∈ H: Segment root | ||
} | ||
|
||
// RefinementContext provides context for the refinement process | ||
type RefinementContext struct { | ||
AnchorHeaderHash crypto.Hash // a ∈ H: Anchor header hash | ||
AnchorPosteriorStateRoot crypto.Hash // s ∈ H: Anchor state root | ||
AnchorPosteriorBeefyRoot crypto.Hash // b ∈ H: Anchor Beefy root | ||
LookupAnchorHeaderHash crypto.Hash // l ∈ H: Lookup anchor hash | ||
LookupAnchorTimeslot time.Timeslot // t ∈ N_T: Lookup anchor timeslot | ||
PrerequisiteHash *crypto.Hash // p ∈ H?: Optional prerequisite work package hash | ||
} | ||
|
||
// WorkResult represents the result of a single work item | ||
type WorkResult struct { | ||
ServiceIndex uint32 // s ∈ N_S: Service index (N_S is the set of service indices) | ||
CodeHash crypto.Hash // c ∈ H: Code hash | ||
PayloadHash crypto.Hash // l ∈ H: Payload hash | ||
GasRatio uint64 // g ∈ N_G: Gas prioritization ratio | ||
Output WorkResultOutput // o ∈ Y ∪ J: Output or error (Y is the set of octet strings, J is the set of work execution errors) | ||
} | ||
|
||
// WorkResultOutput represents either the successful output or an error from a work result | ||
type WorkResultOutput struct { | ||
Data []byte // Represents successful output (Y) | ||
Error WorkResultError // Represents error output (J) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where:
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same question as with Credential, do we need this intermediary struct
GuaranteesExtrinsic
or can we use[]Guarantees
directly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is variable length, so we can't represent it and array with length
341
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. I initially started the
ticket
with just a slice, but seems wrong and I have a PR fixing that. We will probably have functions specific for extrinsics, i.e.validate
etc. So it makes sense.