-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Node API OCR3 delegate support (#11993)
* OCR3 delegate support * -Move adapters -Convert if statement to switch * - Add adapters tests - Pin to new version of chainlink-common * - Pin to new version of chainlink-common * Fix go sum * Pin to latest version of chainlink-common
- Loading branch information
1 parent
2784f9b
commit c84f1b5
Showing
10 changed files
with
312 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package ocrcommon | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" | ||
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" | ||
) | ||
|
||
var _ ocr3types.OnchainKeyring[any] = (*OCR3OnchainKeyringAdapter)(nil) | ||
|
||
type OCR3OnchainKeyringAdapter struct { | ||
o ocrtypes.OnchainKeyring | ||
} | ||
|
||
func NewOCR3OnchainKeyringAdapter(o ocrtypes.OnchainKeyring) *OCR3OnchainKeyringAdapter { | ||
return &OCR3OnchainKeyringAdapter{o} | ||
} | ||
|
||
func (k *OCR3OnchainKeyringAdapter) PublicKey() ocrtypes.OnchainPublicKey { | ||
return k.o.PublicKey() | ||
} | ||
|
||
func (k *OCR3OnchainKeyringAdapter) Sign(digest ocrtypes.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[any]) (signature []byte, err error) { | ||
return k.o.Sign(ocrtypes.ReportContext{ | ||
ReportTimestamp: ocrtypes.ReportTimestamp{ | ||
ConfigDigest: digest, | ||
Epoch: uint32(seqNr), | ||
Round: 0, | ||
}, | ||
ExtraHash: [32]byte(make([]byte, 32)), | ||
}, r.Report) | ||
} | ||
|
||
func (k *OCR3OnchainKeyringAdapter) Verify(opk ocrtypes.OnchainPublicKey, digest ocrtypes.ConfigDigest, seqNr uint64, ri ocr3types.ReportWithInfo[any], signature []byte) bool { | ||
return k.o.Verify(opk, ocrtypes.ReportContext{ | ||
ReportTimestamp: ocrtypes.ReportTimestamp{ | ||
ConfigDigest: digest, | ||
Epoch: uint32(seqNr), | ||
Round: 0, | ||
}, | ||
ExtraHash: [32]byte(make([]byte, 32)), | ||
}, ri.Report, signature) | ||
} | ||
|
||
func (k *OCR3OnchainKeyringAdapter) MaxSignatureLength() int { | ||
return k.o.MaxSignatureLength() | ||
} | ||
|
||
var _ ocr3types.ContractTransmitter[any] = (*OCR3ContractTransmitterAdapter)(nil) | ||
|
||
type OCR3ContractTransmitterAdapter struct { | ||
ct ocrtypes.ContractTransmitter | ||
} | ||
|
||
func NewOCR3ContractTransmitterAdapter(ct ocrtypes.ContractTransmitter) *OCR3ContractTransmitterAdapter { | ||
return &OCR3ContractTransmitterAdapter{ct} | ||
} | ||
|
||
func (c *OCR3ContractTransmitterAdapter) Transmit(ctx context.Context, digest ocrtypes.ConfigDigest, seqNr uint64, r ocr3types.ReportWithInfo[any], signatures []ocrtypes.AttributedOnchainSignature) error { | ||
return c.ct.Transmit(ctx, ocrtypes.ReportContext{ | ||
ReportTimestamp: ocrtypes.ReportTimestamp{ | ||
ConfigDigest: digest, | ||
Epoch: uint32(seqNr), | ||
Round: 0, | ||
}, | ||
ExtraHash: [32]byte(make([]byte, 32)), | ||
}, r.Report, signatures) | ||
} | ||
|
||
func (c *OCR3ContractTransmitterAdapter) FromAccount() (ocrtypes.Account, error) { | ||
return c.ct.FromAccount() | ||
} |
Oops, something went wrong.