Skip to content

Commit

Permalink
Update codec test vectors (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
pantrif authored Dec 18, 2024
1 parent 4ce28c3 commit 99bb2b8
Show file tree
Hide file tree
Showing 34 changed files with 1,279 additions and 307 deletions.
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

0 comments on commit 99bb2b8

Please sign in to comment.