-
Notifications
You must be signed in to change notification settings - Fork 14
Solana USDC Reader #1022
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
base: main
Are you sure you want to change the base?
Solana USDC Reader #1022
Conversation
f6c2bda
to
24926a3
Compare
* Updated USDC reader queries and binding * Added CCTP event query to constructor for test * Cleaned up test code and added new contract name const * Fixed lint error * Fixed lint error * Updated Solana USDC reader to use the SourceMessageTransmitter address
pkg/reader/usdc_reader.go
Outdated
keyFilter, err := query.Where( | ||
// Using same as EVM for consistency. Only used by off-chain components so name does not have to align with on-chain | ||
consts.EventNameCCTPMessageSent, | ||
expressions..., |
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.
I think this logic could break if we get multiple CCTP data. The default operator in the LogPoller is AND
so stringing expressions together like this would make a query like nonce=1 && domain=5 && nonce=2 && domain=5
. I think we probably need to use the Or comparator here
expressions..., | |
query.Or(expressions...), |
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.
Oh and we should probably move the query.Confidence(primitives.Finalized)
from above here so it doesn't get mixed up the with the nonce/domain queries
expressions..., | |
query.Confidence(primitives.Finalized), | |
expressions..., |
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.
Unresolving this since I noticed the query.Confidence(primitives.Finalized)
expression wasn't moved down into the where clause
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.
It would be great to have some e2e tests to cover that, especially to cover the full flow with CR/LogPoller for Solana
pkg/reader/usdc_reader.go
Outdated
|
||
// Query the token pool contract for the MessageSent event data. | ||
expressions := []query.Expression{query.Confidence(primitives.Finalized)} | ||
for _, data := range cctpData { |
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.
That would definitely require perf tests using database like the ones we have for evm usdc reader
https://github.com/smartcontractkit/chainlink/blob/develop/core/capabilities/ccip/ccip_integration_tests/usdcreader/usdcreader_test.go
|
@@ -127,6 +127,13 @@ func (p *Plugin) Observation( | |||
"numCommitReports", numCommitReports, | |||
"numMessages", observation.Messages.Count()) | |||
|
|||
lggr.Debugw("[verbose] execute plugin got observation", |
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.
Do we want to keep it? There might be non-zero overhead to json serialization of observation
with every round.
@@ -128,12 +128,16 @@ func (s *USDCAttestationClient) fetchSingleMessage( | |||
messageHash := cciptypes.Bytes32(s.hasher.Hash(message)) | |||
body, _, err := s.client.Get(ctx, fmt.Sprintf("%s/%s/%s", apiVersion, attestationPath, messageHash.String())) | |||
if err != nil { | |||
s.lggr.Warnw("Failed to fetch attestation from the API", "err", err) |
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.
👍 I think it might be an error level
return tokendata.ErrorAttestationStatus(err) | ||
} | ||
response, err := attestationFromResponse(body) | ||
if err != nil { | ||
s.lggr.Warnw("Failed to parse attestation from the response", "err", err, "body", body) |
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.
ditto
@@ -20,6 +18,9 @@ import ( | |||
"github.com/smartcontractkit/chainlink-ccip/pluginconfig" | |||
) | |||
|
|||
// USDCMessageReader retrieves each of the CCTPv1 MessageSent event created | |||
// during the Commit phase of the USDC token transfer. The events are created |
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.
nit, but MessageSent
events are created when a message is sent via Router - as a part of that transaction OnRamp interacts with USDCTokenPool, which interacts with Circle contracts. Technically, it's before Commit (assuming Sol works similar to EVM)
} | ||
case sel.FamilySolana: | ||
// Bind the TokenPool contract, the contract re-emits the USDC MessageSent event along with other metadata. | ||
bytesAddress, err := addrCodec.AddressStringToBytes(token.SourceMessageTransmitterAddr, chainSelector) |
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.
Not sure if it's set for both families, but we will need to have time retention set for these events just to make sure we don't store them forever
keyFilter, err := query.Where( | ||
// Using same as EVM for consistency. Only used by off-chain components so name does not have to align with on-chain | ||
consts.EventNameCCTPMessageSent, | ||
query.Confidence(primitives.Finalized), |
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.
nit, not sure how adding finalization check impacts db query performance for Solana, but it might be redundant. By the time we reach this place message is already committed so it's already finalized - at least this is how it works for EVM
@@ -212,6 +230,12 @@ func AllAvailableDomains() map[uint64]uint32 { | |||
return destDomains | |||
} | |||
|
|||
type evmUSDCMessageReader struct { |
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.
minor, but if you extracted Solana to a separate file then I would extract evm implementation to usd_reader_evm.go
and keep only the factory/interfaces in usdc_reader.go
@@ -0,0 +1,157 @@ | |||
package reader |
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.
Any tests for Solana? Or would that be covered/tested in Chainlink repository with e2e tests?
No description provided.