Skip to content
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

timeout certificate can be nil #790

Merged
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
13 changes: 7 additions & 6 deletions access/grpc/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ func MessageToBlockHeader(m *entities.BlockHeader) (flow.BlockHeader, error) {
timestamp = m.GetTimestamp().AsTime()
}

tc, err := MessageToTimeoutCertificate(m.GetLastViewTc())
timeoutCertificate, err := MessageToTimeoutCertificate(m.GetLastViewTc())
if err != nil {
return flow.BlockHeader{}, err
return flow.BlockHeader{}, fmt.Errorf("error converting timeout certificate: %w", err)
}

return flow.BlockHeader{
Expand All @@ -285,19 +285,20 @@ func MessageToBlockHeader(m *entities.BlockHeader) (flow.BlockHeader, error) {
ProposerSigData: m.GetProposerSigData(),
ChainID: flow.HashToID([]byte(m.GetChainId())),
ParentVoterIndices: m.GetParentVoterIndices(),
LastViewTimeoutCertificate: tc,
LastViewTimeoutCertificate: timeoutCertificate,
ParentView: m.GetParentView(),
}, nil
}

func MessageToTimeoutCertificate(m *entities.TimeoutCertificate) (flow.TimeoutCertificate, error) {
if m == nil {
return flow.TimeoutCertificate{}, ErrEmptyMessage
// timeout certificate can be nil
return flow.TimeoutCertificate{}, nil
}

qc, err := MessageToQuorumCertificate(m.GetHighestQc())
if err != nil {
return flow.TimeoutCertificate{}, err
return flow.TimeoutCertificate{}, fmt.Errorf("error converting quorum certificate: %w", err)
}

return flow.TimeoutCertificate{
Expand Down Expand Up @@ -326,7 +327,7 @@ func TimeoutCertificateToMessage(tc flow.TimeoutCertificate) (*entities.TimeoutC

func MessageToQuorumCertificate(m *entities.QuorumCertificate) (flow.QuorumCertificate, error) {
if m == nil {
return flow.QuorumCertificate{}, ErrEmptyMessage
return flow.QuorumCertificate{}, fmt.Errorf("quourum certificate is empty: %w", ErrEmptyMessage)
}

return flow.QuorumCertificate{
Expand Down
2 changes: 1 addition & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.4
replace github.com/onflow/flow-go-sdk => ../

require (
github.com/onflow/cadence v1.0.1-0.20241018173327-2e72919b18ac
github.com/onflow/cadence v1.2.1
github.com/onflow/flow-cli/flowkit v1.11.0
github.com/onflow/flow-go-sdk v0.41.17
github.com/spf13/afero v1.11.0
Expand Down
1 change: 1 addition & 0 deletions examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ github.com/onflow/cadence v1.0.0-preview.38/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmp
github.com/onflow/cadence v1.0.0-preview.52/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU=
github.com/onflow/cadence v1.0.0/go.mod h1:7wvvecnAZtYOspLOS3Lh+FuAmMeSrXhAWiycC3kQ1UU=
github.com/onflow/cadence v1.0.1-0.20241018173327-2e72919b18ac/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg=
github.com/onflow/cadence v1.2.1/go.mod h1:fJxxOAp1wnWDfOHT8GOc1ypsU0RR5E3z51AhG8Yf5jg=
github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
Expand Down
Loading