Skip to content

Commit

Permalink
ReportFormat => uint32 (#32)
Browse files Browse the repository at this point in the history
* ReportFormat => uint32

* Bump cl-common
  • Loading branch information
samsondav authored Feb 20, 2024
1 parent 0b183f7 commit 09be0ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/shopspring/decimal v1.3.1
github.com/smartcontractkit/chain-selectors v1.0.5
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216155433-cbc18ce56182
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220201513-6cb818f8800d
github.com/smartcontractkit/libocr v0.0.0-20240112202000-6359502d2ff1
github.com/stretchr/testify v1.8.4
google.golang.org/protobuf v1.32.0
Expand Down Expand Up @@ -36,6 +36,7 @@ require (
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/mwitkow/grpc-proxy v0.0.0-20230212185441-f345521cb9c9 // indirect
github.com/oklog/run v1.0.0 // indirect
Expand Down
10 changes: 8 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,14 @@ github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5g
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/smartcontractkit/chain-selectors v1.0.5 h1:NOefQsogPZS4aBbWPFrgAyoke0gppN2ojfa8SQkhu8c=
github.com/smartcontractkit/chain-selectors v1.0.5/go.mod h1:WBhLlODF5b95vvx2tdKK55vGACg1+qZpuBhOGu1UXVo=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216155433-cbc18ce56182 h1:V7IrB822iwWmgMwy1zdOMLXUU4gJ53suzvHW54AyoUY=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216155433-cbc18ce56182/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216181624-ccf0da042f11 h1:zazCJSjz60/V5B8+8LxLX7BrtN1AXGUv+B/E1Xrq2OA=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240216181624-ccf0da042f11/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220164325-44ed6b4009cb h1:E0K6uq+9SjpktUeqTg8NVarUAfwRBL/reIuZb4msrtA=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220164325-44ed6b4009cb/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220165243-0b144b02fd8d h1:OOezTy1Z4sITGuOx3oegof47O0AbloW/YLPjzVLXn1E=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220165243-0b144b02fd8d/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220201513-6cb818f8800d h1:XByRw7oF2mG+yBuoMpBqm5Ogu1vlunPZfhL74Ny3NFU=
github.com/smartcontractkit/chainlink-common v0.1.7-0.20240220201513-6cb818f8800d/go.mod h1:6aXWSEQawX2oZXcPPOdxnEGufAhj7PqPKolXf6ijRGA=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16 h1:TFe+FvzxClblt6qRfqEhUfa4kFQx5UobuoFGO2W4mMo=
github.com/smartcontractkit/go-plugin v0.0.0-20240208201424-b3b91517de16/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI=
github.com/smartcontractkit/grpc-proxy v0.0.0-20230731113816-f1be6620749f h1:hgJif132UCdjo8u43i7iPN1/MFnu49hv7lFGFftCHKU=
Expand Down
20 changes: 3 additions & 17 deletions llo/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,12 @@ type PredecessorRetirementReportCache interface {
CheckAttestedRetirementReport(predecessorConfigDigest ocr2types.ConfigDigest, attestedRetirementReport []byte) (RetirementReport, error)
}

const (
// NOTE: ReportFormat strings should be constrained to a maximum of 8 chars
// since they need to be stored on-chain
ReportFormatEVM llotypes.ReportFormat = "evm"
ReportFormatJSON llotypes.ReportFormat = "json"
ReportFormatSolana llotypes.ReportFormat = "solana"
ReportFormatCosmos llotypes.ReportFormat = "cosmos"
ReportFormatStarknet llotypes.ReportFormat = "starknet"
)

// MakeChannelHash is used for mapping ChannelDefinitionWithIDs
func MakeChannelHash(cd ChannelDefinitionWithID) ChannelHash {
h := sha256.New()
merr := errors.Join(
binary.Write(h, binary.BigEndian, cd.ChannelID),
binary.Write(h, binary.BigEndian, uint32(len(cd.ReportFormat))),
)
_, err := h.Write([]byte(cd.ReportFormat))
merr = errors.Join(merr,
err,
binary.Write(h, binary.BigEndian, cd.ReportFormat),
binary.Write(h, binary.BigEndian, cd.ChainSelector),
binary.Write(h, binary.BigEndian, uint32(len(cd.StreamIDs))),
)
Expand Down Expand Up @@ -793,7 +779,7 @@ type Report struct {
func (p *LLOPlugin) encodeReport(r Report, format llotypes.ReportFormat) (types.Report, error) {
codec, exists := p.Codecs[format]
if !exists {
return nil, fmt.Errorf("codec missing for ReportFormat=%s", format)
return nil, fmt.Errorf("codec missing for ReportFormat=%d", format)
}
return codec.Encode(r)
}
Expand Down Expand Up @@ -841,7 +827,7 @@ func (p *LLOPlugin) Reports(seqNr uint64, rawOutcome ocr3types.Outcome) ([]ocr3t
Report: must(json.Marshal(retirementReport)),
Info: llotypes.ReportInfo{
LifeCycleStage: outcome.LifeCycleStage,
ReportFormat: ReportFormatJSON,
ReportFormat: llotypes.ReportFormatJSON,
},
})
}
Expand Down

0 comments on commit 09be0ea

Please sign in to comment.