* updated path processing data types, refactored ParsePath and fixed tests
* updated generalized index accordingly, changed input parameter path type from []PathElemen to Path
* updated query.go accordingly, changed input parameter path type from []PathElemen to Path
* added descriptive changelog
* Update encoding/ssz/query/path.go
Co-authored-by: Jun Song <87601811+syjn99@users.noreply.github.com>
* Added documentation for Path struct and renamed to for clarity
* Update encoding/ssz/query/path.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* updated changelog to its correct type: Changed
* updated outdated comment in generalized_index.go and removed test in generalized_index_test.go as this one belongs in path_test.go
* Added validateRawPath with strict raw-path validation only - no raw-path fixing is added. Added test suite covering
* added extra tests for wrongly formated paths
---------
Co-authored-by: Jun Song <87601811+syjn99@users.noreply.github.com>
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* added tests for calculating generalized indices
* added first version of GI calculation walking the specified path with no recursion. Extended test coverage for bitlist and bitvectors.
vectors need more testing
* refactored code. Detached PathElement processing, currently done at the beginning. Swap to regex to gain flexibility.
* added an updateRoot function with the GI formula. more refactoring
* added changelog
* replaced TODO tag
* udpated some comments
* simplified code - removed duplicated code in processingLengthField function
* run gazelle
* merging all input path processing into path.go
* reviewed Jun's feedback
* removed unnecessary idx pointer var + fixed error with length data type (uint64 instead of uint8)
* refactored path.go after merging path elements from generalized_indices.go
* re-computed GIs for tests as VariableTestContainer added a new field.
* added minor comment - rawPath MUST be snake case
removed extractFieldName func.
* fixed vector GI calculation - updated tests GIs
* removed updateRoot function in favor of inline code
* path input data enforced to be snake case
* added sanity checks for accessing outbound element indices - checked against vector.length/list.limit
* fixed issues triggered after merging develop
* Removed redundant comment
Co-authored-by: Jun Song <87601811+syjn99@users.noreply.github.com>
* removed unreachable condition as `strings.Split` always return a slice with length >= 1
If s does not contain sep and sep is not empty, Split returns a slice of
length 1 whose only element is s.
* added tests to cover edge cases + cleaned code (toLower is no longer needed in extractFieldName function
* added Jun's feedback + more testing
* postponed snake case conversion to do it on a per-element-basis. Added more testing focused mainly in snake case conversion
* addressed several Jun's comments.
* added sanity check to prevent length of a multi-dimensional array. added more tests with extended paths
* Update encoding/ssz/query/generalized_index.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* Update encoding/ssz/query/generalized_index.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* Update encoding/ssz/query/generalized_index.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* placed constant bitsPerChunk in the right place. Exported BitsPerChunk and BytesPerChunk and updated code that use them
* added helpers for computing GI of each data type
* changed %q in favor of %s
* Update encoding/ssz/query/path.go
Co-authored-by: Jun Song <87601811+syjn99@users.noreply.github.com>
* removed the least restrictive condition isBasicType
* replaced length of containerInfo.order for containerInfo.fields for clarity
* removed outdated comment
* removed toSnakeCase conversion.
* moved isBasicType func to its natural place, SSZType
* cosmetic refactor
- renamed itemLengthFromInfo to itemLength (same name is in spec).
- arranged all SSZ helpers.
* cleaned tests
* renamed "root" to "index"
* removed unnecessary check for negative integers. Replaced %q for %s.
* refactored regex variables and prevented re-assignation
* added length regex explanation
* added more testing for stressing regex for path processing
* renamed currentIndex to parentIndex for clarity and documented the returns from calculate<Type>GeneralizedIndex functions
* Update encoding/ssz/query/generalized_index.go
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
* run gazelle
* fixed never asserted error. Updated error message
---------
Co-authored-by: Jun Song <87601811+syjn99@users.noreply.github.com>
Co-authored-by: Radosław Kapka <radoslaw.kapka@gmail.com>
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Move ssz_query objects into testing folder (ensuring test objects only used in test environment)
* Add containers for response
* Export sszInfo
* Add QueryBeaconState/Block
* Add comments and few refactor
* Fix merge conflict issues
* Return 500 when calculate offset fails
* Add test for QueryBeaconState
* Add test for QueryBeaconBlock
* Changelog :)
* Rename `QuerySSZRequest` to `SSZQueryRequest`
* Fix middleware hooks for RPC to accept JSON from client and return SSZ
* Convert to `SSZObject` directly from proto
* Move marshalling/calculating hash tree root part after `CalculateOffsetAndLength`
* Make nogo happy
* Add informing comment for using proto unsafe conversion
---------
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Add basic parsing feature for accessing by index
* Add more tests for 2d byte vector
* Add List case for access indexing
* Handle 2D bytes List example
* Fix misleading cases for CalculateOffsetAndLength
* Use elementSizes[index] if it is the last path element
* Add variable_container_list field for mocking attester_slashings in BeaconBlockBody
* Remove redundant protobuf message
* Better documentation
* Changelog
* Fix `expectedSize` of `VariableTestContainer`: as we added `variable_container_list` here
* Apply reviews from Radek
* Add SizeSSZ as a member of SSZObject
* Temporarily rename dereferencePointer function
* Fix analyzeType: use reflect.Value for analyzing
* Fix PopulateVariableLengthInfo: change function signature & reset pointer
* Remove Container arm for Size function as it'll be handled in the previous branch
* Remove OffsetBytes function in listInfo
* Refactor and document codes
* Remove misleading "fixedSize" concept & Add Uint8...64 SSZTypes
* Add size testing
* Move TestSSZObject_Batch and rename it as TestHashTreeRoot
* Changelog :)
* Rename endOffset to fixedOffset
---------
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* stored CL object to enable the usage Fastssz's HashTreeRoot(). added basic test
* refactorization - using interfaces instead of storing original object
* added tests covering ssz custom types
* renamed hash_tree_root to ssz_interface as it contains MarshalSSZ and UnmarshalSSZ functions
* run gazelle
* renamed test and improved comments
* refactored test and extend to marshalSSZ and UnmarshalSSZ
* added changelog
* updated comment
* Changed SSZIface name to SSZObject. Removed MarshalSSZ and UnmarshalSSZ function signatures from interface as they are not used still. Refactored tests.
* renamed file ssz_interface.go to ssz_object.go. merge test from ssz_interface_test.go into query_test.go.
reordered source SSZObject field from sszInfo struct
* sticked SSZObject interface to HashTreeRoot() function, the only one needed so far
* run gazelle :)
---------
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Add bitvector field for FixedTestContainer
* Handle Bitvector type using isBitfield flag
* Add Bitvector case for Stringify
* Add bitlist field for VariableTestContainer
* Add bitlistInfo
* Changelog
* Add bitvectorInfo
* Remove analyzeBit* functions and just inline them
* Fix misleading comments
* Add comments for bitlistInfo's Size
* Apply reviews from Radek
* Add vectorInfo
* Add 2D bytes field for test
* Add tag_parser for parsing SSZ tags
* Integrate tag parser with analyzer
* Add ByteList test case
* Changelog
* Better printing feature with Stringer implementation
* Return error for non-determined case without printing other values
* Update tag_parser.go: handle Vector and List mutually exclusive (inspired by OffchainLabs/fastssz)
* Make linter happy
---------
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* 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>
* Add basic PathElement
* Add ssz_type.go
* Add basic sszInfo
* Add containerInfo
* Add basic analyzer without analyzing list/vector
* Add analyzer for homogeneous collection types
* Add offset/length calculator
* Add testutil package in encoding/ssz/query
* Add first round trip test for IndexedAttestationElectra
* Go mod tidy
* Add Print function for debugging purpose
* Add changelog
* Add testonly flag for testutil package & Nit for nogo
* Apply reviews from Radek
* Replace fastssz with prysmaticlabs one
* Add proto/ssz_query package for testing purpose
* Update encoding/ssz/query tests to decouple with beacon types
* Use require.* instead of assert.*
* Fix import name for proto ssz_query package
* Remove uint8/uint16 and some byte arrays in FixedTestContainer
* Add newline for files
* Fix comment about byte array in ssz_query.proto
---------
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* refactor: use auto-generated HashTreeRoot functions in htrutil.go
* refactor: use type alias for Transaction & use SliceRoot for TransactionsRoot
* changelog
* fix: TransactionsRoot receives raw 2d bytes as an argument
* fix: handle nil argument
* test: add nil test for fork and checkpoint
---------
Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
* initialize genesis data asap at node start
* add genesis validation tests with embedded state verification
* Add test for hardcoded mainnet genesis validator root and time from init() function
* Add test for UnmarshalState in encoding/ssz/detect/configfork.go
* Add tests for genesis.Initialize
* Move genesis/embedded to genesis/internal/embedded
* Gazelle / BUILD fix
* James feedback
* Fix lint
* Revert lock
---------
Co-authored-by: Kasey <kasey@users.noreply.github.com>
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
Co-authored-by: Preston Van Loon <preston@pvl.dev>
* Add the new Fulu state with the new field
* fix the hasher for the fulu state
* Fix ToProto() and ToProtoUnsafe()
* Add the fields as shared
* Add epoch transition code
* short circuit the proposer cache to use the state
* Marshal the state JSON
* update spectests to 1.6.0-alpha.1
* Remove deneb and electra entries from blob schedule
This was cherry picked from PR #15364
and edited to remove the minimal cases
* Fix minimal tests
* Increase deadling for processing blocks in spectests
* Preston's review
* review
---------
Co-authored-by: terence tsao <terence@prysmaticlabs.com>
* Migrate Prysm repo to Offchain Labs organization ahead of Pectra upgrade v6
* Replace prysmaticlabs with OffchainLabs on general markdowns
* Update mock
* Gazelle and add mock.go to excluded generated mock file
* Implement static analysis to prevent panics
* Add nopanic to nogo
* Fix violations and add exclusions
Fix violations and add exclusions for all
* Changelog fragment
* Use pass.Report instead of pass.Reportf
* Remove strings.ToLower for checking init method name
* Add exclusion for herumi init
* Move api/client/beacon template function to init and its own file
* Fix nopanic testcase
* Add feature flag to start from any beacon block in db
The new feature flag called --sync-from takes a string that can take
values:
- `head` or
- a 0x-prefixed hex encoded beacon block root.
The beacon block root or the head block root has to be known in db and
has to be a descendant of the current justified checkpoint.
* Fix Bugs In Sync From Head (#15006)
* Fix Bugs
* Remove log
* missing save
* add tests
* Kasey review #1
* Kasey's review #2
* Kasey's review #3
---------
Co-authored-by: Nishant Das <nishdas93@gmail.com>
* change field IDs in `AggregateAttestationAndProofElectra`
* fix typo in `validator.proto`
* correct slashing indices length and shashings length
* check length in indexed attestation's `ToConsensus` method
* use `fieldparams.BLSSignatureLength`
* Add length checks for execution request
* fix typo in `beacon_state.proto`
* fix typo in `ssz_proto_library.bzl`
* fix error messages about incorrect types in block factory
* add Electra case to `BeaconBlockContainerToSignedBeaconBlock`
* move PeerDAS config items to PeerDAS section
* remove redundant params
* rename `PendingDepositLimit` to `PendingDepositsLimit`
* improve requests unmarshaling errors
* rename `get_validator_max_effective_balance` to `get_max_effective_balance`
* fix typo in `consolidations.go`
* rename `index` to `validator_index` in `PendingPartialWithdrawal`
* rename `randomByte` to `randomBytes` in `validators.go`
* fix for version in a comment in `validator.go`
* changelog <3
* Revert "rename `index` to `validator_index` in `PendingPartialWithdrawal`"
This reverts commit 87e4da0ea2.
* Prepare for future fork boilerplate.
* Implement the Fulu fork boilerplate.
* `Upgraded state to <fork> log`: Move from debug to info.
Rationale:
This log is the only one notifying the user a new fork happened.
A new fork is always a little bit stressful for a node operator.
Having at least one log indicating the client switched fork is something useful.
* Update testing/util/helpers.go
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Fix Radek's comment.
* Fix Radek's comment.
* Update beacon-chain/state/state-native/state_trie.go
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Update beacon-chain/state/state-native/state_trie.go
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Fix Radek's comment.
* Fix Radek's comment.
* Fix Radek's comment.
* Remove Electra struct type aliasing.
---------
Co-authored-by: Radosław Kapka <rkapka@wp.pl>
* Cast to String Without Allocating
* Make it its own method
* Changelog
* Gosec
* Add benchmark, fuzz test, and @kasey's implementation.
* Gosec
* Fix benchmark test names
* Kasey's Suggestion
* Radek's Suggestion
---------
Co-authored-by: Preston Van Loon <preston@pvl.dev>
* renaming functions and fields based on consensus changes
* execution api rename
* fixing test
* reverting spectests changes, it should be changed with new version
* reverting temporarily
* revert exclusions
* Electra: Beacon State
* Electra: Beacon state fixes from PR 13919
* Add missing tests - part 1
* Split eip_7251_root.go into different files and reuse/share code with historical state summaries root. It's identical!
* Add missing tests - part 2
* deposit receipts start index getters and setters (#13947)
* adding in getters and setters for deposit receipts start index
* adding tests
* gaz
* Add missing tests - part 3 of 3
Update the electra withdrawal example with a ssz state containing pending partial withdrawals
* add tests for beacon-chain/state/state-native/getters_balance_deposits.go
* Add electra field to testing/util/block.go execution payload
* godoc commentary on public methods
* Fix failing test
* Add balances index out of bounds check and relevant tests.
* Revert switch case electra
* Instead of copying spectest data into testdata, use the spectest dependency
* Deepsource fixes
* Address @rkapka PR feedback
* s/MaxPendingPartialsPerWithdrawalSweep/MaxPendingPartialsPerWithdrawalsSweep/
* Use multivalue slice compatible accessors for validator and balance in ActiveBalanceAtIndex
* More @rkapka feedback. What a great reviewer!
* More tests for branching logic in ExitEpochAndUpdateChurn
* fix build
---------
Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
* First take at updating everything to v5
* Patch gRPC gateway to use prysm v5
Fix patch
* Update go ssz
---------
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
* scaffolding for verification package
* WIP blob verification methods
* lock wrapper for safer forkchoice sharing
* more solid cache and verification designs; adding tests
* more test coverage, adding missing cache files
* clearer func name
* remove forkchoice borrower (it's in another PR)
* revert temporary interface experiment
* lint
* nishant feedback
* add comments with spec text to all verifications
* some comments on public methods
* invert confusing verification name
* deep source
* remove cache from ProposerCache + gaz
* more consistently early return on error paths
* messed up the test with the wrong config value
* terence naming feedback
* tests on BeginsAt
* lint
* deep source...
* name errors after failure, not expectation
* deep sooource
* check len()==0 instead of nil so empty lists work
* update test for EIP-7044
---------
Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>