-
Notifications
You must be signed in to change notification settings - Fork 867
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
Draft
vaidikcode
wants to merge
28
commits into
hyperledger:main
Choose a base branch
from
vaidikcode:#7835
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
1724426
commit
vaidikcode 858c8ee
addressing comments
vaidikcode dd498e7
updating api hash
vaidikcode aae1526
fixing the issue of implementing the permission service class in pr w…
vaidikcode 2509d7d
add tests
vaidikcode 6c7b463
change log
vaidikcode 4a0c5dd
fix
vaidikcode 2d51ec2
fix
vaidikcode 7851707
Merge remote-tracking branch 'origin/#7835' into #7835
vaidikcode da2c3de
fix
vaidikcode dd44cca
fix
vaidikcode 549db1f
fix
vaidikcode 7f75593
Merge branch 'hyperledger:main' into #7835
vaidikcode d77f294
refactor
vaidikcode 245e8ef
Merge remote-tracking branch 'origin/#7835' into #7835
vaidikcode b51669b
Merge branch 'main' into #7835
vaidikcode 94620ed
fix
vaidikcode 531ff5d
Merge remote-tracking branch 'origin/#7835' into #7835
vaidikcode ae8f3c8
Merge branch 'main' into #7835
vaidikcode 5d815c2
spotless
vaidikcode 9cfc510
Merge remote-tracking branch 'origin/#7835' into #7835
vaidikcode 80c832c
compile error fix
vaidikcode b74a3e1
Merge branch 'main' into #7835
macfarla 0b23b89
minor fix
vaidikcode de4ee35
Merge remote-tracking branch 'origin/#7835' into #7835
vaidikcode 040857a
minor fix
vaidikcode a037c07
final
macfarla 028c103
Merge branch '#7835' of github.com:vaidikcode/besu into #7835
macfarla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,15 +19,17 @@ | |||||
|
||||||
import org.hyperledger.besu.crypto.Hash; | ||||||
import org.hyperledger.besu.datatypes.Address; | ||||||
import org.hyperledger.besu.ethereum.core.Transaction; | ||||||
import org.hyperledger.besu.ethereum.permissioning.account.TransactionPermissioningProvider; | ||||||
import org.hyperledger.besu.datatypes.Quantity; | ||||||
import org.hyperledger.besu.datatypes.Transaction; | ||||||
import org.hyperledger.besu.ethereum.transaction.CallParameter; | ||||||
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator; | ||||||
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult; | ||||||
import org.hyperledger.besu.metrics.BesuMetricCategory; | ||||||
import org.hyperledger.besu.plugin.services.MetricsSystem; | ||||||
import org.hyperledger.besu.plugin.services.metrics.Counter; | ||||||
import org.hyperledger.besu.plugin.services.permissioning.TransactionPermissioningProvider; | ||||||
|
||||||
import java.math.BigInteger; | ||||||
import java.util.Optional; | ||||||
|
||||||
import org.apache.tuweni.bytes.Bytes; | ||||||
|
@@ -195,9 +197,13 @@ public static Bytes createPayload(final Bytes signature, final Transaction trans | |||||
private static Bytes encodeTransaction(final Transaction transaction) { | ||||||
return Bytes.concatenate( | ||||||
encodeAddress(transaction.getSender()), | ||||||
encodeAddress(transaction.getTo()), | ||||||
transaction.getValue(), | ||||||
transaction.getGasPrice().map(BaseUInt256Value::toBytes).orElse(Bytes32.ZERO), | ||||||
encodeAddress(transaction.getTo().map(Address.class::cast)), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love this line - surely there is a cleaner way todo this |
||||||
convertQuantityToBytes(transaction.getValue()), | ||||||
transaction | ||||||
.getGasPrice() | ||||||
.map(price -> (BaseUInt256Value<?>) price) | ||||||
.map(BaseUInt256Value::toBytes) | ||||||
.orElse(Bytes32.ZERO), | ||||||
encodeLong(transaction.getGasLimit()), | ||||||
encodeBytes(transaction.getPayload())); | ||||||
} | ||||||
|
@@ -231,4 +237,16 @@ private static Bytes encodeBytes(final Bytes value) { | |||||
final Bytes padding = Bytes.wrap(new byte[(32 - (value.size() % 32))]); | ||||||
return Bytes.concatenate(dynamicParameterOffset, length, value, padding); | ||||||
} | ||||||
|
||||||
// Convert the Quantity value to Bytes | ||||||
private static Bytes convertQuantityToBytes(final Quantity quantity) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (quantity == null) { | ||||||
return Bytes32.ZERO; | ||||||
} | ||||||
if (quantity instanceof BaseUInt256Value) { | ||||||
return ((BaseUInt256Value) quantity).toBytes(); | ||||||
} | ||||||
BigInteger value = quantity.getAsBigInteger(); | ||||||
return Bytes.wrap(value.toByteArray()); | ||||||
} | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
needs to move to "Unreleased" section