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

Go quorum interop #1782

Merged
merged 61 commits into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
8e524d1
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
31ab133
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
eb693b1
separate current functionality into two classes (on-chain and off-cha…
pinges Nov 25, 2020
e3631a9
changes based on comments
pinges Nov 26, 2020
a760ba0
changes based on comments
pinges Nov 26, 2020
1970507
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Nov 26, 2020
d254e22
changes based on comments
pinges Nov 26, 2020
5a37b4b
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 1, 2020
700eff0
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 3, 2020
55e59d4
add quorum raw private transactions
pinges Dec 14, 2020
2985980
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 14, 2020
424a33d
some changes
pinges Dec 15, 2020
b12bc00
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 16, 2020
dbbd27e
merge privacy configuration
pinges Dec 17, 2020
2c43940
Initial goquorum private tx processing
lucassaldanha Dec 17, 2020
119a9d2
Added GoQuorumKeyValueStorage
lucassaldanha Dec 18, 2020
4adcf0b
Removed unecessary classes
lucassaldanha Dec 22, 2020
8774a89
Clenup
lucassaldanha Dec 27, 2020
28687be
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Dec 30, 2020
2b0fefc
private Tx mined by quorum, but import into besu fails with 'invalid …
pinges Dec 31, 2020
a785608
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Jan 11, 2021
5e4635f
tests passing after rebase with Lucas branch
pinges Jan 11, 2021
d2e2506
spotless
pinges Jan 11, 2021
b0a1aed
merged in changes from master. All tests passing
pinges Jan 12, 2021
410cd83
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 12, 2021
4af37ab
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 13, 2021
47e9c11
Merge branch 'master' of github.com:hyperledger/besu into createQuoru…
pinges Jan 13, 2021
5f811ef
Merge branch 'createQuorumTransaction' into goQuorumInterop
pinges Jan 13, 2021
f69dd2a
add some debug sout
pinges Jan 13, 2021
a2e28ce
remove receive RPC method
pinges Jan 14, 2021
232100b
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 14, 2021
1d9431c
make quorum privacy configuration not use static
pinges Jan 15, 2021
f019692
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 15, 2021
063cd03
fix compile
pinges Jan 17, 2021
f9d5be1
fix test
pinges Jan 17, 2021
bfb8f17
fix test failure
pinges Jan 18, 2021
565bbf9
fix test failure
pinges Jan 18, 2021
dfbbc0e
fix test failure
pinges Jan 18, 2021
0bc3b6e
fix test failure
pinges Jan 18, 2021
e744047
fix test failure
pinges Jan 18, 2021
ee0e4b3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 18, 2021
365618b
fix AT NullPointerExceptions
pinges Jan 19, 2021
f45b539
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 19, 2021
424dff5
remove another static field
pinges Jan 19, 2021
b0db717
some cleanup
pinges Jan 19, 2021
ffa56b3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
bafc3d6
more cleanup
pinges Jan 20, 2021
1cad6ce
even more cleanup
pinges Jan 20, 2021
0042fdf
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
da6c97e
and even more cleanup
pinges Jan 20, 2021
17eec25
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
1fb251d
fix a unit test
pinges Jan 20, 2021
c806616
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 20, 2021
314234e
fixes after review from Sally
pinges Jan 22, 2021
7e7ebd3
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 22, 2021
73e96f2
merge master and somes fixes after review from Mark
pinges Jan 27, 2021
97dfe34
changes after comments from Lucas
pinges Jan 27, 2021
64ab12e
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 27, 2021
a9d583e
fix spotless
pinges Jan 27, 2021
d08eb35
Merge branch 'master' of github.com:hyperledger/besu into goQuorumInt…
pinges Jan 28, 2021
8710904
remove some comments
pinges Jan 29, 2021
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
Prev Previous commit
Next Next commit
merged in changes from master. All tests passing
Signed-off-by: Stefan Pingel <stefan.pingel@consensys.net>
  • Loading branch information
pinges committed Jan 12, 2021
commit b0a1aed4a09ab2ab4cee34b6822ebdf004330e8a
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,24 @@ public BesuController build() {
final ProtocolSchedule protocolSchedule = createProtocolSchedule();
final GenesisState genesisState = GenesisState.fromConfig(genesisConfig, protocolSchedule);
final WorldStateStorage worldStateStorage = storageProvider.createWorldStateStorage();
final WorldStateArchive worldStateArchive = createWorldStateArchive(worldStateStorage);
final WorldStateStorage privateWorldStateStorage =
storageProvider.createPrivateWorldStateStorage();
final WorldStateArchive privateWorldStateArchive =
createPrivateWorldStateArchive(privateWorldStateStorage);

final BlockchainStorage blockchainStorage =
storageProvider.createBlockchainStorage(protocolSchedule);

final MutableBlockchain blockchain =
DefaultBlockchain.createMutable(
genesisState.getBlock(), blockchainStorage, metricsSystem, reorgLoggingThreshold);

final WorldStateArchive worldStateArchive =
createWorldStateArchive(worldStateStorage, blockchain);
final ProtocolContext protocolContext =
ProtocolContext.init(
storageProvider,
worldStateArchive,
genesisState,
protocolSchedule,
metricsSystem,
this::createConsensusContext,
reorgLoggingThreshold);
blockchain, worldStateArchive, genesisState, this::createConsensusContext);
protocolContext.setPrivateWorldStateArchive(privateWorldStateArchive);

validateContext(protocolContext);

protocolSchedule.setPublicWorldStateArchiveForPrivacyBlockProcessor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.IbftConfigOptions;
import org.hyperledger.besu.ethereum.core.Address;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Wei;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.IbftConfigOptions;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.core.Wei;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockBodyValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ public Optional<BlockProcessingOutputs> validateAndProcessBlock(
}

final Optional<MutableWorldState> maybeWorldState =
context.getWorldStateArchive().getMutable(parentHeader.getStateRoot());
if (maybeWorldState.isEmpty()) {
context
.getWorldStateArchive()
.getMutable(parentHeader.getStateRoot(), parentHeader.getHash());
if (!maybeWorldState.isPresent()) {
LOG.debug(
"Unable to process block {} because parent world state {} is not available",
block.getHeader().getNumber(),
Expand Down Expand Up @@ -127,6 +129,8 @@ public Optional<BlockProcessingOutputs> validateAndProcessBlock(
*/
protected Result processBlock(
final ProtocolContext context, final MutableWorldState worldState, final Block block) {
System.out.println("Using the MainnetBlockValidator");

return blockProcessor.processBlock(context.getBlockchain(), worldState, block);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public Result processBlock(
return AbstractBlockProcessor.Result.failed();
}

worldState.persist(blockHeader.getHash());
worldState.persist(blockHeader);
privateWorldState.persist(null);

privateStorageUpdater.putPrivateStateRootHashMapping(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,37 @@ public GoQuorumBlockValidator(
protected Result processBlock(
final ProtocolContext context, final MutableWorldState worldState, final Block block) {

System.out.println("Using the GoQuormBlockValidator");
final MutableWorldState privateWorldState =
getPrivateWorldState(context, worldState.rootHash());
getPrivateWorldState(context, worldState.rootHash(), block.getHash());

return ((GoQuorumBlockProcessor) blockProcessor)
.processBlock(context.getBlockchain(), worldState, privateWorldState, block);
}

private MutableWorldState getPrivateWorldState(
final ProtocolContext context, final Hash publicWorldStateRootHash) {
final ProtocolContext context, final Hash worldStateRootHash, final Hash publicBlockHash) {
final Hash privateStateRootHash =
goQuorumPrivateStorage
.getPrivateStateRootHash(publicWorldStateRootHash)
.getPrivateStateRootHash(worldStateRootHash)
.orElse(Hash.EMPTY_TRIE_HASH);

final Optional<MutableWorldState> maybePrivateWorldState =
context.getPrivateWorldStateArchive().flatMap(p -> p.getMutable(privateStateRootHash));
context
.getPrivateWorldStateArchive()
.flatMap(p -> p.getMutable(privateStateRootHash, publicBlockHash));
if (maybePrivateWorldState.isEmpty()) {
LOG.debug(
"Private world state not available for public world state root hash {}",
publicWorldStateRootHash);
"Private world state not available for public world state root hash {}, public block hash {}",
worldStateRootHash,
publicBlockHash);

/*
This should never happen because privateStateRootResolver will either return a matching
private world state root hash, or the hash for an empty world state (first private tx ever).
*/
throw new IllegalStateException(
"Private world state not available for public world state root hash "
+ publicWorldStateRootHash);
"Private world state not available for public world state root hash " + publicBlockHash);
}
return maybePrivateWorldState.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,51 +147,55 @@ public AbstractBlockProcessor.Result processBlock(
return AbstractBlockProcessor.Result.failed();
}

final List<TransactionReceipt> receipts = new ArrayList<>();
long currentGasUsed = 0;
for (final Transaction transaction : transactions) {
if (!hasAvailableBlockBudget(blockHeader, transaction, currentGasUsed)) {
return AbstractBlockProcessor.Result.failed();
final WorldUpdater worldStateUpdater = worldState.updater();
final BlockHashLookup blockHashLookup = new BlockHashLookup(blockHeader, blockchain);
final Address miningBeneficiary =
miningBeneficiaryCalculator.calculateBeneficiary(blockHeader);

final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,
miningBeneficiary,
OperationTracer.NO_TRACING,
blockHashLookup,
true,
TransactionValidationParams.processingBlock(),
privateMetadataUpdater);
if (result.isInvalid()) {
LOG.info(
"Block processing error: transaction invalid '{}'. Block {} Transaction {}",
result.getValidationResult().getInvalidReason(),
blockHeader.getHash().toHexString(),
transaction.getHash().toHexString());
return AbstractBlockProcessor.Result.failed();
}

worldStateUpdater.commit();

currentGasUsed += transaction.getGasLimit() - result.getGasRemaining();

final TransactionReceipt transactionReceipt =
transactionReceiptFactory.create(
transaction.getType(), result, worldState, currentGasUsed);
receipts.add(transactionReceipt);
}

final WorldUpdater worldStateUpdater = worldState.updater();
final BlockHashLookup blockHashLookup = new BlockHashLookup(blockHeader, blockchain);
final Address miningBeneficiary =
miningBeneficiaryCalculator.calculateBeneficiary(blockHeader);

final TransactionProcessingResult result =
transactionProcessor.processTransaction(
blockchain,
worldStateUpdater,
blockHeader,
transaction,
miningBeneficiary,
OperationTracer.NO_TRACING,
blockHashLookup,
true,
TransactionValidationParams.processingBlock(),
privateMetadataUpdater);

if (result.isInvalid()) {
LOG.info(
"Block processing error: transaction invalid '{}'. Block {} Transaction {}",
result.getValidationResult().getInvalidReason(),
blockHeader.getHash().toHexString(),
transaction.getHash().toHexString());
if (!rewardCoinbase(worldState, blockHeader, ommers, skipZeroBlockRewards)) {
// no need to log, rewardCoinbase logs the error.
return AbstractBlockProcessor.Result.failed();
}

worldStateUpdater.commit();

currentGasUsed += transaction.getGasLimit() - result.getGasRemaining();

final TransactionReceipt transactionReceipt =
transactionReceiptFactory.create(
transaction.getType(), result, worldState, currentGasUsed);
receipts.add(transactionReceipt);
worldState.persist(blockHeader);
return AbstractBlockProcessor.Result.successful(receipts);
} finally {
globalProcessBlock.end();
}
}

// TODO Stefan: is this method used anywhere?
protected boolean hasAvailableBlockBudget(
final BlockHeader blockHeader, final Transaction transaction, final long currentGasUsed) {
if (!gasBudgetCalculator.hasBudget(
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.