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

Add synchronized flag to subscriptions #235

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

nguyer
Copy link
Contributor

@nguyer nguyer commented Jul 24, 2023

This PR adds a new flag to a subscription to indicate whether ETHConnect is still catching up or has caught up to the configured block height gap, and is keeping up with the chain head. When you do a GET on a subscription you will now see a synchronized field like this:

    {
        "created": "2023-07-24T17:02:29Z",
        "id": "sb-6e37fa9f-1a8c-48e1-6159-0f15701e15e5",
        "path": "/subscriptions/sb-6e37fa9f-1a8c-48e1-6159-0f15701e15e5",
        "name": "default_BatchPin_3078626437333333",
        "stream": "es-900f1d84-22fd-470f-54cd-b87d3e9e475a",
        "filter": {
            "address": [
                "0xbd7333f75351fe1bfc0e6f0bf2c01fc185beaf4a"
            ],
            "topics": [
                [
                    "0x805721bc246bccc732581be0c0aa2dd8f7ec93e97ba4b307be84428c98b0a12f"
                ]
            ]
        },
        "event": {
            "type": "event",
            "name": "BatchPin",
            "inputs": [
                {
                    "name": "author",
                    "type": "address",
                    "internalType": "address"
                },
                {
                    "name": "timestamp",
                    "type": "uint256",
                    "internalType": "uint256"
                },
                {
                    "name": "namespace",
                    "type": "string",
                    "internalType": "string"
                },
                {
                    "name": "uuids",
                    "type": "bytes32",
                    "internalType": "bytes32"
                },
                {
                    "name": "batchHash",
                    "type": "bytes32",
                    "internalType": "bytes32"
                },
                {
                    "name": "payloadRef",
                    "type": "string",
                    "internalType": "string"
                },
                {
                    "name": "contexts",
                    "type": "bytes32[]",
                    "internalType": "bytes32[]"
                }
            ],
            "outputs": null
        },
        "fromBlock": "latest",
        "synchronized": true
    }

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
@codecov-commenter
Copy link

Codecov Report

Merging #235 (c6d4152) into main (7791bec) will increase coverage by 0.00%.
The diff coverage is n/a.

❗ Current head c6d4152 differs from pull request most recent head e4bd748. Consider uploading reports for the commit e4bd748 to get more accurate results

@@           Coverage Diff           @@
##             main     #235   +/-   ##
=======================================
  Coverage   97.26%   97.26%           
=======================================
  Files          59       59           
  Lines        7521     7524    +3     
=======================================
+ Hits         7315     7318    +3     
- Misses        163      164    +1     
+ Partials       43       42    -1     

see 3 files with indirect coverage changes

Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

Really small (hopefully) request here @nguyer so that we don't return true until we've processed the logs between the end of the catchup window, and the head of the chain.

@@ -214,6 +215,7 @@ func (s *subscription) createFilter(ctx context.Context, since *big.Int) error {
return errors.Errorf(errors.RPCCallReturnedError, "eth_newFilter", err)
}
s.catchupBlock = nil // we are not in catchup mode now
s.info.Synchronized = true
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should wait to flick this to true until we've done our first eth_getFilterLogs and switch to eth_getFilterChanges:

if s.filteredOnce {
rpcMethod = "eth_getFilterChanges"
}

Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

👍 - thanks for making that tweak. Looks great

@peterbroadhurst peterbroadhurst merged commit 5fee4d0 into hyperledger:main Jul 25, 2023
2 checks passed
@peterbroadhurst peterbroadhurst deleted the synchronized branch July 25, 2023 20:34
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.

3 participants