-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
ccip - EVM Implementation of RMNCrypto interface #14416
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f0785ec
upgrade cl-common to RMNCrypto iface branch
dimkouv 9791c77
implement RMN crypto evm ecdsa sig verifier
dimkouv b7b21eb
personal code review
dimkouv 15f9df9
merge develop
dimkouv 2eaaf3e
no panics
dimkouv ab6c88a
Merge branch 'develop' into dk/ccip-impl-rmncrypto
dimkouv 9f3af71
changeset
dimkouv bba042d
Merge branch 'dk/ccip-impl-rmncrypto' of github.com:smartcontractkit/…
dimkouv a67d04c
add comment
dimkouv f70efc5
fix linter errs
dimkouv bd09438
makramkd code review fixes
dimkouv b3ed3aa
Merge branch 'develop' into dk/ccip-impl-rmncrypto
dimkouv 3659bb5
Merge branch 'develop' into dk/ccip-impl-rmncrypto
dimkouv 59effa1
goimports
dimkouv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
no panics
- Loading branch information
commit 2eaaf3e4e418067928f317b2ccdbafa6649d24c6
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,30 +20,33 @@ import ( | |
const encodingUtilsAbiRaw = `[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"DoNotDeploy","type":"error"},{"inputs":[{"internalType":"bytes32","name":"rmnReportVersion","type":"bytes32"},{"components":[{"internalType":"uint256","name":"destChainId","type":"uint256"},{"internalType":"uint64","name":"destChainSelector","type":"uint64"},{"internalType":"address","name":"rmnRemoteContractAddress","type":"address"},{"internalType":"address","name":"offrampAddress","type":"address"},{"internalType":"bytes32","name":"rmnHomeContractConfigDigest","type":"bytes32"},{"components":[{"internalType":"uint64","name":"sourceChainSelector","type":"uint64"},{"internalType":"bytes","name":"onRampAddress","type":"bytes"},{"internalType":"uint64","name":"minSeqNr","type":"uint64"},{"internalType":"uint64","name":"maxSeqNr","type":"uint64"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"internalType":"struct Internal.MerkleRoot[]","name":"destLaneUpdates","type":"tuple[]"}],"internalType":"struct RMNRemote.Report","name":"rmnReport","type":"tuple"}],"name":"_rmnReport","outputs":[],"stateMutability":"nonpayable","type":"function"}]` | ||
const addressEncodeAbiRaw = `[{"name":"method","type":"function","inputs":[{"name": "", "type": "address"}]}]` | ||
|
||
// EVMRMNCrypto is the RMNCrypto implementation for EVM chains. | ||
type EVMRMNCrypto struct { | ||
encodingUtilsABI abi.ABI | ||
addressEncodeABI abi.ABI | ||
} | ||
var ( | ||
EncodingUtilsABI abi.ABI | ||
AddressEncodeABI abi.ABI | ||
) | ||
|
||
// Interface compliance check | ||
var _ cciptypes.RMNCrypto = (*EVMRMNCrypto)(nil) | ||
func init() { | ||
var err error | ||
|
||
func NewEVMRMNCrypto() *EVMRMNCrypto { | ||
encodingUtilsABI, err := abi.JSON(strings.NewReader(encodingUtilsAbiRaw)) | ||
EncodingUtilsABI, err = abi.JSON(strings.NewReader(encodingUtilsAbiRaw)) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to parse encoding utils ABI: %v", err)) | ||
} | ||
|
||
addressEncodeABI, err := abi.JSON(strings.NewReader(addressEncodeAbiRaw)) | ||
AddressEncodeABI, err = abi.JSON(strings.NewReader(addressEncodeAbiRaw)) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to parse address encode ABI: %v", err)) | ||
} | ||
} | ||
|
||
return &EVMRMNCrypto{ | ||
encodingUtilsABI: encodingUtilsABI, | ||
addressEncodeABI: addressEncodeABI, | ||
} | ||
// EVMRMNCrypto is the RMNCrypto implementation for EVM chains. | ||
type EVMRMNCrypto struct{} | ||
|
||
// Interface compliance check | ||
var _ cciptypes.RMNCrypto = (*EVMRMNCrypto)(nil) | ||
|
||
func NewEVMRMNCrypto() *EVMRMNCrypto { | ||
return &EVMRMNCrypto{} | ||
} | ||
|
||
type evmRMNRemoteReport struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a TODO also to use the types from the gethwrappers when they're available? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
|
@@ -64,7 +67,7 @@ type evmInternalMerkleRoot struct { | |
} | ||
|
||
func (r *EVMRMNCrypto) VerifyReportSignatures( | ||
ctx context.Context, | ||
_ context.Context, | ||
sigs []cciptypes.RMNECDSASignature, | ||
report cciptypes.RMNReport, | ||
signerAddresses []cciptypes.Bytes, | ||
|
@@ -83,7 +86,7 @@ func (r *EVMRMNCrypto) VerifyReportSignatures( | |
evmLaneUpdates := make([]evmInternalMerkleRoot, len(report.LaneUpdates)) | ||
for i, lu := range report.LaneUpdates { | ||
onRampAddress := common.BytesToAddress(lu.OnRampAddress) | ||
onRampAddrAbi, err := abiEncodeMethodInputs(r.addressEncodeABI, onRampAddress) | ||
onRampAddrAbi, err := abiEncodeMethodInputs(AddressEncodeABI, onRampAddress) | ||
if err != nil { | ||
return fmt.Errorf("ΑΒΙ encode onRampAddress: %w", err) | ||
} | ||
|
@@ -105,7 +108,7 @@ func (r *EVMRMNCrypto) VerifyReportSignatures( | |
DestLaneUpdates: evmLaneUpdates, | ||
} | ||
|
||
abiEnc, err := r.encodingUtilsABI.Methods["_rmnReport"].Inputs.Pack(rmnVersionHash, evmReport) | ||
abiEnc, err := EncodingUtilsABI.Methods["_rmnReport"].Inputs.Pack(rmnVersionHash, evmReport) | ||
if err != nil { | ||
return fmt.Errorf("failed to ABI encode args: %w", err) | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can be private?
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.
sure