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 support for private log subscriptions (Pub-Sub API) #762

Closed
lucassaldanha opened this issue Apr 21, 2020 · 0 comments · Fixed by #858
Closed

Add support for private log subscriptions (Pub-Sub API) #762

lucassaldanha opened this issue Apr 21, 2020 · 0 comments · Fixed by #858
Assignees
Labels
privacy private transactions

Comments

@lucassaldanha
Copy link
Member

lucassaldanha commented Apr 21, 2020

Description

At the moment, the only options for retrieving logs generated by private contracts are using prig_getLogs or private filters.

It would be nice to also offer support for subscribing to private events.

This subscription would be similar to eth_subscribe (we should name it priv_susbscribe).

Acceptance Criteria

  • User can use priv_subscribe and priv_unsuibscribe to create subscriptions to private logs.
  • This should only support logs subscription.
  • The request to create a private logs subscription should be similar to creating a "public" log subscription. The only difference is that the privacyGroupId will be added as parameter index 0.

Definition:

# Subscribe request
{
  "id": 1,
  "method": "priv_subscribe",
  "params": [
    "<privacy_group_id>",
    "logs",
    <filter_parameter_object>
  ]
}

# Unsubscribe request
{
  "id": 1,
  "method": "priv_unsubscribe",
  "params": [
    "<privacy_group_id>",
    "<subscription_id>"
  ]
}

# Subscription notification
{
  "jsonrpc": "2.0",
  "method": "priv_subscription",
  "params": {
    "subscription": "<subscription_id>",
    "privacyGroupId": "<privacy_group_id>",
    "result": <log_entry_object>
  }
}

Example:

# Subscribe request
{
  "id": 1,
  "method": "priv_subscribe",
  "params": [
     "OGD/1dkDZWb9VqgDfElovjYMDAcSiRUiB6fLtFRmugU=",
    "logs",
    {
      "address": "0x8320fe7702b96808f7bbc0d4a888ed1468216cfd",
      "topics": [
        "0xd78a0cb8bb633d06981248b816e7bd33c2a35a6089241d099fa519e361cab902"
      ]
    }
  ]
}

# Unsubscribe request
{
  "id": 1,
  "method": "priv_unsubscribe",
  "params": [
    "OGD/1dkDZWb9VqgDfElovjYMDAcSiRUiB6fLtFRmugU=",
    "0xcd0c3e8af590364c09d0fa6a1210faf5"
  ]
}

# Subscription notification
{
  "jsonrpc": "2.0",
  "method": "priv_subscription",
  "params": {
    "subscription": "0x1",
    "privacyGroupId": "awEvxROVE0ydIgZyVFOfjvZKxaUwtOcWha/CJFHJ4Lw=",
    "result": {
      "logIndex": "0x0",
      "removed": false,
      "blockNumber": "0x2de",
      "blockHash": "0xe4657882a821af048bafbe64a6a0d40e61229c2ad1ef70bc9627e3adf0c941f7",
      "transactionHash": "0xd3e7c320a3d3a8a28fa722611b12c52452dc1ed9e6b0400f7421628f1360b064",
      "transactionIndex": "0x0",
      "address": "0xd9104a5e123c0a026e35eaf7b500bd026921dbde",
      "data": "0x",
      "topics": [
        "0x85bea11d86cefb165374e0f727bacf21dc2f4ea816493981ecf72dcfb212a410",
        "0x0000000000000000000000000000000000000000000000000000000000000002"
      ]
    }
  }
}
@lucassaldanha lucassaldanha added the privacy private transactions label Apr 21, 2020
@lucassaldanha lucassaldanha self-assigned this Apr 21, 2020
@lucassaldanha lucassaldanha added this to the 1.5 Privacy Features milestone May 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
privacy private transactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant