SSZ-QL: populate variable-length metadata in AnalyzeObject (#15676)

* increased AnalyzeObject functionality to return a fully populated SSZInfo object including runtime lengths for lists

* reverted formatting change

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
This commit is contained in:
fernantho
2025-09-11 13:39:02 +02:00
committed by GitHub
parent df86f57507
commit a8cab58f7e
3 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,3 @@
### Added
- Populate sszInfo of variable-length fields in AnalyzeObjects

View File

@@ -18,6 +18,12 @@ func AnalyzeObject(obj any) (*sszInfo, error) {
return nil, fmt.Errorf("could not analyze type %s: %w", value.Type().Name(), err)
}
// Populate variable-length information using the actual value.
err = PopulateVariableLengthInfo(info, value.Interface())
if err != nil {
return nil, fmt.Errorf("could not populate variable length info: %w", err)
}
return info, nil
}

View File

@@ -171,11 +171,9 @@ func TestCalculateOffsetAndLength(t *testing.T) {
path, err := query.ParsePath(tt.path)
require.NoError(t, err)
info, err := query.AnalyzeObject(&sszquerypb.VariableTestContainer{})
require.NoError(t, err)
testContainer := createVariableTestContainer()
err = query.PopulateVariableLengthInfo(info, testContainer)
info, err := query.AnalyzeObject(testContainer)
require.NoError(t, err)
_, offset, length, err := query.CalculateOffsetAndLength(info, path)