mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
* Add VariableTestContainer in ssz_query.proto * Add listInfo * Use errors.New for making an error with a static string literal * Add listInfo field when analyzing the List type * Persist the field order in the container * Add actualOffset and goFieldName at fieldInfo * Add PopulateFromValue function & update test runner * Handle slice of ssz object for marshalling * Add CalculateOffsetAndLength test * Add comments for better doc * Changelog :) * Apply reviews from Radek * Remove actualOffset and update offset field instead * Add Nested container of variable-sized for testing nested path * Fix offset adding logics: for variable-sized field, always add 4 instead of its fixed size * Fix multiple import issue --------- Co-authored-by: Radosław Kapka <rkapka@wp.pl>
76 lines
3.8 KiB
Protocol Buffer
76 lines
3.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package ssz_query;
|
|
|
|
import "proto/eth/ext/options.proto";
|
|
|
|
option go_package = "github.com/OffchainLabs/prysm/v6/proto/ssz_query";
|
|
|
|
|
|
// ===== FIXED-SIZE TEST CONTAINERS =====
|
|
// These containers are designed to test SSZ query functionality with comprehensive coverage
|
|
// of all fixed-size SSZ types according to the SSZ specification.
|
|
|
|
// FixedNestedContainer - nested container for testing nested field access
|
|
// Tests: nested container navigation, field offset calculations within nested structures
|
|
message FixedNestedContainer {
|
|
uint64 value1 = 1; // Test: uint64 basic type, offset calculation in nested context
|
|
bytes value2 = 2 [ (ethereum.eth.ext.ssz_size) = "32" ]; // Test: fixed-size bytes in nested container
|
|
}
|
|
|
|
// FixedTestContainer - comprehensive fixed-size container for SSZ query testing
|
|
// Tests: All basic fixed-size SSZ types, nested containers, vectors, offset/length calculations
|
|
// Total size: 333 bytes (4+8+1+32+40+192+56)
|
|
message FixedTestContainer {
|
|
// Basic integer types - test different integer sizes and their SSZ serialization
|
|
uint32 field_uint32 = 3; // Test: uint32 basic type, offset: 0
|
|
uint64 field_uint64 = 4; // Test: uint64 basic type, offset: 4
|
|
|
|
// Boolean type - test boolean serialization (1 byte in SSZ)
|
|
bool field_bool = 5; // Test: boolean basic type, offset: 12
|
|
|
|
// Fixed-size bytes - test byte array
|
|
bytes field_bytes32 = 8 [ (ethereum.eth.ext.ssz_size) = "32" ]; // Test: 32-byte array, offset: 13
|
|
|
|
// Nested container - test container nesting and field access
|
|
FixedNestedContainer nested = 9; // Test: nested container navigation (8+32=40 bytes), offset: 45
|
|
|
|
// Vector type - test fixed-size array of basic elements
|
|
repeated uint64 vector_field = 10 [ (ethereum.eth.ext.ssz_size) = "24" ]; // Test: Vector[24] of uint64 (24*8=192 bytes), offset: 85
|
|
|
|
// Additional bytes field - test field ordering and offset calculation
|
|
bytes trailing_field = 11 [ (ethereum.eth.ext.ssz_size) = "56" ]; // Test: trailing field after vector, offset: 277
|
|
}
|
|
|
|
// ===== VARIABLE-SIZE TEST CONTAINERS =====
|
|
|
|
// VariableNestedContainer - nested container for testing nested field access
|
|
// Tests: nested container navigation, field offset calculations within nested structures
|
|
message VariableNestedContainer {
|
|
uint64 value1 = 1;
|
|
repeated uint64 field_list_uint64 = 2 [ (ethereum.eth.ext.ssz_max) = "100" ];
|
|
}
|
|
|
|
// VariableTestContainer - comprehensive variable-size container for SSZ query testing
|
|
// Tests: Variable-size lists, offsets in variable containers, mixed fixed/variable fields
|
|
message VariableTestContainer {
|
|
// Fixed-size leading field - test fixed field before variable fields
|
|
// Acts as a baseline to verify offset calculations start correctly
|
|
bytes leading_field = 1 [ (ethereum.eth.ext.ssz_size) = "32" ]; // Test: fixed 32-byte field at start, offset: 0
|
|
|
|
// Variable-size list of basic type - test list with primitive elements
|
|
// SSZ uses 4-byte offset pointer, actual data stored after all fixed fields
|
|
repeated uint64 field_list_uint64 = 2 [ (ethereum.eth.ext.ssz_max) = "2048" ]; // Test: List[uint64, 2048] (max 2048 elements)
|
|
|
|
// Variable-size list of containers - test list with composite elements
|
|
// Each container is fixed-size (40 bytes), but list itself is variable
|
|
repeated FixedNestedContainer field_list_container = 3 [ (ethereum.eth.ext.ssz_max) = "128" ]; // Test: List[FixedNestedContainer, 128]
|
|
|
|
// Variable nested container - test nested container access within variable container
|
|
VariableNestedContainer nested = 4;
|
|
|
|
// Fixed-size trailing field - test fixed field after variable fields
|
|
// Verifies correct offset calculation after variable-size fields
|
|
bytes trailing_field = 5 [ (ethereum.eth.ext.ssz_size) = "56" ]; // Test: fixed 56-byte field at end, offset: 32 + 4 + 4 + 4 = 44
|
|
}
|