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

Update reporting plugin factory constructors #20

Merged
merged 24 commits into from
Jul 17, 2024

Conversation

makramkd
Copy link
Collaborator

@makramkd makramkd commented Jul 4, 2024

We need to inject the required dependencies in order for the plugins to correctly function.

@makramkd makramkd force-pushed the mk/plugin-factory-constructors branch from b7620f0 to 923e0ca Compare July 15, 2024 12:10
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Renamed package to consts since its not just chain reader stuff.

@makramkd makramkd marked this pull request as ready for review July 17, 2024 15:41
@@ -35,42 +38,88 @@ func (p PluginFactoryConstructor) NewReportingPluginFactory(
keyValueStore core.KeyValueStore,
relayerSet core.RelayerSet,
) (core.OCR3ReportingPluginFactory, error) {
return NewPluginFactory(), nil
return nil, errors.New("unimplemented")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We'll revisit this when the loopification work starts.

Comment on lines +117 to +119
MaxObservationLength: 20_000, // 20kB
MaxOutcomeLength: 10_000, // 10kB
MaxReportLength: 10_000, // 10kB
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are ballpark, we'll revisit as we test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be read from config in the future?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No these will likely be constants, but might not be these values.

@@ -157,7 +157,7 @@ func (p *Plugin) Observation(
// If there's no previous outcome (first round ever), we only observe the latest committed sequence numbers.
// and on the next round we use those to look for messages.
if outctx.PreviousOutcome == nil {
p.lggr.Debugw("first round ever, can't observe new messages yet")
p.lggr.Infow("first round ever, can't observe new messages yet")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Making these info because turning on debug logs in the CL node brings an avalanche of logs that are not relevant.

Copy link
Contributor

Choose a reason for hiding this comment

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

but then it will always show even without turning on debug logs, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Log levels filter downards, so Debug means Debug and all levels above, Info means Info and all levels above, etc.

@makramkd makramkd requested review from winder and 0xnogo July 17, 2024 15:48
Copy link
Contributor

@dimkouv dimkouv left a comment

Choose a reason for hiding this comment

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

🚀 (approving with minor comments)

commit/factory.go Outdated Show resolved Hide resolved
commit/factory.go Outdated Show resolved Hide resolved
@@ -167,7 +167,7 @@ func (p *Plugin) Observation(
if err != nil {
return types.Observation{}, fmt.Errorf("decode commit plugin previous outcome: %w", err)
}
p.lggr.Debugw("previous outcome decoded", "outcome", prevOutcome.String())
p.lggr.Infow("previous outcome decoded", "outcome", prevOutcome.String())
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't String() used by default? (not sure)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not 100% sure but doesn't hurt. I think depending on the logger it sometimes tries to json encode it.

execute/factory.go Outdated Show resolved Hide resolved
internal/reader/ccip.go Outdated Show resolved Hide resolved
for chain, cfg := range sourceConfigs {
if cfg.OnRamp == "" {
if len(cfg.OnRamp) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe cfg.OnRamp == nil ? not sure what's more idiomatic

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is more idiomatic, since both nil and the empty slice will have length zero.

Address: cfg.OnRamp,
Name: crconsts.ContractNameOnRamp,
// TODO: revisit, this is EVM specific.
Address: "0x" + hex.EncodeToString(cfg.OnRamp),
Copy link
Contributor

Choose a reason for hiding this comment

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

re-use the func to convert bytes to string

commit/factory.go Outdated Show resolved Hide resolved
@@ -349,7 +349,7 @@ func (p *Plugin) ShouldTransmitAcceptedReport(
return false, fmt.Errorf("validate merkle roots state: %w", err)
}

p.lggr.Debugw("transmitting report",
p.lggr.Infow("transmitting report",
Copy link
Contributor

Choose a reason for hiding this comment

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

Making this one Info level seems fine.... not sure about the others. Making everything Info means there would be an avalanche of Info logs as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We'll have to revisit these later, for now I think this is slightly better than turning on Debug and getting all the debug logs of the app.

Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

I think you might have gotten a little carried away with Debug -> Info. Other than that, LGTM.

// defaultMsgScanBatchSize is the default batch size for sequence number range queries.
// Since 256 messages is the limit for a merkle root, this is set to 256.
// NOTE: maybe we can also set this in the OCR config, offchainConfig.
defaultMsgScanBatchSize = 256
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like there's already a constant for this

Suggested change
defaultMsgScanBatchSize = 256
defaultMsgScanBatchSize = merklemulti.MaxNumberTreeLeaves

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, just used that const directly.

Copy link

Test Coverage

Branch Coverage
mk/plugin-factory-constructors 74.8%
ccip-develop 75.6%

@makramkd makramkd merged commit 0bcfc8e into ccip-develop Jul 17, 2024
1 check passed
@makramkd makramkd deleted the mk/plugin-factory-constructors branch July 17, 2024 20:24
makramkd added a commit to smartcontractkit/ccip that referenced this pull request Jul 18, 2024
## Motivation

We still need to create the plugin and bootstrap oracles, meaning there
needs to be a concrete implementation of the `OracleCreator` interface.

## Solution

Implement the `OracleCreator` interface. An end to end Integration test
is also included in this PR, which tests commit reports. However, these
commit reports do NOT contain merkle roots, some issues need to be
resolved in upcoming PRs which involve changes in chainlink-common.

## Notes

* This PR is using `legacyevm` instead of relayers because chain writer
changes have not yet fully propagated to this repo. Once they have we
can update the implementation to use the relayers.

## Requires

* smartcontractkit/chainlink-ccip#20

---------

Co-authored-by: Abdelrahman Soliman (Boda) <2677789+asoliman92@users.noreply.github.com>
Co-authored-by: asoliman <abdelrahman.soliman@smartcontract.com>
0xnogo pushed a commit to smartcontractkit/ccip that referenced this pull request Jul 19, 2024
We still need to create the plugin and bootstrap oracles, meaning there
needs to be a concrete implementation of the `OracleCreator` interface.

Implement the `OracleCreator` interface. An end to end Integration test
is also included in this PR, which tests commit reports. However, these
commit reports do NOT contain merkle roots, some issues need to be
resolved in upcoming PRs which involve changes in chainlink-common.

* This PR is using `legacyevm` instead of relayers because chain writer
changes have not yet fully propagated to this repo. Once they have we
can update the implementation to use the relayers.

* smartcontractkit/chainlink-ccip#20

---------

Co-authored-by: Abdelrahman Soliman (Boda) <2677789+asoliman92@users.noreply.github.com>
Co-authored-by: asoliman <abdelrahman.soliman@smartcontract.com>
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.

4 participants