-
Notifications
You must be signed in to change notification settings - Fork 158
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
Spec update #1858
base: main
Are you sure you want to change the base?
Spec update #1858
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1858 +/- ##
==========================================
- Coverage 75.43% 75.40% -0.03%
==========================================
Files 97 97
Lines 8342 8340 -2
==========================================
- Hits 6293 6289 -4
- Misses 1519 1520 +1
- Partials 530 531 +1 ☔ View full report in Codecov by Sentry. |
|
||
s.log.Infow("Start Pipeline", "Random node height", randHeight, "Current height", nextHeight-1, "Start", nextHeight, "End", | ||
nextHeight+min(blockBehind, maxBlocks)) | ||
s.log.Infow("Start Pipeline", "Random node height", randHeight, "Current height", nextHeight-1, "Start", nextHeight) |
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.
randHeight
will no longer be used, so it will always be 0. Do we need to remove it?
Would like to ask, if we no longer choose a random peer and sync with it, how does the current implementation choose its peers?
I would also recommend adding some sort of check such that if no peers are available, then don't bother trying to sync at all, perhaps retry every certain interval. This is because I've been getting a lot of these messages while attempting to sync when there are no peers:
23:53:22.370 14/06/2024 +08:00 ERROR p2p/sync.go:79 Failed to get block headers parts{"err": "no peers available"}
github.com/NethermindEth/juno/p2p.(*syncService).start
/Users/han/Documents/Codes/juno/p2p/sync.go:79
github.com/NethermindEth/juno/p2p.(*Service).Run
/Users/han/Documents/Codes/juno/p2p/p2p.go:212
github.com/NethermindEth/juno/node.(*Node).Run.func3
/Users/han/Documents/Codes/juno/node/node.go:353
github.com/sourcegraph/conc/panics.(*Catcher).Try
/Users/han/go/1.22.4/pkg/mod/github.com/sourcegraph/conc@v0.3.0/panics/panics.go:23
github.com/sourcegraph/conc.(*WaitGroup).Go.func1
/Users/han/go/1.22.4/pkg/mod/github.com/sourcegraph/conc@v0.3.0/waitgroup.go:32
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.
There is some todo I think we can work but we can complete them in a separate PR. Also, there is some unused code which should be removed (such as randHeight
and onBlockBodiesRequest
.
In general, the PR looks good, I have left some questions and suggestions.
Here are some of my thoughts on the sync process:
- Good first step towards using the new conventions.
- To fully utilise the Stream convention we should request more than 1 block parts, however, this would complicate the sync process a lot.
- We should try to benchmark the current sync process so that it can be compared to any new ones in the future. It may be the case that the simple one is more efficient.
GasPrice: AdaptFelt(header.GasPrice), | ||
GasPriceFri: AdaptUint128(header.GasPrice), | ||
Signatures: utils.Map(header.Signatures, AdaptSignature), | ||
// todo(kirill) set these fields |
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 am assuming these fields will have to be set after 0.13.2 update, right?
default: | ||
panic(fmt.Errorf("unknown L1DAMode %v", da)) |
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.
nit: given the data is coming from our db I think we can assume it will be correct.
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.
yep, I can change it to panic("unreachable")
but without it won't work because switch must have default case that either panic or return smth.
func AdaptUint128(f *felt.Felt) *spec.Uint128 { | ||
// bits represents value in little endian byte order | ||
// i.e. first is least significant byte | ||
bits := f.Bits() | ||
// todo what should we do with the rest of bytes? | ||
return &spec.Uint128{ | ||
Low: bits[0], | ||
High: bits[1], | ||
} | ||
} |
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.
Do you think they are not using felt to reduce the size of the message?.
Having 128 bits to represent a number seems a bit weird, not sure why uint64 is not enough.
// todo what should we do with the rest of bytes?
I don't think the rest of the words would be used as this is only used for Gas/DataGas prices
func adaptDeployTransaction(tx *core.DeployTransaction) *spec.Transaction_Deploy_ { | ||
return &spec.Transaction_Deploy_{ | ||
Deploy: &spec.Transaction_Deploy{ | ||
ClassHash: AdaptHash(tx.ClassHash), | ||
AddressSalt: AdaptFelt(tx.ContractAddressSalt), | ||
Calldata: AdaptFeltSlice(tx.ConstructorCallData), | ||
Version: 0, // todo(kirill) remove field from spec? tx is deprecated so no future versions |
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 think that is a good idea
adaptEP := func(points []*spec.EntryPoint) []core.EntryPoint { | ||
// usage of NonNilSlice is essential because relevant core class fields are non nil |
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.
So can EntryPoints be empty or do you think there is a bug in Pathfinder?
err = stream.SetReadDeadline(time.Now().Add(readTimeout)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
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.
Which issue caused you to introduce a timeout?
if !coreBlock.Hash.Equal(h) { | ||
spew.Dump("Receipts number:", coreBlock.Receipts, events) | ||
spew.Dump("Hash mismtach", coreBlock) | ||
os.Exit(1) | ||
} |
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.
consider removing this debug code?
fin := newFin(&spec.BlockBodiesResponse{ | ||
BodyMessage: &spec.BlockBodiesResponse_Fin{}, | ||
}) | ||
|
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 don't see why we need to keep this function. let's delete it.
log utils.SimpleLogger | ||
|
||
ctx context.Context |
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 have always read that storing a context is not a good idea.
I can see that it is used in different protocol handlers protocol handlers when creating a stream. However, we could pass context from the setProtocolHanderls()
and avoid this storage. The cancel function can be set when HeadersHandler()
or any other handler function is called.
(I would be happy if this change could be made in a separate PR)
for _, msg := range messages { | ||
// push generated msg to caller | ||
if !yield(msg) { | ||
// if caller is not interested in remaining data (example: connection to a peer is closed) exit | ||
// note that in this case we won't send finMsg | ||
return | ||
} | ||
} |
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.
If I am not mistaken, this is the only part which is different from processIterationRequest
. Do you think we could pass this as a function and reduce the duplication?
Totally agree |
Issue #1688