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

Log Event Streaming for Plugin API #186

Merged
merged 21 commits into from
Nov 13, 2019

Conversation

RatanRSur
Copy link
Contributor

PR description

Since the blockchain can now produce LogWithMetadata in its events. We create a new listener that the plugin implementation hooks into.

There is also code that converts from the plugin types to our domain types. It's a bit forceful so I'm open to suggestions on how to make that part more elegant within Java's type system.

Fixed Issue(s)

https://pegasys1.atlassian.net/secure/RapidBoard.jspa?rapidView=28&projectKey=PIE&modal=detail&selectedIssue=PIE-1802&assignee=5ce472e018de8f0dc3552e9c&assignee=UNASSIGNED_USER_ID

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@@ -176,6 +176,10 @@ public static Address privateContractAddress(
})));
}

public static Address fromPlugin(final org.hyperledger.besu.plugin.data.Address logger) {
Copy link
Contributor

@shemnon shemnon Nov 13, 2019

Choose a reason for hiding this comment

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

Should we do a type check first? There's a strong chance it is a compatible object we just can't staticly prove it.

if (logger instanceof Address) {
  return (Address) logger;
} else {
  return wrap(BytesValue.fromPlugin(logger));
}

@@ -68,6 +68,10 @@ public static Hash fromHexStringLenient(final String str) {
return new Hash(Bytes32.fromHexStringLenient(str));
}

public static Hash fromPlugin(final org.hyperledger.besu.plugin.data.Hash blockHash) {
return wrap(Bytes32.fromPlugin(blockHash));
Copy link
Contributor

@shemnon shemnon Nov 13, 2019

Choose a reason for hiding this comment

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

Same type check here, and all the places we do a wrap.

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@@ -168,6 +169,10 @@ static Bytes32 fromHexStringStrict(final String str) {
return wrap(BytesValues.fromRawHexString(str, -1, false));
}

static Bytes32 fromPlugin(final UnformattedData data) {
return wrap(data.getByteArray());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shemnon Would we want to leave this one as is since wrap here does runtime verification of the structure?

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's a Bytes32 it should already have been validated when the instance was made. If we keep wrapping this will put pressure on the garbage collector and I'd like to avoid that as much as possible. Either way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah right, sounds good

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@shemnon
Copy link
Contributor

shemnon commented Nov 13, 2019

👍

Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
Signed-off-by: Ratan Rai Sur <ratan.r.sur@gmail.com>
@RatanRSur RatanRSur merged commit 271d578 into hyperledger:master Nov 13, 2019
@RatanRSur RatanRSur deleted the log-events-2 branch November 13, 2019 22:03
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.

2 participants