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

[KS-182] keystone: Refactor write_capability + add ChainWriter #13259

Merged
merged 40 commits into from
May 31, 2024

Conversation

archseer
Copy link
Contributor

@archseer archseer commented May 20, 2024

  • Use chainwriter
  • Move evm specific init under the evm relayer
  • Check if report already delivered via chainreader

cr.Bind(ctx, []commontypes.BoundContract{{
Address: config.ForwarderAddress().String(),
Name: "forwarder",
// Pending: false, // ???
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nolag I couldn't find any documentation on what this flag does

Copy link
Contributor

Choose a reason for hiding this comment

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

If you are reading a contract method it doesn't really do anything.

Copy link
Contributor

@ilija42 ilija42 May 20, 2024

Choose a reason for hiding this comment

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

If you are reading a log event it translated to confirmations Finalized/Unfinalized, will be changed soon to make more sense

@archseer archseer requested a review from cedric-cordenier May 31, 2024 03:47
// SignalCallback: true, TODO: add code that checks if a workflow id is present, if so, route callback to chainwriter rather than pipeline
}
tx, err := txm.CreateTransaction(ctx, req)
txID, err := uuid.NewUUID() // TODO(archseer): it seems odd that CW expects us to generate an ID, rather than return one
Copy link
Contributor

Choose a reason for hiding this comment

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

This TODO is not really actionable, I'd remove it.

if err != nil {
// Check whether value was already transmitted on chain
queryInputs := struct {
Receiver string
Copy link
Contributor

Choose a reason for hiding this comment

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

You might need to add ReportID here but let's merge this PR first and then handle new meta fields separately.

txm := cap.chain.TxManager()
func success() <-chan capabilities.CapabilityResponse {
callback := make(chan capabilities.CapabilityResponse)
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can create a channel with size 1 and avoid this goroutine.

func success() <-chan capabilities.CapabilityResponse {
callback := make(chan capabilities.CapabilityResponse)
go func() {
callback <- capabilities.CapabilityResponse{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we want to put some info in the response? For example whether we attempted transmission or not. Maybe not important atm but let's consider it in the future.

_, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

// TODO(nickcorin): Add shutdown steps here.
Copy link
Contributor

Choose a reason for hiding this comment

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

are there any?

}

// Initialize write target capability if configuration is defined
if chain.Config().EVM().ChainWriter().ForwarderAddress() != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably rename this to "KeystoneForwarderAddress" to not be confused with Operator Forwarders.

}
cw := NewChainWriterService(lggr.Named("ChainWriter"), chain.Client(), chain.TxManager(), chainWriterConfig)

return targets.NewWriteTarget(lggr, name, cr, cw, config.ForwarderAddress().String()), 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 we avoid having two objects with the same name "WriteTarget"?

ChainSpecificName: "report",
Checker: "simulate",
FromAddress: config.FromAddress().Address(),
GasLimit: 200_000,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be in TOML config (separate PR)

@archseer archseer requested a review from ilija42 May 31, 2024 07:12
@archseer archseer enabled auto-merge May 31, 2024 07:12
@archseer archseer added this pull request to the merge queue May 31, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 31, 2024
@archseer archseer added this pull request to the merge queue May 31, 2024
Merged via the queue into develop with commit 76dbe19 May 31, 2024
109 checks passed
@archseer archseer deleted the cap-idempotent-writes branch May 31, 2024 09:16
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.

7 participants