Skip to content

core/types: add SSZ encoders/decoders for BAL types from EIP 7928 #31948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions core/types/bal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package types

//go:generate go run github.com/ferranbt/fastssz/sszgen --path . --objs PerTxAccess,SlotAccess,AccountAccess,BlockAccessList,BalanceDelta,BalanceChange,AccountBalanceDiff,CodeChange,AccountCodeDiff,AccountNonce,NonceDiffs --output bal_encoding.go

type PerTxAccess struct {
TxIdx uint64 `ssz-size:"2"`
ValueAfter [32]byte
}

type SlotAccess struct {
Slot [32]byte `ssz-size:"32"`
Accesses []PerTxAccess `ssz-max:"30000"`
}

type AccountAccess struct {
Address [20]byte `ssz-size:"32"`
Accesses []SlotAccess `ssz-max:"300000"`
code []byte `ssz-max:"24576"` // this is currently a union in the EIP spec, but unions aren't used anywhere in practice so I implement it as a list here.

Check failure on line 18 in core/types/bal.go

View workflow job for this annotation

GitHub Actions / Lint

field code is unused (unused)

Check failure on line 18 in core/types/bal.go

View workflow job for this annotation

GitHub Actions / Lint

field code is unused (unused)
}

type BalanceDelta [12]byte // {}-endian signed integer

type BalanceChange struct {
TxIdx uint64 `ssz-size:"2"`
Delta BalanceDelta
}

type AccountBalanceDiff struct {
Address [40]byte
Changes []BalanceChange `ssz-max:"30000"`
}

// TODO: implement encoder/decoder manually on this, as we can't specify tags for a type declaration
type BalanceDiffs = []AccountBalanceDiff

type CodeChange struct {
TxIdx uint64 `ssz-size:"2"`
NewCode []byte `ssz-max:"24576"`
}

type AccountCodeDiff struct {
Address [40]byte
Changes []CodeChange `ssz-max:"30000"`
}

// TODO: implement encoder/decoder manually on this, as we can't specify tags for a type declaration
type CodeDiffs []AccountCodeDiff

type AccountNonce struct {
Address [40]byte
NonceAfter uint64
}

// TODO: implement encoder/decoder manually on this, as we can't specify tags for a type declaration
type NonceDiffs []AccountNonce
Loading
Loading