-
Notifications
You must be signed in to change notification settings - Fork 844
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 Transaction Permissioning Hook to PermissioningService Interface #7952
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: vaidikcode <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contrib!
a few comments. the logging would be better at info level. you can have extra logging in the plugin if needed, and/or you can use custom log4j config to turn this up for troubleshooting but don't want this permanently at info level. The one-off "registered plugin" is fine at info level.
there's also the TestPermissioningPlugin and PermissioningPluginTest - you could expand the test plugin and add a test to verify the tx permissioning callback works as expected
you'll also need to run the gradle target checkAPIChanges to calculate and update the api hash
and prob add a changelog entry
return false; | ||
} | ||
} | ||
log.info("Transaction {} permitted.", transaction.getHash()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.info("Transaction {} permitted.", transaction.getHash()); | |
log.debug("Transaction {} permitted.", transaction.getHash()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be spammy at info level
import java.util.List; | ||
|
||
public class PermissionServiceImpl implements PermissioningService { | ||
private static final Logger log = LoggerFactory.getLogger(PermissionServiceImpl.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private static final Logger log = LoggerFactory.getLogger(PermissionServiceImpl.class); | |
private static final Logger LOG = LoggerFactory.getLogger(PermissionServiceImpl.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all upper case naming convention for static fields
public boolean isTransactionPermitted(Transaction transaction) { | ||
for (TransactionPermissioningProvider provider : transactionPermissioningProviders) { | ||
if (!provider.isPermitted(transaction)) { | ||
log.info("Transaction {} not permitted by one of the providers.", transaction.getHash()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.info("Transaction {} not permitted by one of the providers.", transaction.getHash()); | |
log.debug("Transaction {} not permitted by one of the providers.", transaction.getHash()); |
Signed-off-by: vaidikcode <[email protected]>
Signed-off-by: vaidikcode <[email protected]>
…hen it already exists 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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need some refactoring to move this TransactionPermissioningProvider interface into the plugin package.
/** | ||
* Gets transaction rules. | ||
* | ||
* @return if the transaction is valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @return if the transaction is valid | |
* @return whether the transaction is permitted |
@@ -32,6 +32,7 @@ | |||
- Fast Sync | |||
|
|||
### Additions and Improvements | |||
- Add support for registeringTransactionPermissionProvider in Plugin API to define and validate transaction rules [#7952](https://github.com/hyperledger/besu/pull/7952) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add support for registeringTransactionPermissionProvider in Plugin API to define and validate transaction rules [#7952](https://github.com/hyperledger/besu/pull/7952) | |
- Add support for transaction permissioning rules in Plugin API [#7952](https://github.com/hyperledger/besu/pull/7952) |
@@ -14,6 +14,7 @@ | |||
*/ | |||
package org.hyperledger.besu.plugin.services; | |||
|
|||
import org.hyperledger.besu.ethereum.permissioning.account.TransactionPermissioningProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need some refactoring to move this TransactionPermissioningProvider interface into the plugin package.
Signed-off-by: vaidikcode [email protected]
PR description
I’ve implemented the registerTransactionPermissioningProvider method to allow custom transaction permissioning logic by adding providers to a collection. A method to iterate over these providers and check if transactions are permitted has also been included.
Currently, other methods in the PermissioningService interface (like registerNodePermissioningProvider and registerNodeMessagePermissioningProvider) are left unimplemented, as they are not part of this PR's scope.
I may need guidance on whether you would like me to proceed with implementing the other methods, and any improvements or adjustments needed to integrate this into the broader permissioning system.
Fixed Issue(s)
#7835
Thanks for sending a pull request! Have you done the following?
doc-change-required
label to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew build
./gradlew acceptanceTest
./gradlew integrationTest
./gradlew ethereum:referenceTests:referenceTests