Date
1 - 7 of 7
Implementing custom validation GO plugin, does an example exists? #vscc
rmulken@...
Hello everyone,
In my current project we are looking into building custom validation logic via GO plugin, some docs can be found here: https://hyperledger-fabric.readthedocs.io/en/release-2.2/pluggable_endorsement_and_validation.html#pluggable-endorsement-and-validation-logic. The thing that I'm missing is a simple example of an implementation of such a plugin. Does anyone have experience with this? We want to be able to check for example if a token is not already spent (checking if inputs are still valid against data on the ledger). Thanks in advance. Robert van Mölken
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
Yacov
Check the integration tests here: https://github.com/hyperledger/fabric/blob/main/integration/pluggable/pluggable_test.go
From: fabric@... <fabric@...> on behalf of rmulken@... <rmulken@...>
Sent: Wednesday, September 14, 2022 10:54 AM To: fabric@... <fabric@...> Subject: [EXTERNAL] [Hyperledger Fabric] Implementing custom validation GO plugin, does an example exists? #vscc
This Message Is From an Untrusted Sender
You have not previously corresponded with this sender.
In my current project we are looking into building custom validation logic via GO plugin, some docs can be found here: https://hyperledger-fabric.readthedocs.io/en/release-2.2/pluggable_endorsement_and_validation.html#pluggable-endorsement-and-validation-logic. The thing that I'm missing is a simple example of an implementation of such a plugin. Does anyone have experience with this? We want to be able to check for example if a token is not already spent (checking if inputs are still valid against data on the ledger). Thanks in advance. Robert van Mölken
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
rmulken@...
Thanks Yacov,
I will take a look at the testdata plugins : https://github.com/hyperledger/fabric/tree/main/integration/pluggable/testdata/plugins Kind regards, Robert
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
rmulken@...
@Yacov,
I find that the plugins in the testdata don't represent the interface given in the documentation and it does not include any real test. Any further help on this topic?
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
Yacov
I'm not sure what you mean by not include a real test?
The test makes the validation plugin create a file with the peer's name:
and then tests that the plugins were activated.
It's a toy example, of course, but it still proves that it works.
What do you mean it doesn't represent the interface given in the documentation?
In any case, if there is a discrepancy between the documentation and the code, you know which one wins 😉
From: fabric@... <fabric@...> on behalf of rmulken@... <rmulken@...>
Sent: Wednesday, September 14, 2022 6:02 PM To: fabric@... <fabric@...> Subject: [EXTERNAL] Re: [Hyperledger Fabric] Implementing custom validation GO plugin, does an example exists? #vscc
This Message Is From an Untrusted Sender
You have not previously corresponded with this sender.
I find that the plugins in the testdata don't represent the interface given in the documentation and it does not include any real test. Any further help on this topic?
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
rmulken@...
Hi Yacov,
Thanks for your reply. I'm not concerned about the integration test not working, the code looks legit, but does not cover what I'm looking for. The documentation of implementing a validation plugin is describe here: https://hyperledger-fabric.readthedocs.io/en/release-2.2/pluggable_endorsement_and_validation.html#validation-plugin-implementation and describes the following plugin interface: // Plugin validates transactions type Plugin interface { // Validate returns nil if the action at the given position inside the transaction // at the given position in the given block is valid, or an error if not. Validate(block *common.Block, namespace string, txPosition int, actionPosition int, contextData ...ContextDatum) error // Init injects dependencies into the instance of the Plugin Init(dependencies ...Dependency) error } When I look at the integration tests the reference the following test validation plugin: https://github.com/hyperledger/fabric/blob/2ef46bbc718de220bbd33ee4e1ce65194b963358/integration/pluggable/testdata/plugins/validation/plugin.go but this plugin does not implement this validation interface and nor has it executable instructions.
So i'm really helped with an actual example of a validation plugin as mentioned in the documentation. Or is the answer that Hyperledger Fabric does not actively supporting pluggable endorser/validation plugins on a peer?
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
Yacov
The plugin is indeed the interface that you outlined below, with the Validate and Init methods.
However, these plugins are created for each channel and should be independent from each other.
When a plugin instance is created, the plugin factory is called with the method New() which returns an instance of a plugin.
The way to override the regular validation plugin, is to create a plugin factory which returns plugins that you implement.
In the test, we have a custom plugin factory which:
The aim of the integration tests is to check that the peer can be correctly configured with a validation plugin.
From: fabric@... <fabric@...> on behalf of rmulken@... <rmulken@...>
Sent: Wednesday, September 21, 2022 5:47 PM To: fabric@... <fabric@...> Subject: [EXTERNAL] Re: [Hyperledger Fabric] Implementing custom validation GO plugin, does an example exists? #vscc
This Message Is From an Untrusted Sender
You have not previously corresponded with this sender.
Thanks for your reply. I'm not concerned about the integration test not working, the code looks legit, but does not cover what I'm looking for. The documentation of implementing a validation plugin is describe here: https://hyperledger-fabric.readthedocs.io/en/release-2.2/pluggable_endorsement_and_validation.html#validation-plugin-implementation and describes the following plugin interface: // Plugin validates transactions type Plugin interface { // Validate returns nil if the action at the given position inside the transaction // at the given position in the given block is valid, or an error if not. Validate(block *common.Block, namespace string, txPosition int, actionPosition int, contextData ...ContextDatum) error // Init injects dependencies into the instance of the Plugin Init(dependencies ...Dependency) error } When I look at the integration tests the reference the following test validation plugin: https://github.com/hyperledger/fabric/blob/2ef46bbc718de220bbd33ee4e1ce65194b963358/integration/pluggable/testdata/plugins/validation/plugin.go but this plugin does not implement this validation interface and nor has it executable instructions.
So i'm really helped with an actual example of a validation plugin as mentioned in the documentation. Or is the answer that Hyperledger Fabric does not actively supporting pluggable endorser/validation plugins on a peer?
|
|||||||||||||||||||||||||||||
|