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

Remove getbyblocknumber from flexibleprivacyprecompiledcontract #5221

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions besu/src/main/java/org/hyperledger/besu/RunnerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.hyperledger.besu.ethereum.api.query.PrivacyQueries;
import org.hyperledger.besu.ethereum.blockcreation.MiningCoordinator;
import org.hyperledger.besu.ethereum.chain.Blockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MiningParameters;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Synchronizer;
Expand Down Expand Up @@ -796,7 +797,8 @@ public Runner build() {
.build();
vertx.deployVerticle(filterManager);

createPrivateTransactionObserver(filterManager, privacyParameters);
createPrivateTransactionObserver(
filterManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());

final P2PNetwork peerNetwork = networkRunner.getNetwork();

Expand Down Expand Up @@ -1032,7 +1034,8 @@ public Runner build() {
DefaultAuthenticationService.create(vertx, webSocketConfiguration),
metricsSystem));

createPrivateTransactionObserver(subscriptionManager, privacyParameters);
createPrivateTransactionObserver(
subscriptionManager, privacyParameters, context.getBlockchain().getGenesisBlockHeader());
}

final Optional<MetricsService> metricsService =
Expand Down Expand Up @@ -1344,17 +1347,19 @@ private void createLogsSubscriptionService(

private void createPrivateTransactionObserver(
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't know how feasible this is, but adding a test for this would be good. But it might already be covered by a test at another level.

final PrivateTransactionObserver privateTransactionObserver,
final PrivacyParameters privacyParameters) {
final PrivacyParameters privacyParameters,
final BlockHeader genesisBlockHeader) {
// register privateTransactionObserver as observer of events fired by the flexible precompile.
if (privacyParameters.isFlexiblePrivacyGroupsEnabled()
&& privacyParameters.isMultiTenancyEnabled()) {
final FlexiblePrivacyPrecompiledContract flexiblePrivacyPrecompiledContract =
(FlexiblePrivacyPrecompiledContract)
besuController
.getProtocolSchedule()
.getByBlockNumber(1)
.getByBlockHeader(genesisBlockHeader)
.getPrecompileContractRegistry()
.get(FLEXIBLE_PRIVACY);

flexiblePrivacyPrecompiledContract.addPrivateTransactionObserver(privateTransactionObserver);
}
}
Expand Down