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

[Follow up] Add Transaction Permissioning Hook to PermissioningService Interface #8365

Merged
merged 44 commits into from
Mar 12, 2025

Conversation

relu91
Copy link
Contributor

@relu91 relu91 commented Feb 28, 2025

PR description

This PR builds upon the work started in #7952, finalizing the implementation while maintaining consistency with the existing changes.

Key Updates:

  • Completed the feature without altering the previous implementation significantly.
  • Added some improvements to the acceptance tests
  • Ensured consistency with the existing codebase by following established style and logic.
  • Took inspiration from the NodePermissioningController for handling plugin-based submissions, aligning the approach with Besu’s existing permissioning mechanisms.

Basically, after merging this work, people can filter transactions using the PermissioningService in their plugins. I would say adding some examples to the documentation might be useful.

Note: I didn't like the previous acceptance test, I found it a little bit convoluted for simply assigning the filtering mechanism of the plugins. As I said, I tried to be as conservative as I could. If you want, we can discuss possible improvements there.

Fixed Issue(s)

#7835

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

vaidikcode and others added 29 commits November 28, 2024 02:16
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
…er#7835

# Conflicts:
#	acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/plugins/PermissioningPluginTest.java
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: Sally MacFarlane <[email protected]>
Copy link
Contributor

@macfarla macfarla 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 your contribution! Strong preference for not modifying the smart contract permissioning code at this stage since it's about to be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

we've deprecated smart contract based permissioning per the sunset plan https://www.lfdecentralizedtrust.org/blog/sunsetting-tessera-and-simplifying-hyperledger-besu

so this class is going to be removed

Copy link
Contributor

Choose a reason for hiding this comment

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

and right now we're effectively in a code freeze for the sunset features. So would prefer not to modify this code if possible, and if not possible, would prefer to remove smart contract permissioning first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was indeed another thing that I wanted to mention in the first comment. I can revert that change. Should I also add @Depracted tag? or is it not common practice here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Meanwhile, I checked the latest version from main reverting the changes. Let me know if I need to do other cleanups of the previous changes.

Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

looking pretty good, couple of minor suggestions

@macfarla macfarla requested a review from jflo March 4, 2025 05:39
@macfarla
Copy link
Contributor

macfarla commented Mar 4, 2025

@jflo if you want to take a look, this replaces #7952

@relu91
Copy link
Contributor Author

relu91 commented Mar 4, 2025

I fixed the build error of the previous CI run, it should be ready now.

for (TransactionPermissioningProvider provider : this.pluginProviders) {
if (!provider.isPermitted(transaction)) {
LOG.trace(
"Account permissioning - {}: Rejected transaction {} from {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking we should standardise the class naming and logging to "Transaction permissioning" rather than "Account permissioning" - but this can be a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

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

You could even call it "Transaction Rejector" or something that conveys that the default case is to permit the transaction.

@relu91
Copy link
Contributor Author

relu91 commented Mar 6, 2025

Should I resolve the conflicts with main? I don't want to trigger CI again for a trivial hash check in the build system.

Copy link
Contributor

@jflo jflo left a comment

Choose a reason for hiding this comment

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

I think this is good, the only part of the design I would tighten up would be to require transaction permissioning to be defined under a broader permissioning config.

Not sure if that is by design or not, but one could view it as a leaky abstraction.

@@ -1177,10 +1177,17 @@ private Optional<AccountPermissioningController> buildAccountPermissioningContro
final BesuController besuController,
final TransactionSimulator transactionSimulator) {

if (permissioningConfiguration.isPresent()) {
if (permissioningConfiguration.isPresent()
|| permissioningService.getTransactionPermissioningProviders().size() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Allowing transaction permissioning without a broader permissioningConfiguration seems weird, we will need to clarify in the docs that you can set up permissioning on just the transactions in this manner.

Copy link
Contributor Author

@relu91 relu91 Mar 10, 2025

Choose a reason for hiding this comment

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

I followed the same behavior of Node permissioning above. Should I change both of them? How should the end result looks like? User create an empty account permissioning file to enable a plugin that filters transactions? Shall I create an additional option --permissions-accounts-plugin-enable (and also --permissions-node-plugin-enable) ?

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 this could be refactored separately (different PR) since the same pattern is used for node permissioning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@macfarla Opened an issue to discuss possible solutions: #8407 (I can volunteer if needed)

for (TransactionPermissioningProvider provider : this.pluginProviders) {
if (!provider.isPermitted(transaction)) {
LOG.trace(
"Account permissioning - {}: Rejected transaction {} from {}",
Copy link
Contributor

Choose a reason for hiding this comment

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

You could even call it "Transaction Rejector" or something that conveys that the default case is to permit the transaction.

@relu91
Copy link
Contributor Author

relu91 commented Mar 10, 2025

I've updated the logging messages, however, if you ask me, it is weird that a class called AccountPermissioningController logs messages with Transaction Rejector ... . Should we probably think of a major refactoring of the concept? ( and probably explain something here)

@jflo
Copy link
Contributor

jflo commented Mar 11, 2025

I've updated the logging messages, however, if you ask me, it is weird that a class called AccountPermissioningController logs messages with Transaction Rejector ... . Should we probably think of a major refactoring of the concept? ( and probably explain something here)

Thats ok, the details on which class are emitting the log should be preserved via the SLF4J pattern. So the message should focus on what it is doing, i.e. rejecting transactions.

Signed-off-by: Sally MacFarlane <[email protected]>
@macfarla macfarla enabled auto-merge (squash) March 12, 2025 07:11
@macfarla macfarla merged commit 72ac7bd into hyperledger:main Mar 12, 2025
43 checks passed
marcosio pushed a commit to IoBuilders/besu that referenced this pull request Mar 12, 2025
…e Interface (hyperledger#8365)

* fixing the issue of implementing the permission service class in pr when it already exists
Signed-off-by: vaidikcode <[email protected]>

* wiring transaction filtering for Permissioning Plugins

* revert modify deprated code for TransactionSmartContractPermissioning

* Improve logging for AccountPermissioningController

Co-authored-by: Sally MacFarlane <[email protected]>
Signed-off-by: Cristiano Aguzzi <[email protected]>

* Improve logging messages for AccountPermissioningController

* Allign AccountPermissioningControllerFactoryTest with the latest api

Signed-off-by: reluc <[email protected]>

---------

Signed-off-by: Vaidik <[email protected]>
Signed-off-by: Sally MacFarlane <[email protected]>
Signed-off-by: reluc <[email protected]>
Signed-off-by: Cristiano Aguzzi <[email protected]>
Co-authored-by: vaidikcode <[email protected]>
Co-authored-by: Sally MacFarlane <[email protected]>
Co-authored-by: Justin Florentine <[email protected]>
Signed-off-by: Marcos Serradilla Diez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants