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

[CCIP-5233] CCIP: price-only commit report method override. #16422

Open
wants to merge 7 commits into from

Conversation

winder
Copy link
Contributor

@winder winder commented Feb 14, 2025

Adds option to override the commit method for price-only commit reports.

Implemented by extending the ToExecCalldata handler to return the contract/method in addition to the args object.

Copy link
Contributor

github-actions bot commented Feb 14, 2025

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

Copy link
Contributor

github-actions bot commented Feb 14, 2025

AER Report: CI Core ran successfully ✅

aer_workflow , commit

AER Report: Operator UI CI ran successfully ✅

aer_workflow , commit

@winder winder force-pushed the will/price-only-transmit branch from 22d4b5b to 6dc66cf Compare February 15, 2025 22:46
archseer
archseer previously approved these changes Feb 18, 2025
Copy link
Contributor

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated on the e2e testing branch

@winder winder changed the title CCIP: price-only commit report method override. [CCIP-5233] CCIP: price-only commit report method override. Feb 18, 2025
@@ -23,54 +23,63 @@ type ToCalldataFunc func(
report ocr3types.ReportWithInfo[[]byte],
rs, ss [][32]byte,
vs [32]byte,
) (any, error)
) (string, string, any, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add names to the return vars to self-document

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can return a struct instead

) (any, error)
) (string, string, any, error)

func NewToCommitCalldata(defaultMethod, priceOnlyMethod string) ToCalldataFunc {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Godoc on this would be good to have, to explain its existence vs. lack of one for exec.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also NewToCommitCalldataFunc seems to be a better name given the ret val

if err != nil {
return nil, err
method := defaultMethod
if len(priceOnlyMethod) > 0 && len(info.MerkleRoots) == 0 && len(info.TokenPrices) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing len(string) seems awkward/non-idiomatic, I feel like priceOnlyMethod != "" reads better.

Also, if we always require a merkle root then shouldn't len(info.MerkleRoots) == 1? cc @archseer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making a note that you can't tweak this array here since it'll fail the sig check onchain, this has to come from the plugin.

Copy link
Contributor Author

@winder winder Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably it's invalid to have a report where len(info.MerkleRoots) == 0 && len(info.TokenPrices) == 0.

onchain method HasRoot(s) HasPrices
commit true true
commit true false
price_only_commit false true
N/A false false

I think the report codec should be responsible for detect if the report was invalid not the transmitter. So I'm proposing this code ignores the N/A case above.

Comment on lines -214 to +233
if err := c.cw.SubmitTransaction(ctx, c.contractName, c.method, args, fmt.Sprintf("%s-%s-%s", c.contractName, c.offrampAddress, txID.String()), c.offrampAddress, &meta, zero); err != nil {
if err := c.cw.SubmitTransaction(ctx, contract, method, args, fmt.Sprintf("%s-%s-%s", contract, c.offrampAddress, txID.String()), c.offrampAddress, &meta, zero); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't comment on the line in this PR but there is still some evm-specific signature splitting above (evmutil.SplitSignature) that may not work for Solana.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, damn. Thanks for pointing that out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On further investigation, evmutil.SplitSignature is just poorly named. It should be named ecdsautil.SplitSignature. It's unlikely that we'd use a different signature for OCR reports, so this is not something that would change now or in the future.

@@ -316,7 +317,7 @@ func newTestUniverse(t *testing.T, ks *keyringsAndSigners[[]byte]) *testUniverse
contractName,
methodTransmitWithSignatures,
ocr3HelperAddr.Hex(),
ocrimpls.ToCommitCalldata,
ocrimpls.NewToCommitCalldata(consts.MethodCommit, ""),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a test for the Solana transmission?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Solana e2e test would cover this. I'm not sure how a unit test would work.

Comment on lines +102 to +98
// PriceOnlyCommitFn optional method override for price only commit reports.
PriceOnlyCommitFn string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where/how would this get set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's set a few lines above. Hard coded for the Solana chain family.

@winder
Copy link
Contributor Author

winder commented Feb 19, 2025

@makramkd @dimkouv created a ticket for future refactoring:
https://smartcontract-it.atlassian.net/browse/CCIP-5276

matYang
matYang previously approved these changes Feb 23, 2025
@winder winder dismissed stale reviews from matYang and archseer via 3a02939 February 25, 2025 13:00
@winder winder force-pushed the will/price-only-transmit branch from 926456a to 9c75cee Compare February 25, 2025 21:23
@winder winder force-pushed the will/price-only-transmit branch from 9c75cee to 7182d62 Compare February 26, 2025 15:15
@makramkd
Copy link
Contributor

Can you merge in latest develop so the in-memory tests can run as well? There was a hiccup recently #16586

@archseer archseer enabled auto-merge February 27, 2025 05:43
@archseer archseer added this pull request to the merge queue Feb 27, 2025
Any commits made after this event will not be merged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants