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

Add QBFT support for evmtool #2807

Merged
merged 10 commits into from
Oct 8, 2021
1 change: 1 addition & 0 deletions ethereum/evmtool/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies {
implementation project(':consensus:clique')
implementation project(':consensus:common')
implementation project(':consensus:ibft')
implementation project(':consensus:qbft')
implementation project(':ethereum:api')
implementation project(':ethereum:core')
implementation project(':ethereum:referencetests')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ private static GenesisFileModule createGenesisModule(final String genesisConfig)
return new IBFTGenesisFileModule(genesisConfig);
} else if (config.containsKey("clique")) {
return new CliqueGenesisFileModule(genesisConfig);
} else if (config.containsKey("qbft")) {
return new QBFTGenesisFileModule(genesisConfig);
} else {
// default is mainnet
return new MainnetGenesisFileModule(genesisConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright ConsenSys AG.
usmansaleem marked this conversation as resolved.
Show resolved Hide resolved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
package org.hyperledger.besu.evmtool;

import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions;
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
import org.hyperledger.besu.consensus.qbft.QbftProtocolSchedule;
import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
import org.hyperledger.besu.evm.internal.EvmConfiguration;

import javax.inject.Named;

class QBFTGenesisFileModule extends GenesisFileModule {
final QbftExtraDataCodec bftExtraDataEncoder = new QbftExtraDataCodec();

QBFTGenesisFileModule(final String genesisConfig) {
super(genesisConfig);
}

@Override
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
return QbftProtocolSchedule.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be able to use the simpler create constructor here, i.e. QbftProtocolSchedule.create(configOptions, bftExtraDataEncoder)

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

configOptions,
PrivacyParameters.DEFAULT,
revertReasonEnabled,
bftExtraDataEncoder,
EvmConfiguration.DEFAULT);
}

@Override
BlockHeaderFunctions blockHashFunction() {
return BftBlockHeaderFunctions.forOnchainBlock(bftExtraDataEncoder);
}
}