Skip to content
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

Update codec test vectors #188

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions internal/work/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,33 @@ import (
"github.com/eigerco/strawberry/internal/crypto"
)

// SegmentReferenceType differentiates between a direct segment-root hash (H) and a work-package hash (H⊞)
type SegmentReferenceType uint8

const (
SegmentReferenceRootHash SegmentReferenceType = iota // H
SegmentReferenceWorkPackageHash // H⊞
)

type ImportedSegment struct {
RefType SegmentReferenceType
Hash crypto.Hash
Index uint32
Hash crypto.Hash
Index uint16
}

type BlobHashLengthPair struct {
type Extrinsic struct {
Hash crypto.Hash
Length uint32
}

// Item represents I (14.2 v0.5.2)
type Item struct {
ServiceId uint32 // s ∈ N_S
CodeHash crypto.Hash // c ∈ H
Payload []byte // y ∈ Y
GasLimitRefine uint64 // g ∈ N_G
GasLimitAccumulate uint64 // a ∈ N_G
ExportedSegments uint // eN
ImportedSegments []ImportedSegment // i ∈ ⟦{H ∪ (H⊞), N}
BlobHashLengths []BlobHashLengthPair // x⟦(H, N)⟧
ServiceId uint32 // s ∈ N_S
CodeHash crypto.Hash // c ∈ H
Payload []byte // y ∈ Y
GasLimitRefine uint64 // g ∈ N_G
GasLimitAccumulate uint64 // a ∈ N_G
ImportedSegments []ImportedSegment // i⟦{H ∪ (H⊞), N}⟧
Extrinsics []Extrinsic // x ∈ ⟦(H, N)
ExportedSegments uint16 // eN
}

func (w *Item) Size() uint64 {
// S(w) = |w.y| + |w.i| * WG + Σ(h,l)∈w.x l
total := uint64(len(w.Payload)) // |w.y|
total += uint64(len(w.ImportedSegments)) * SizeOfSegment // |w.i| * WG
for _, bh := range w.BlobHashLengths {
for _, bh := range w.Extrinsics {
total += uint64(bh.Length)
}
return total
Expand Down
4 changes: 2 additions & 2 deletions internal/work/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ type Package struct {

// ValidateNumberOfEntries (14.4 v0.5.2)
func (wp *Package) ValidateNumberOfEntries() error {
var totalExported, totalImported uint
var totalExported, totalImported uint16
for _, w := range wp.WorkItems {
totalExported += w.ExportedSegments
totalImported += uint(len(w.ImportedSegments))
totalImported += uint16(len(w.ImportedSegments))
}

if totalExported > MaxNumberOfEntries {
Expand Down
281 changes: 0 additions & 281 deletions tests/integration/block_integration_test.go

This file was deleted.

Loading
Loading