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

Bug at startup where FireFly gives up creating listeners if cannot reach transaction manager #1532

Open
EnriqueL8 opened this issue Jun 20, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@EnriqueL8
Copy link
Contributor

As part of the startup flow of FireFly, it will reconcile the intent from its database and call the relevant plugins. For example, it will make sure to activate the toke pools (listen to token pool events) or make sure the contract listeners are created in the transaction manager layer. The latter is the source of this bug and the the listener will never be created against the transaction manager. The worst part is that is fails silently, only when you retrieve the listener then in the status you will see that it cannot find the listener in the blockchain connector as such:

 "status": {
    "error": "FF10111: Error from ethereum connector: {\"error\":\"FF21046: Event listener '0190119e-0627-9252-799e-0c02208b939c' not found\"}"
  }

This will cause FireFly to never listen to those events and not let the user know that an issue has occurred. It's a bug in the way the Contract Manager handles errors from the transaction manager

@EnriqueL8 EnriqueL8 added the bug Something isn't working label Jun 20, 2024
@peterbroadhurst
Copy link
Contributor

This will cause FireFly to never listen to those events and not let the user know that an issue has occurred. It's a bug in the way the Contract Manager handles errors from the transaction manager

I'm not convinced this is a full diagnosis here @EnriqueL8

If you have this level of detail worked out, I think logs of the success and failure cases would be helpful

@peterbroadhurst
Copy link
Contributor

Note that I expect the testing, code changes and investigation of this one to overlap with the changes under discussion in #1531

@EnriqueL8
Copy link
Contributor Author

EnriqueL8 commented Jun 26, 2024

Managed to replicate this one manually but unsure how this could occur at startup.

To replicate it, you can simply delete the listener in the blockchain connector and then query the listener on the FireFly API under /contract/listeners/<id> as part of that flow it will go and fetch the latest checkpoint information from the blockchain connector. If it cannot find it it will just give you:

 "status": {
    "error": "FF10111: Error from ethereum connector: {\"error\":\"FF21046: Event listener '01905405-6c96-0afe-9189-2796811ff49a' not found\"}"
  }

I does make me think that if we do not find the listener in the connector at query time we should created it.

If I delete the eventstream you get the same error, so I'm going to do a test of upgrading to 1.3 from 1.2.2 to see if I can replicate this issue

@peterbroadhurst
Copy link
Contributor

Thanks @EnriqueL8 - going to take another look my side to understand the code better.

My naive reading of the code suggested that if err != nil in the below block, we would return err rather than dropping down to cm.blockchain.AddContractListener.

I'd coupled that to the "status": return above, because that also calls GetContractListenerStatus

func (cm *contractManager) checkContractListenerExists(ctx context.Context, listener *core.ContractListener) error {
found, _, _, err := cm.blockchain.GetContractListenerStatus(ctx, listener.Namespace, listener.BackendID, true)
if err != nil {
log.L(ctx).Errorf("Validating listener %s:%s (BackendID=%s) failed: %s", listener.Signature, listener.ID, listener.BackendID, err)
return err
}

@peterbroadhurst
Copy link
Contributor

Ok - so the thing I missed here is the true being passed down for okNotFound, so the FF10111 error isn't actually passed to this code.

So I don't think we have a concrete issue to investigate there currently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants