core/types/bal: enhance the bal validation (#35281)

EIP-7928 requires that each address appears exactly once in the block
access list.

In the `BlockAccessList.Validate`, the strict `isStrictlySortedFunc` is
required to detect the duplicated accounts.
This commit is contained in:
rjl493456442 2026-07-03 14:30:56 +08:00 committed by GitHub
parent 7aa7806c09
commit 3d50e3eb0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -80,7 +80,7 @@ func (e *BlockAccessList) DecodeRLP(s *rlp.Stream) error {
// according to the spec or any code changes are contained which exceed protocol
// max code size.
func (e *BlockAccessList) Validate(blockGasLimit uint64, blockTxCount int) error {
if !slices.IsSortedFunc(*e, func(a, b AccountAccess) int {
if !isStrictlySortedFunc(*e, func(a, b AccountAccess) int {
return bytes.Compare(a.Address[:], b.Address[:])
}) {
return errors.New("block access list accounts not in lexicographic order")