Skip to content

Commit

Permalink
Remove getbyblocknumber from flexibleprivacyprecompiledcontract (hype…
Browse files Browse the repository at this point in the history
…rledger#5221)

<!-- Thanks for sending a pull request! Please check out our
contribution guidelines: -->
<!-- https://github.com/hyperledger/besu/blob/main/CONTRIBUTING.md -->

## PR description
This PR aims to remove the usage of getByBlockNumber from the
FlexiblePrivacyPrecompiledContract. As far as analysis shows the only
requirement is to get a protocolSpec (it doesn't matter which one)
currently it always fetches the protocolSpec for block number 1 which
can vary according to the network config. We're changing that get the
protocolSpec for block 0 which is the only block we always have the
header.

AT nonmainnet on circle CI
Pipeline - 21048

## Fixed Issue(s)
<!-- Please link to fixed issue(s) here using format: fixes #<issue
number> -->
<!-- Example: "fixes #2" -->
Fixes hyperledger#5160 

## Documentation

- [x] I thought about documentation and added the `doc-change-required`
label to this PR if
[updates are
required](https://wiki.hyperledger.org/display/BESU/Documentation).

## Acceptance Tests (Non Mainnet)

- [x] I have considered running `./gradlew acceptanceTestNonMainnet`
locally if my PR affects non-mainnet modules.

## Changelog

- [x] I thought about the changelog and included a [changelog update if
required](https://wiki.hyperledger.org/display/BESU/Changelog).

---------

Signed-off-by: Gabriel Fukushima <gabrielfukushima@gmail.com>
  • Loading branch information
gfukushima authored and elenduuche committed Aug 16, 2023
1 parent b84eb48 commit a3ff150
Showing 1 changed file with 9 additions and 4 deletions.
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(
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

0 comments on commit a3ff150

Please sign in to comment.