Skip to content

Commit

Permalink
Return post0132 commitments for pre0132 blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushinDaniil committed Dec 10, 2024
1 parent cf106af commit cdf8552
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions p2p/starknet/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,31 @@ func (h *Handler) onHeadersRequest(req *spec.BlockHeadersRequest) (iter.Seq[prot

h.log.Debugw("Created Header Iterator", "blockNumber", header.Number)

commitments, err := h.bcReader.BlockCommitmentsByNumber(header.Number)
stateUpdate, err := h.bcReader.StateUpdateByNumber(header.Number)
if err != nil {
return nil, err
}

stateUpdate, err := h.bcReader.StateUpdateByNumber(header.Number)
var commitments *core.BlockCommitments
blockVer, err := core.ParseBlockVersion(header.ProtocolVersion)
if err != nil {
return nil, err
}
if blockVer.LessThan(core.Ver0_13_2) {
block, err := it.Block()
if err != nil {
return nil, err
}
_, commitments, err = core.Post0132Hash(block, stateUpdate.StateDiff)
if err != nil {
return nil, err
}
} else {
commitments, err = h.bcReader.BlockCommitmentsByNumber(header.Number)
if err != nil {
return nil, err
}
}

return &spec.BlockHeadersResponse{
HeaderMessage: &spec.BlockHeadersResponse_Header{
Expand Down

0 comments on commit cdf8552

Please sign in to comment.