8000 feat(connector-besu): add WatchSolidityEventV1 endpoint by petermetz · Pull Request #3844 · hyperledger-cacti/cacti · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(connector-besu): add WatchSolidityEventV1 endpoint #3844

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

petermetz
Copy link
Contributor

A dedicated endpoint that is purpose-built for solidity events
would add a lot of convenience to users.

Depends on #3830

Fixes #3825

Signed-off-by: Peter Somogyvari peter.somogyvari@accenture.com

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

A dedicated endpoint that is purpose-built for solidity events
would add a lot of convenience to users.

Depends on hyperledger-cacti#3830

Fixes hyperledger-cacti#3825

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Copy link
github-actions bot commented Apr 9, 2025

This PR/issue depends on:

Copy link
Contributor
@outSH outSH left a comment

Choose a reason for hiding this comment

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

I have only one small comment, otherwise it looks great

}
}
},
"ViemV2_24_2_EventLog": {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't use Viem/Web3js name in our return specifications. In case something changes in View output in the future we will have to transform it to match our (older) response specification for API stability. This may be confusing for users who may expect that this structure is pinned to actual View output

Copy link
Contributor
@jagpreetsinghsasan jagpreetsinghsasan Apr 11, 2025

Choose a reason for hiding this comment

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

I think @petermetz did this intentionally so that we can replace web3 with viem gradually over time, without breaking functionality of the existing codebase (@petermetz please correct me if I am wrong here).
But yes, if we call it Viem_EventLog instead of ViemV2_24_2_EventLog , it would be cleaner in my opinion (all good otherwise from my end as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@outSH @jagpreetsinghsasan sorry for the slow response! I'll note down here my thoughts, please let me know if based on these it makes sense to keep it as-is or not. If not, I'm fine with changing it, but I wanted to make sure we are on the same page first:

  1. The probability of breaking changes in the Viem types is 100% as time goes on.
  2. The probability of security vulnerabilities in Viem that will force us to upgrade is also a 100% as time approaches infinity.
  3. Based on 1 and 2 it is 100% that we'll have to adjust our types.
  4. When we are at that juncture, we'll have the choices of a) make a breaking change in the Viem_EventLog type which will be more confusing to users or b) avoid a breaking change by having ViemV2_24_2_EventLog now and add a new ViemV3_0_0_EventLog and let it be immediately obvious to anyone what exactly happened and why (breaking change in the upstream library and in which specific version, etc.)

I'm not married to option b) so just let me know what do you prefer and I'm happy to update it as such.

Copy link
Contributor

Choose a reason for hiding this comment

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

@petermetz true, I just checked the viem gh repo and it seems like they have pretty frequent updates, breaking changes and dependency upgrades. I am thus fine with the current state of the code in this PR.
@outSH what are your thoughts about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@petermetz @jagpreetsinghsasan

When we are at that juncture, we'll have the choices of a) make a breaking change in the Viem_EventLog type which will be more confusing to users or b) avoid a breaking change by having ViemV2_24_2_EventLog now and add a new ViemV3_0_0_EventLog

I'm thinking about a case where we don't actualy change Viem_EventLog, but write an adapter code that will transform the Viem output to backward compatible format, so that our user can use latest library release without security issues and not modify his code at all, but only rely on Cacti API stability. We can of course introduce breaking changes in Viem_EventLog:V2 and remove Viem_EventLog:V1 in next major Cacti release to follow viem implementation in a long run. If we use ViemV2_24_2_EventLog then we're strictly pinned to Viem and user has to update the code every time something in Viem changes, or use older Cacti/Viem version.

I think head/block subscription structure is likely linked to ethereum JSON-RPC and not Viem itself, so the changes we can expect in the future are likely in types or some fields being named differently / marked optional, but the data will be the same between libraries, so I don't expect much work to be done here.

* @returns The string itself if it was 0x prefixed or a new 0x prefixed version of if it wasn't.
*/
export function ensure0xPrefix(maybePrefixed: string): string & `0x${string}` {
const fn = "ensure-0x-prefix.ts";
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the .ts there by mistake?

readonly viemClient: ViemPublicClient;
}

export class WatchEventsV1Endpoint {
Copy link
Contributor

Choose a reason for hiding this comment

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

@petermetz, I would just suggest renaming classes/types to something like SolidityEvent or ContractEvent, just like the PR title. This may be a bit misleading since there is usually the possibility of listening for multiple events beyond the ones emitted by contracts (e.g., pending Transactions, new Heads, etc.)

@AndreAugusto11
Copy link
Contributor

@petermetz, we are working on the satp-hermes plugin, which is dependent on this PR. Can I help accelerate acceptance and merge in any way?

@petermetz
Copy link
Contributor Author

@petermetz, we are working on the satp-hermes plugin, which is dependent on this PR. Can I help accelerate acceptance and merge in any way?

@AndreAugusto11 Sorry for the slow response! I haven't had the time to make the updates requested by @outSH and @jagpreetsinghsasan (I agree with them, I just couldn't find the time). If you'd like to, feel free to update the PR yourself and then re-request their reviews and then we can merge it.

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.

feat(connector-besu): add WatchSolidityEventV1 endpoint
4 participants
0