-
Notifications
You must be signed in to change notification settings - Fork 21k
Draft: New EraE implementation #32157
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint is failing, you can check on your machine with make lint
@@ -0,0 +1,91 @@ | |||
// Copyright 2024 The go-ethereum Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright 2024 The go-ethereum Authors | |
// Copyright 2025 The go-ethereum Authors |
internal/era2/builder2.go
Outdated
@@ -0,0 +1,305 @@ | |||
package era2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
header
internal/era2/builder2.go
Outdated
receiptoffsets []uint64 | ||
proofoffsets []uint64 | ||
tdoff []uint64 | ||
startTd *big.Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are used and implemented, when I am writing sections it also appends with the offset of where item was written.
internal/era2/era2.go
Outdated
@@ -0,0 +1,429 @@ | |||
package era2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a bunch of comments here - we still need to figure out how to call this module since era2
isn't very elegant. In the meantime should rename builder2.go
to just builder.go
and era2.go
to era.go
.
internal/era2/builder2.go
Outdated
writtenBytes uint64 | ||
} | ||
|
||
func NewBuilder(w io.Writer) *Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add docs for all public methods
internal/era2/builder2.go
Outdated
} | ||
} | ||
|
||
func (b *Builder) Add(header types.Header, body types.Body, receipts types.Receipts, blockhash common.Hash, blocknum uint64, td *big.Int, proof *Proof) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blockhash
and blocknum
are already available via header
, so no need to duplicate them
internal/era2/builder2.go
Outdated
} | ||
} | ||
|
||
func (b *Builder) Add(header types.Header, body types.Body, receipts types.Receipts, blockhash common.Hash, blocknum uint64, td *big.Int, proof *Proof) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would separate this into Add
and AddRLP
internal/era2/builder2.go
Outdated
headersRLP [][]byte | ||
bodiesRLP [][]byte | ||
receiptsRLP [][]byte | ||
proofsRLP [][]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would remove RLP
suffix since it is pretty explanatory by the type [][]byte
internal/era2/era2.go
Outdated
"github.com/klauspost/compress/snappy" | ||
) | ||
|
||
type meta struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type meta struct { | |
type metadata struct { |
internal/era2/era2.go
Outdated
type meta struct { | ||
start uint64 // start block number | ||
count uint64 // number of blocks in the era | ||
compcount uint64 // number of properties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compcount uint64 // number of properties | |
components uint64 // number of properties |
internal/era2/era2.go
Outdated
start uint64 // start block number | ||
count uint64 // number of blocks in the era | ||
compcount uint64 // number of properties | ||
filelen int64 // length of the file in bytes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filelen int64 // length of the file in bytes | |
length int64 // length of the file in bytes |
internal/era2/era2.go
Outdated
mu *sync.Mutex | ||
headeroff, bodyoff, receiptsoff, tdoff, proofsoff []uint64 // offsets for each entry type | ||
indstart int64 | ||
rootheader uint64 // offset of the root header in the file if present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the use of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when reading each era file I load in the index table into cache to make lookup faster, indstart is where the byte where the index table starts, and the root header is where the accumulator root is present when reading so it can seek there quickly since it is its own e2store object. The mutex should be removed though, forgot to do so very early on when I didn't understand what the file was doing I thought I wouldn't want it to read and write at the same time so put a lock.
internal/era2/era2.go
Outdated
m meta // metadata for the era2 file | ||
mu *sync.Mutex | ||
headeroff, bodyoff, receiptsoff, tdoff, proofsoff []uint64 // offsets for each entry type | ||
indstart int64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this?
Also, please write a description for your PRs and try to fix the CI errors so your code is all green. |
Fixed all issues including extra logic regarding proof types, modularizing some functions and refactoring code for correctness and readability.
internal/era2/era.go
Outdated
|
||
func (*BlockProofHistoricalSummariesDeneb) Variant() proofvar { return proofDeneb } | ||
|
||
func proofVariantOf(p Proof) proofvar { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func proofVariantOf(p Proof) proofvar { | |
func variantOf(p Proof) proofvar { |
internal/era2/builder.go
Outdated
@@ -57,41 +57,33 @@ const ( | |||
|
|||
type proofvar uint16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type proofvar uint16 | |
type variant uint16 |
We know that the variant is for Proofs, should be at most a comment, not part of the variable name, otherwise you end up with the types like mev-boost :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha will make the change :)
Here is a draft for the New EraE implementation. The code follows along with the spec listed at this link.