diff --git a/besu/build.gradle b/besu/build.gradle index 01b0b4bead7..d1230b6974b 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -39,6 +39,7 @@ dependencies { implementation project(':consensus:ibft') implementation project(':consensus:merge') implementation project(':consensus:qbft') + implementation project(':consensus:qbft-core') implementation project(':crypto:services') implementation project(':datatypes') implementation project(':enclave') diff --git a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java index e8c08d8a473..4143d034058 100644 --- a/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java +++ b/besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java @@ -47,20 +47,20 @@ import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory; -import org.hyperledger.besu.consensus.qbft.QbftGossip; import org.hyperledger.besu.consensus.qbft.QbftProtocolScheduleBuilder; import org.hyperledger.besu.consensus.qbft.blockcreation.QbftBlockCreatorFactory; +import org.hyperledger.besu.consensus.qbft.core.network.QbftGossip; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftBlockHeightManagerFactory; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftController; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftRoundFactory; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.validator.ValidatorModeTransitionLogger; import org.hyperledger.besu.consensus.qbft.jsonrpc.QbftJsonRpcMethods; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; import org.hyperledger.besu.consensus.qbft.protocol.Istanbul100SubProtocol; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftBlockHeightManagerFactory; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftController; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftRoundFactory; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidatorFactory; import org.hyperledger.besu.consensus.qbft.validator.ForkingValidatorProvider; import org.hyperledger.besu.consensus.qbft.validator.TransactionValidatorProvider; import org.hyperledger.besu.consensus.qbft.validator.ValidatorContractController; -import org.hyperledger.besu.consensus.qbft.validator.ValidatorModeTransitionLogger; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.api.jsonrpc.methods.JsonRpcMethods; diff --git a/consensus/common/src/test-support/java/org/hyperledger/besu/consensus/common/bft/BftContextBuilder.java b/consensus/common/src/test-support/java/org/hyperledger/besu/consensus/common/bft/BftContextBuilder.java index 890045bf365..0a848c737cc 100644 --- a/consensus/common/src/test-support/java/org/hyperledger/besu/consensus/common/bft/BftContextBuilder.java +++ b/consensus/common/src/test-support/java/org/hyperledger/besu/consensus/common/bft/BftContextBuilder.java @@ -73,12 +73,20 @@ public static T setupContextWithBftExtraDataEncoder( final Class contextClazz, final Collection
validators, final BftExtraDataCodec bftExtraDataCodec) { + return setupContextWithBftBlockInterface( + contextClazz, validators, new BftBlockInterface(bftExtraDataCodec)); + } + + public static T setupContextWithBftBlockInterface( + final Class contextClazz, + final Collection
validators, + final BftBlockInterface bftBlockInterface) { final T bftContext = mock(contextClazz, withSettings().strictness(Strictness.LENIENT)); final ValidatorProvider mockValidatorProvider = mock(ValidatorProvider.class, withSettings().strictness(Strictness.LENIENT)); when(bftContext.getValidatorProvider()).thenReturn(mockValidatorProvider); when(mockValidatorProvider.getValidatorsAfterBlock(any())).thenReturn(validators); - when(bftContext.getBlockInterface()).thenReturn(new BftBlockInterface(bftExtraDataCodec)); + when(bftContext.getBlockInterface()).thenReturn(bftBlockInterface); when(bftContext.as(any())).thenReturn(bftContext); return bftContext; diff --git a/consensus/qbft-core/build.gradle b/consensus/qbft-core/build.gradle new file mode 100644 index 00000000000..5631f314f9c --- /dev/null +++ b/consensus/qbft-core/build.gradle @@ -0,0 +1,82 @@ +/* + * Copyright Besu Contributors. + * + * 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 + */ + +apply plugin: 'java-library' + +jar { + archiveBaseName = 'besu-qbft-core' + manifest { + attributes( + 'Specification-Title': archiveBaseName, + 'Specification-Version': project.version, + 'Implementation-Title': archiveBaseName, + 'Implementation-Version': calculateVersion(), + 'Commit-Hash': getGitCommitDetails(40).hash + ) + } +} + +dependencies { + implementation project(':config') + implementation project(':consensus:common') + implementation project(':crypto:services') + implementation project(':datatypes') + implementation project(':ethereum:blockcreation') + implementation project(':ethereum:core') + implementation project(':ethereum:eth') + implementation project(':ethereum:p2p') + implementation project(':ethereum:rlp') + implementation project(':evm') + + implementation 'com.google.guava:guava' + implementation 'io.tmio:tuweni-bytes' + + integrationTestImplementation project(path: ':config', configuration: 'testSupportArtifacts') + integrationTestImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') + + testImplementation project(path: ':crypto:services', configuration: 'testSupportArtifacts') + testImplementation project(path: ':config', configuration: 'testSupportArtifacts') + testImplementation project(path: ':consensus:common', configuration: 'testArtifacts') + testImplementation project(path: ':consensus:common', configuration: 'testSupportArtifacts') + testImplementation project(':ethereum:core') + testImplementation project(path: ':ethereum:core', configuration: 'testSupportArtifacts') + testImplementation project(':crypto:algorithms') + testImplementation project(':evm') + testImplementation project(':metrics:core') + testImplementation project(':testutil') + + testImplementation 'org.assertj:assertj-core' + testImplementation 'org.awaitility:awaitility' + testImplementation 'org.junit.jupiter:junit-jupiter' + testImplementation 'org.mockito:mockito-core' + testImplementation 'org.mockito:mockito-junit-jupiter' + + integrationTestImplementation project(':crypto:algorithms') + integrationTestImplementation project(path: ':crypto:services', configuration: 'testSupportArtifacts') + integrationTestImplementation project(path: ':consensus:common', configuration: 'testSupportArtifacts') + integrationTestImplementation project(':consensus:qbft') + integrationTestImplementation project(':evm') + integrationTestImplementation project(':metrics:core') + integrationTestImplementation project(':testutil') + + integrationTestImplementation 'org.assertj:assertj-core' + integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api' + integrationTestImplementation 'org.mockito:mockito-core' + integrationTestImplementation 'org.mockito:mockito-junit-jupiter' + + integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter' + + testSupportImplementation 'org.mockito:mockito-core' +} diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/IntegrationTestHelpers.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/IntegrationTestHelpers.java similarity index 90% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/IntegrationTestHelpers.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/IntegrationTestHelpers.java index 4a9f8e7057a..390302eb880 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/IntegrationTestHelpers.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/IntegrationTestHelpers.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.support; +package org.hyperledger.besu.consensus.qbft.core.support; import org.hyperledger.besu.consensus.common.bft.BftBlockHashing; import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions; @@ -20,9 +20,9 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.payload.CommitPayload; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.payload.CommitPayload; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/RoundSpecificPeers.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/RoundSpecificPeers.java similarity index 91% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/RoundSpecificPeers.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/RoundSpecificPeers.java index dc35796d0dc..afa07b31a4d 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/RoundSpecificPeers.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/RoundSpecificPeers.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.support; +package org.hyperledger.besu.consensus.qbft.core.support; import static java.util.Optional.empty; import static org.assertj.core.api.Assertions.assertThat; @@ -23,15 +23,15 @@ import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.Payload; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagedata.CommitMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.PrepareMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.messagedata.CommitMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.PrepareMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContext.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/TestContext.java similarity index 97% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContext.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/TestContext.java index 54dab34bdf5..0a65d03bcd3 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContext.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/TestContext.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.support; +package org.hyperledger.besu.consensus.qbft.core.support; import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions; import org.hyperledger.besu.consensus.common.bft.BftExecutors; @@ -23,7 +23,7 @@ import org.hyperledger.besu.consensus.common.bft.statemachine.BftEventHandler; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; import org.hyperledger.besu.consensus.common.validator.ValidatorProvider; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/TestContextBuilder.java similarity index 97% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/TestContextBuilder.java index 426d18e3e1d..29d65eda0b6 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/TestContextBuilder.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.support; +package org.hyperledger.besu.consensus.qbft.core.support; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider.createInMemoryBlockchain; @@ -64,18 +64,18 @@ import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory; -import org.hyperledger.besu.consensus.qbft.QbftGossip; import org.hyperledger.besu.consensus.qbft.QbftProtocolScheduleBuilder; import org.hyperledger.besu.consensus.qbft.blockcreation.QbftBlockCreatorFactory; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftBlockHeightManagerFactory; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftController; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftRoundFactory; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.network.QbftGossip; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftBlockHeightManagerFactory; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftController; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftRoundFactory; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.validator.ValidatorModeTransitionLogger; import org.hyperledger.besu.consensus.qbft.validator.ForkingValidatorProvider; import org.hyperledger.besu.consensus.qbft.validator.TransactionValidatorProvider; import org.hyperledger.besu.consensus.qbft.validator.ValidatorContractController; -import org.hyperledger.besu.consensus.qbft.validator.ValidatorModeTransitionLogger; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/ValidatorPeer.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/ValidatorPeer.java similarity index 76% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/ValidatorPeer.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/ValidatorPeer.java index af764bfed72..a4e482c7a1b 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/ValidatorPeer.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/support/ValidatorPeer.java @@ -12,27 +12,27 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.support; +package org.hyperledger.besu.consensus.qbft.core.support; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createCommitBlockFromProposalBlock; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createCommitBlockFromProposalBlock; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.EventMultiplexer; import org.hyperledger.besu.consensus.common.bft.inttest.DefaultValidatorPeer; import org.hyperledger.besu.consensus.common.bft.inttest.NodeParams; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagedata.CommitMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.PrepareMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.messagedata.CommitMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.PrepareMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/FutureHeightTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/FutureHeightTest.java similarity index 94% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/FutureHeightTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/FutureHeightTest.java index 811899bc7f5..a8438d3c01e 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/FutureHeightTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/FutureHeightTest.java @@ -12,23 +12,23 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.util.Lists.emptyList; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createSignedCommitPayload; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createSignedCommitPayload; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.events.NewChainHead; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; import org.hyperledger.besu.ethereum.core.Block; import java.time.Clock; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/FutureRoundTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/FutureRoundTest.java similarity index 89% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/FutureRoundTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/FutureRoundTest.java index 9681ca4f7d6..c2920619e46 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/FutureRoundTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/FutureRoundTest.java @@ -12,22 +12,22 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createCommitBlockFromProposalBlock; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createCommitBlockFromProposalBlock; import org.hyperledger.besu.consensus.common.bft.BftHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/GossipTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/GossipTest.java similarity index 88% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/GossipTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/GossipTest.java index fbe98de6b79..acafe66a055 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/GossipTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/GossipTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static java.util.Collections.emptyList; @@ -20,16 +20,16 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.events.NewChainHead; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; -import org.hyperledger.besu.consensus.qbft.support.ValidatorPeer; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.support.ValidatorPeer; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/LocalNodeIsProposerTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/LocalNodeIsProposerTest.java similarity index 90% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/LocalNodeIsProposerTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/LocalNodeIsProposerTest.java index e5885d96a4f..85896bda3e4 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/LocalNodeIsProposerTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/LocalNodeIsProposerTest.java @@ -12,22 +12,22 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createSignedCommitPayload; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createSignedCommitPayload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.events.BlockTimerExpiry; import org.hyperledger.besu.consensus.common.bft.events.NewChainHead; import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; import org.hyperledger.besu.ethereum.core.Block; import java.time.Clock; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/LocalNodeNotProposerTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/LocalNodeNotProposerTest.java similarity index 89% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/LocalNodeNotProposerTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/LocalNodeNotProposerTest.java index 9d386178686..16cc4f87807 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/LocalNodeNotProposerTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/LocalNodeNotProposerTest.java @@ -12,18 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createSignedCommitPayload; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createSignedCommitPayload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; import org.hyperledger.besu.ethereum.core.Block; import org.junit.jupiter.api.BeforeEach; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ReceivedFutureProposalTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/ReceivedFutureProposalTest.java similarity index 90% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ReceivedFutureProposalTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/ReceivedFutureProposalTest.java index 77b33ad2adc..260e996c223 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ReceivedFutureProposalTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/ReceivedFutureProposalTest.java @@ -12,23 +12,23 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createValidPreparedCertificate; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; -import org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; -import org.hyperledger.besu.consensus.qbft.support.ValidatorPeer; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.support.ValidatorPeer; import org.hyperledger.besu.ethereum.core.Block; import java.util.Collections; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/RoundChangeTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/RoundChangeTest.java similarity index 93% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/RoundChangeTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/RoundChangeTest.java index b1464efd53b..79761b10064 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/RoundChangeTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/RoundChangeTest.java @@ -12,27 +12,27 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static java.util.Collections.emptyList; import static java.util.Optional.empty; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createValidPreparedCertificate; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createValidPreparedCertificate; import org.hyperledger.besu.consensus.common.bft.BftHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.events.BlockTimerExpiry; import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; -import org.hyperledger.besu.consensus.qbft.support.ValidatorPeer; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.support.ValidatorPeer; import org.hyperledger.besu.ethereum.core.Block; import java.time.Clock; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/SpuriousBehaviourTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/SpuriousBehaviourTest.java similarity index 88% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/SpuriousBehaviourTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/SpuriousBehaviourTest.java index 8f1bfb9a7fd..a18a885bafd 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/SpuriousBehaviourTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/SpuriousBehaviourTest.java @@ -12,21 +12,21 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.consensus.qbft.support.IntegrationTestHelpers.createSignedCommitPayload; +import static org.hyperledger.besu.consensus.qbft.core.support.IntegrationTestHelpers.createSignedCommitPayload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.inttest.NodeParams; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; -import org.hyperledger.besu.consensus.qbft.support.ValidatorPeer; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.support.ValidatorPeer; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/TransitionsTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/TransitionsTest.java similarity index 93% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/TransitionsTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/TransitionsTest.java index 93268ab1b81..1c57e532b33 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/TransitionsTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/TransitionsTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static org.assertj.core.api.Assertions.assertThat; @@ -21,8 +21,8 @@ import org.hyperledger.besu.config.QbftFork; import org.hyperledger.besu.consensus.common.bft.BftEventQueue; import org.hyperledger.besu.consensus.common.bft.events.NewChainHead; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.testutil.TestClock; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/ValidatorContractTest.java similarity index 98% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/ValidatorContractTest.java index c5978560065..4ab147989e3 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/ValidatorContractTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/ValidatorContractTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test; +package org.hyperledger.besu.consensus.qbft.core.test; import static java.time.temporal.ChronoUnit.SECONDS; import static org.assertj.core.api.Assertions.assertThat; @@ -27,10 +27,10 @@ import org.hyperledger.besu.consensus.common.bft.inttest.NodeParams; import org.hyperledger.besu.consensus.common.validator.ValidatorProvider; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.support.RoundSpecificPeers; -import org.hyperledger.besu.consensus.qbft.support.TestContext; -import org.hyperledger.besu.consensus.qbft.support.TestContextBuilder; -import org.hyperledger.besu.consensus.qbft.support.ValidatorPeer; +import org.hyperledger.besu.consensus.qbft.core.support.RoundSpecificPeers; +import org.hyperledger.besu.consensus.qbft.core.support.TestContext; +import org.hyperledger.besu.consensus.qbft.core.support.TestContextBuilder; +import org.hyperledger.besu.consensus.qbft.core.support.ValidatorPeer; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/round/QbftRoundIntegrationTest.java b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/round/QbftRoundIntegrationTest.java similarity index 95% rename from consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/round/QbftRoundIntegrationTest.java rename to consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/round/QbftRoundIntegrationTest.java index 7dcca442a7f..e93b2e7f40e 100644 --- a/consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/test/round/QbftRoundIntegrationTest.java +++ b/consensus/qbft-core/src/integration-test/java/org/hyperledger/besu/consensus/qbft/core/test/round/QbftRoundIntegrationTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.test.round; +package org.hyperledger.besu.consensus.qbft.core.test.round; import static java.util.Collections.emptyList; import static java.util.Optional.empty; @@ -32,11 +32,11 @@ import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator; import org.hyperledger.besu.consensus.common.bft.inttest.StubValidatorMulticaster; import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.statemachine.QbftRound; -import org.hyperledger.besu.consensus.qbft.statemachine.RoundState; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidator; +import org.hyperledger.besu.consensus.qbft.core.network.QbftMessageTransmitter; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.statemachine.QbftRound; +import org.hyperledger.besu.consensus.qbft.core.statemachine.RoundState; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidator; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.cryptoservices.NodeKey; diff --git a/consensus/qbft/src/integration-test/resources/genesis_migrating_validator_contract.json b/consensus/qbft-core/src/integration-test/resources/genesis_migrating_validator_contract.json similarity index 100% rename from consensus/qbft/src/integration-test/resources/genesis_migrating_validator_contract.json rename to consensus/qbft-core/src/integration-test/resources/genesis_migrating_validator_contract.json diff --git a/consensus/qbft/src/integration-test/resources/genesis_validator_contract.json b/consensus/qbft-core/src/integration-test/resources/genesis_validator_contract.json similarity index 100% rename from consensus/qbft/src/integration-test/resources/genesis_validator_contract.json rename to consensus/qbft-core/src/integration-test/resources/genesis_validator_contract.json diff --git a/consensus/qbft/src/integration-test/resources/genesis_validator_contract_london.json b/consensus/qbft-core/src/integration-test/resources/genesis_validator_contract_london.json similarity index 100% rename from consensus/qbft/src/integration-test/resources/genesis_validator_contract_london.json rename to consensus/qbft-core/src/integration-test/resources/genesis_validator_contract_london.json diff --git a/consensus/qbft/src/integration-test/resources/genesis_validator_contract_shanghai.json b/consensus/qbft-core/src/integration-test/resources/genesis_validator_contract_shanghai.json similarity index 100% rename from consensus/qbft/src/integration-test/resources/genesis_validator_contract_shanghai.json rename to consensus/qbft-core/src/integration-test/resources/genesis_validator_contract_shanghai.json diff --git a/consensus/qbft/src/integration-test/resources/log4j2.xml b/consensus/qbft-core/src/integration-test/resources/log4j2.xml similarity index 100% rename from consensus/qbft/src/integration-test/resources/log4j2.xml rename to consensus/qbft-core/src/integration-test/resources/log4j2.xml diff --git a/consensus/qbft/src/integration-test/resources/validator_contract.sol b/consensus/qbft-core/src/integration-test/resources/validator_contract.sol similarity index 100% rename from consensus/qbft/src/integration-test/resources/validator_contract.sol rename to consensus/qbft-core/src/integration-test/resources/validator_contract.sol diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/CommitMessageData.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/CommitMessageData.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/CommitMessageData.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/CommitMessageData.java index c0e8c537cd6..f39c3e66e19 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/CommitMessageData.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/CommitMessageData.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagedata; +package org.hyperledger.besu.consensus.qbft.core.messagedata; import org.hyperledger.besu.consensus.common.bft.messagedata.AbstractBftMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.apache.tuweni.bytes.Bytes; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/PrepareMessageData.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/PrepareMessageData.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/PrepareMessageData.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/PrepareMessageData.java index 30ed2e33dac..564468cfe6e 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/PrepareMessageData.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/PrepareMessageData.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagedata; +package org.hyperledger.besu.consensus.qbft.core.messagedata; import org.hyperledger.besu.consensus.common.bft.messagedata.AbstractBftMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.apache.tuweni.bytes.Bytes; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/ProposalMessageData.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/ProposalMessageData.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/ProposalMessageData.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/ProposalMessageData.java index 28d8c8d82e9..e474c5cfd86 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/ProposalMessageData.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/ProposalMessageData.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagedata; +package org.hyperledger.besu.consensus.qbft.core.messagedata; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.messagedata.AbstractBftMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.apache.tuweni.bytes.Bytes; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/QbftV1.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/QbftV1.java similarity index 94% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/QbftV1.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/QbftV1.java index ef42312b37a..a598308b39c 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/QbftV1.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/QbftV1.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagedata; +package org.hyperledger.besu.consensus.qbft.core.messagedata; /** Message codes for QBFT v1 messages */ public interface QbftV1 { diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/RoundChangeMessageData.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/RoundChangeMessageData.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/RoundChangeMessageData.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/RoundChangeMessageData.java index 6b017b0a1a2..37ebe4c0a2a 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagedata/RoundChangeMessageData.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagedata/RoundChangeMessageData.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagedata; +package org.hyperledger.besu.consensus.qbft.core.messagedata; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.messagedata.AbstractBftMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.apache.tuweni.bytes.Bytes; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Commit.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Commit.java similarity index 92% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Commit.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Commit.java index 5745f7af9de..142069ec708 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Commit.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Commit.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.CommitPayload; +import org.hyperledger.besu.consensus.qbft.core.payload.CommitPayload; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.rlp.RLP; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Prepare.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Prepare.java similarity index 92% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Prepare.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Prepare.java index 2ffd0bf180f..28bcae7bf80 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Prepare.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Prepare.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Proposal.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Proposal.java similarity index 92% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Proposal.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Proposal.java index 8650a9c6b66..20847236f14 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/Proposal.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/Proposal.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.ProposalPayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.ProposalPayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/RoundChange.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/RoundChange.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/RoundChange.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/RoundChange.java index cbebdf7debd..945a4bafb63 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/messagewrappers/RoundChange.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/RoundChange.java @@ -12,15 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftGossip.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/network/QbftGossip.java similarity index 87% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftGossip.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/network/QbftGossip.java index d0965e11620..c2ebf480a79 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftGossip.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/network/QbftGossip.java @@ -12,17 +12,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft; +package org.hyperledger.besu.consensus.qbft.core.network; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.Gossiper; import org.hyperledger.besu.consensus.common.bft.network.ValidatorMulticaster; import org.hyperledger.besu.consensus.common.bft.payload.Authored; -import org.hyperledger.besu.consensus.qbft.messagedata.CommitMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.PrepareMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.CommitMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.PrepareMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Message; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/network/QbftMessageTransmitter.java similarity index 82% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/network/QbftMessageTransmitter.java index 7c5b93c24a7..5aaa4887fe0 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/network/QbftMessageTransmitter.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/network/QbftMessageTransmitter.java @@ -12,23 +12,23 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.network; +package org.hyperledger.besu.consensus.qbft.core.network; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.network.ValidatorMulticaster; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagedata.CommitMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.PrepareMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.messagedata.CommitMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.PrepareMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/CommitPayload.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/CommitPayload.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/CommitPayload.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/CommitPayload.java index 716417922c4..824bd063bd6 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/CommitPayload.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/CommitPayload.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.Payload; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.Hash; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/MessageFactory.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/MessageFactory.java similarity index 90% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/MessageFactory.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/MessageFactory.java index 860a4c9c418..c359c7ef597 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/MessageFactory.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/MessageFactory.java @@ -12,16 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.Payload; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.datatypes.Hash; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/PreparePayload.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/PreparePayload.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/PreparePayload.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/PreparePayload.java index b0198058e45..58470b2a4d6 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/PreparePayload.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/PreparePayload.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.Payload; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/PreparedRoundMetadata.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/PreparedRoundMetadata.java similarity index 98% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/PreparedRoundMetadata.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/PreparedRoundMetadata.java index 5e534a7178c..4b732d1551b 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/PreparedRoundMetadata.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/PreparedRoundMetadata.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.rlp.RLPInput; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/ProposalPayload.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/ProposalPayload.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/ProposalPayload.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/ProposalPayload.java index 3bbe48dec0f..81a5caa2d94 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/ProposalPayload.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/ProposalPayload.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/QbftPayload.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/QbftPayload.java similarity index 97% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/QbftPayload.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/QbftPayload.java index 4cc64e9d0d0..57faa3225fb 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/QbftPayload.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/QbftPayload.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.Payload; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/RoundChangePayload.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/RoundChangePayload.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/RoundChangePayload.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/RoundChangePayload.java index f40e0464c32..9f4d9abedbd 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/payload/RoundChangePayload.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/payload/RoundChangePayload.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/BaseQbftBlockHeightManager.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/BaseQbftBlockHeightManager.java similarity index 79% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/BaseQbftBlockHeightManager.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/BaseQbftBlockHeightManager.java index 6f1cca0d350..b426263c25b 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/BaseQbftBlockHeightManager.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/BaseQbftBlockHeightManager.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.statemachine.BaseBlockHeightManager; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; /** The interface Base qbft block height manager. */ public interface BaseQbftBlockHeightManager extends BaseBlockHeightManager { diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/NoOpBlockHeightManager.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/NoOpBlockHeightManager.java similarity index 83% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/NoOpBlockHeightManager.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/NoOpBlockHeightManager.java index ae5bde0e9a2..4ad83333d6c 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/NoOpBlockHeightManager.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/NoOpBlockHeightManager.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; import org.hyperledger.besu.ethereum.core.BlockHeader; /** The type NoOp block height manager. */ diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/PreparedCertificate.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/PreparedCertificate.java similarity index 92% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/PreparedCertificate.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/PreparedCertificate.java index 3b5a8df848a..aa72d62fef0 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/PreparedCertificate.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/PreparedCertificate.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; import org.hyperledger.besu.ethereum.core.Block; import java.util.List; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManager.java similarity index 95% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManager.java index 757998b5ca6..2c7e55cbf66 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManager.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManager.java @@ -12,21 +12,21 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.Payload; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.validation.FutureRoundProposalMessageValidator; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.network.QbftMessageTransmitter; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.validation.FutureRoundProposalMessageValidator; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidatorFactory; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockHeader; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerFactory.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManagerFactory.java similarity index 92% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerFactory.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManagerFactory.java index 889f83f98a7..679ef222eb6 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerFactory.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManagerFactory.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.BftHelpers; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidatorFactory; -import org.hyperledger.besu.consensus.qbft.validator.ValidatorModeTransitionLogger; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.validator.ValidatorModeTransitionLogger; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.slf4j.Logger; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftController.java similarity index 90% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftController.java index 57737542eaf..4944aba53bc 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftController.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftController.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.Gossiper; @@ -22,11 +22,11 @@ import org.hyperledger.besu.consensus.common.bft.statemachine.BaseBlockHeightManager; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; import org.hyperledger.besu.consensus.common.bft.statemachine.FutureMessageBuffer; -import org.hyperledger.besu.consensus.qbft.messagedata.CommitMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.PrepareMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.CommitMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.PrepareMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; import org.hyperledger.besu.ethereum.chain.Blockchain; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Message; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRound.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRound.java index 64f23cef279..6a7ce1042a7 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRound.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRound.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import static java.util.Collections.emptyList; @@ -26,13 +26,13 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.RoundTimer; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.network.QbftMessageTransmitter; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.datatypes.Hash; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRoundFactory.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRoundFactory.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRoundFactory.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRoundFactory.java index 6383945bcdf..ca57b50baa5 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRoundFactory.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRoundFactory.java @@ -12,16 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreatorFactory; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; -import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.network.QbftMessageTransmitter; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidatorFactory; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.blockcreation.BlockCreator; import org.hyperledger.besu.ethereum.chain.MinedBlockObserver; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeArtifacts.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundChangeArtifacts.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeArtifacts.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundChangeArtifacts.java index 322d6990ac4..773ff06ef25 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeArtifacts.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundChangeArtifacts.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import java.util.Collection; import java.util.Comparator; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundChangeManager.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundChangeManager.java index 89e2888395c..aa4f605c7c5 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundChangeManager.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundChangeManager.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.validation.RoundChangeMessageValidator; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.validation.RoundChangeMessageValidator; import org.hyperledger.besu.datatypes.Address; import java.util.Collection; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundState.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundState.java index 6acbae56558..d9a9221e4a3 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundState.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundState.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidator; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidator; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/CommitValidator.java similarity index 94% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/CommitValidator.java index 35e49dbb171..e211c6a8ede 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/CommitValidator.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.payload.CommitPayload; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.payload.CommitPayload; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Util; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/FutureRoundProposalMessageValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/FutureRoundProposalMessageValidator.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/FutureRoundProposalMessageValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/FutureRoundProposalMessageValidator.java index 3c401bb203c..dd585c26fda 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/FutureRoundProposalMessageValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/FutureRoundProposalMessageValidator.java @@ -12,10 +12,10 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; import org.hyperledger.besu.ethereum.core.BlockHeader; /** The Future round proposal message validator. */ diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/MessageValidator.java similarity index 94% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/MessageValidator.java index ac112baa051..f526f2b7a3a 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/MessageValidator.java @@ -12,15 +12,15 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions; import org.hyperledger.besu.consensus.common.bft.BftBlockInterface; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidatorFactory.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/MessageValidatorFactory.java similarity index 97% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidatorFactory.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/MessageValidatorFactory.java index b5164746bf6..17795acfb21 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/MessageValidatorFactory.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/MessageValidatorFactory.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.BftBlockInterface; import org.hyperledger.besu.consensus.common.bft.BftContext; @@ -21,7 +21,7 @@ import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.blockcreation.ProposerSelector; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidator.SubsequentMessageValidator; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidator.SubsequentMessageValidator; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.ProtocolContext; import org.hyperledger.besu.ethereum.core.BlockHeader; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/PrepareValidator.java similarity index 92% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/PrepareValidator.java index 54fbaef855f..61bde6a802d 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/PrepareValidator.java @@ -12,12 +12,12 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalPayloadValidator.java similarity index 96% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalPayloadValidator.java index 3d04f699c04..a50f2c79345 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalPayloadValidator.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static com.google.common.base.Preconditions.checkState; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.ProposalPayload; +import org.hyperledger.besu.consensus.qbft.core.payload.ProposalPayload; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.BlockValidator; import org.hyperledger.besu.ethereum.ProtocolContext; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalValidator.java similarity index 97% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalValidator.java index bc3f1bb205c..094521133cd 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalValidator.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static org.hyperledger.besu.consensus.common.bft.validation.ValidationHelpers.hasDuplicateAuthors; import static org.hyperledger.besu.consensus.common.bft.validation.ValidationHelpers.hasSufficientEntries; @@ -24,10 +24,10 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.Payload; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.BlockValidator; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangeMessageValidator.java similarity index 94% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangeMessageValidator.java index 0f0761d4621..1420c32c418 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangeMessageValidator.java @@ -12,16 +12,16 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static org.hyperledger.besu.consensus.common.bft.validation.ValidationHelpers.hasDuplicateAuthors; import static org.hyperledger.besu.consensus.common.bft.validation.ValidationHelpers.hasSufficientEntries; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.ethereum.BlockValidator; import org.hyperledger.besu.ethereum.ProtocolContext; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangePayloadValidator.java similarity index 93% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangePayloadValidator.java index 18977bf2902..549acdd9c55 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidator.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangePayloadValidator.java @@ -12,11 +12,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.datatypes.Address; import java.util.Collection; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validator/ValidatorModeTransitionLogger.java similarity index 98% rename from consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java rename to consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validator/ValidatorModeTransitionLogger.java index 83c18262c66..8265959ef63 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java +++ b/consensus/qbft-core/src/main/java/org/hyperledger/besu/consensus/qbft/core/validator/ValidatorModeTransitionLogger.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validator; +package org.hyperledger.besu.consensus.qbft.core.validator; import org.hyperledger.besu.config.QbftConfigOptions; import org.hyperledger.besu.consensus.common.ForkSpec; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/CommitTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/CommitTest.java similarity index 91% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/CommitTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/CommitTest.java index 87d3a46abe5..11cc9cbeb41 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/CommitTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/CommitTest.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.payload.CommitPayload; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.payload.CommitPayload; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/PrepareTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/PrepareTest.java similarity index 90% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/PrepareTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/PrepareTest.java index 0aed7ed554e..adff617af1c 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/PrepareTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/PrepareTest.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/ProposalTest.java similarity index 79% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/ProposalTest.java index 5b7314f94a2..52946270031 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/ProposalTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/ProposalTest.java @@ -12,20 +12,18 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.consensus.common.bft.BftExtraData; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.ProposalPayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.ProposalPayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; @@ -38,19 +36,18 @@ import java.util.List; import java.util.Optional; -import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +@ExtendWith(MockitoExtension.class) public class ProposalTest { - private static final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec(); - - private static final BftExtraData extraData = - new BftExtraData( - Bytes32.ZERO, Collections.emptyList(), Optional.empty(), 1, Collections.emptyList()); + @Mock private BftExtraDataCodec bftExtraDataCodec; private static final Block BLOCK = new Block( - new BlockHeaderTestFixture().extraData(bftExtraDataCodec.encode(extraData)).buildHeader(), + new BlockHeaderTestFixture().buildHeader(), new BlockBody( Collections.emptyList(), Collections.emptyList(), diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/RoundChangeTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/RoundChangeTest.java similarity index 82% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/RoundChangeTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/RoundChangeTest.java index 23de31417c6..1f38cb787eb 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/messagewrappers/RoundChangeTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/messagewrappers/RoundChangeTest.java @@ -12,19 +12,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.messagewrappers; +package org.hyperledger.besu.consensus.qbft.core.messagewrappers; import static org.assertj.core.api.Assertions.assertThat; -import org.hyperledger.besu.consensus.common.bft.BftExtraData; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; @@ -37,20 +35,18 @@ import java.util.List; import java.util.Optional; -import org.apache.tuweni.bytes.Bytes32; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +@ExtendWith(MockitoExtension.class) public class RoundChangeTest { - private static final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec(); - private static final BftExtraData extraData = - new BftExtraData( - Bytes32.ZERO, Collections.emptyList(), Optional.empty(), 1, Collections.emptyList()); + @Mock private BftExtraDataCodec bftExtraDataCodec; private static final Block BLOCK = new Block( - new BlockHeaderTestFixture() - .extraData(new QbftExtraDataCodec().encode(extraData)) - .buildHeader(), + new BlockHeaderTestFixture().buildHeader(), new BlockBody(Collections.emptyList(), Collections.emptyList())); @Test diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/payload/QbftPayloadTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/payload/QbftPayloadTest.java similarity index 97% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/payload/QbftPayloadTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/payload/QbftPayloadTest.java index 820b0f976f9..38db37cca76 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/payload/QbftPayloadTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/payload/QbftPayloadTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.payload; +package org.hyperledger.besu.consensus.qbft.core.payload; import static org.assertj.core.api.Assertions.assertThat; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManagerTest.java similarity index 94% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManagerTest.java index b6adcb73e62..d77a28867bb 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftBlockHeightManagerTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftBlockHeightManagerTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; @@ -43,17 +43,16 @@ import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; import org.hyperledger.besu.consensus.common.bft.network.ValidatorMulticaster; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.validation.FutureRoundProposalMessageValidator; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidator; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidatorFactory; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.network.QbftMessageTransmitter; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.validation.FutureRoundProposalMessageValidator; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidator; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidatorFactory; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; @@ -107,7 +106,6 @@ public class QbftBlockHeightManagerTest { private final NodeKey nodeKey = NodeKeyUtils.generate(); private final MessageFactory messageFactory = new MessageFactory(nodeKey); private final BlockHeaderTestFixture headerTestFixture = new BlockHeaderTestFixture(); - private final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec(); @Mock private BftFinalState finalState; @Mock private QbftMessageTransmitter messageTransmitter; @@ -122,6 +120,7 @@ public class QbftBlockHeightManagerTest { @Mock private FutureRoundProposalMessageValidator futureRoundProposalMessageValidator; @Mock private ValidatorMulticaster validatorMulticaster; @Mock private BlockHeader parentHeader; + @Mock private BftExtraDataCodec bftExtraDataCodec; @Captor private ArgumentCaptor sentMessageArgCaptor; @@ -133,11 +132,6 @@ public class QbftBlockHeightManagerTest { private Block createdBlock; private void buildCreatedBlock() { - - final BftExtraData extraData = - new BftExtraData(Bytes.wrap(new byte[32]), emptyList(), Optional.empty(), 0, validators); - - headerTestFixture.extraData(bftExtraDataCodec.encode(extraData)); final BlockHeader header = headerTestFixture.buildHeader(); createdBlock = new Block(header, new BlockBody(emptyList(), emptyList())); } @@ -175,8 +169,7 @@ public void setup() { new ProtocolContext( blockchain, null, - setupContextWithBftExtraDataEncoder( - BftContext.class, validators, new QbftExtraDataCodec()), + setupContextWithBftExtraDataEncoder(BftContext.class, validators, bftExtraDataCodec), new BadBlockManager()); final ProtocolScheduleBuilder protocolScheduleBuilder = @@ -234,6 +227,12 @@ BftContext.class, validators, new QbftExtraDataCodec()), bftExtraDataCodec, parentHeader); }); + + when(bftExtraDataCodec.decode(any())) + .thenReturn( + new BftExtraData( + Bytes.wrap(new byte[32]), emptyList(), Optional.empty(), 0, validators)); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); } @Test diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftControllerTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftControllerTest.java similarity index 95% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftControllerTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftControllerTest.java index 3e3a38af824..d6e6fb9fc6f 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftControllerTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftControllerTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import static org.assertj.core.util.Lists.newArrayList; import static org.mockito.ArgumentMatchers.any; @@ -35,17 +35,16 @@ import org.hyperledger.besu.consensus.common.bft.events.RoundExpiry; import org.hyperledger.besu.consensus.common.bft.statemachine.BftFinalState; import org.hyperledger.besu.consensus.common.bft.statemachine.FutureMessageBuffer; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.QbftGossip; -import org.hyperledger.besu.consensus.qbft.messagedata.CommitMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.PrepareMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.ProposalMessageData; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; -import org.hyperledger.besu.consensus.qbft.messagedata.RoundChangeMessageData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.messagedata.CommitMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.PrepareMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.ProposalMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.RoundChangeMessageData; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.network.QbftGossip; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.chain.Blockchain; @@ -68,14 +67,13 @@ @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) public class QbftControllerTest { - private static final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec(); - @Mock private Blockchain blockChain; @Mock private BftFinalState bftFinalState; @Mock private QbftBlockHeightManagerFactory blockHeightManagerFactory; @Mock private BlockHeader chainHeadBlockHeader; @Mock private BlockHeader nextBlock; @Mock private BaseQbftBlockHeightManager blockHeightManager; + @Mock private BftExtraDataCodec bftExtraDataCodec; @Mock private Proposal proposal; private Message proposalMessage; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRoundTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRoundTest.java similarity index 89% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRoundTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRoundTest.java index fb84c1c38fa..f6dc5e31902 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/QbftRoundTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/QbftRoundTest.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; import static java.util.Optional.empty; import static org.assertj.core.api.Assertions.assertThat; -import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftExtraDataEncoder; +import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftBlockInterface; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; @@ -29,6 +29,7 @@ import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; +import org.hyperledger.besu.consensus.common.bft.BftBlockInterface; import org.hyperledger.besu.consensus.common.bft.BftContext; import org.hyperledger.besu.consensus.common.bft.BftExtraData; import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; @@ -37,12 +38,11 @@ import org.hyperledger.besu.consensus.common.bft.RoundTimer; import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.network.QbftMessageTransmitter; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidator; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.network.QbftMessageTransmitter; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidator; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.cryptoservices.NodeKey; @@ -91,7 +91,6 @@ public class QbftRoundTest { private final MessageFactory messageFactory = new MessageFactory(nodeKey); private final MessageFactory messageFactory2 = new MessageFactory(nodeKey2); private final Subscribers subscribers = Subscribers.create(); - private final BftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec(); private ProtocolContext protocolContext; @Mock private BftProtocolSchedule protocolSchedule; @@ -105,11 +104,12 @@ public class QbftRoundTest { @Mock private ProtocolSpec protocolSpec; @Mock private BlockImporter blockImporter; @Mock private BlockHeader parentHeader; + @Mock private BftExtraDataCodec bftExtraDataCodec; + @Mock private BftBlockInterface bftBlockInteface; @Captor private ArgumentCaptor blockCaptor; private Block proposedBlock; - private BftExtraData proposedExtraData; private final SECPSignature remoteCommitSeal = SignatureAlgorithmFactory.getInstance() @@ -121,18 +121,14 @@ public void setup() { new ProtocolContext( blockChain, worldStateArchive, - setupContextWithBftExtraDataEncoder( - BftContext.class, emptyList(), new QbftExtraDataCodec()), + setupContextWithBftBlockInterface(BftContext.class, emptyList(), bftBlockInteface), new BadBlockManager()); when(messageValidator.validateProposal(any())).thenReturn(true); when(messageValidator.validatePrepare(any())).thenReturn(true); when(messageValidator.validateCommit(any())).thenReturn(true); - proposedExtraData = - new BftExtraData(Bytes.wrap(new byte[32]), emptyList(), empty(), 0, emptyList()); final BlockHeaderTestFixture headerTestFixture = new BlockHeaderTestFixture(); - headerTestFixture.extraData(new QbftExtraDataCodec().encode(proposedExtraData)); headerTestFixture.number(1); final BlockHeader header = headerTestFixture.buildHeader(); @@ -149,6 +145,16 @@ BftContext.class, emptyList(), new QbftExtraDataCodec()), when(blockImporter.importBlock(any(), any(), any())) .thenReturn(new BlockImportResult(BlockImportResult.BlockImportStatus.IMPORTED)); + BftExtraData bftExtraData = + new BftExtraData(Bytes.wrap(new byte[32]), emptyList(), empty(), 0, emptyList()); + when(bftExtraDataCodec.decode(any())).thenReturn(bftExtraData); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSealsAndRoundNumber(any())).thenReturn(Bytes.EMPTY); + when(bftBlockInteface.replaceRoundInBlock( + eq(proposedBlock), eq(roundIdentifier.getRoundNumber()), any())) + .thenReturn(proposedBlock); + subscribers.subscribe(minedBlockObserver); } @@ -187,6 +193,9 @@ public void onReceptionOfValidProposalSendsAPrepareToNetworkPeers() { bftExtraDataCodec, parentHeader); + when(bftBlockInteface.replaceRoundInBlock(eq(proposedBlock), eq(0), any())) + .thenReturn(proposedBlock); + round.handleProposalMessage( messageFactory.createProposal( roundIdentifier, proposedBlock, Collections.emptyList(), Collections.emptyList())); @@ -256,10 +265,6 @@ public void aProposalMessageWithTheSameBlockIsSentUponReceptionOfARoundChangeWit verify(transmitter, times(1)) .multicastPrepare(eq(roundIdentifier), eq(blockCaptor.getValue().getHash())); - final BftExtraData proposedExtraData = - new QbftExtraDataCodec().decode(blockCaptor.getValue().getHeader()); - assertThat(proposedExtraData.getRound()).isEqualTo(roundIdentifier.getRoundNumber()); - // Inject a single Prepare message, and confirm the roundState has gone to Prepared (which // indicates the block has entered the roundState (note: all msgs are deemed valid due to mocks) round.handlePrepareMessage( @@ -326,6 +331,9 @@ public void blockIsOnlyImportedOnceWhenCommitsAreReceivedBeforeProposal() { bftExtraDataCodec, parentHeader); + when(bftBlockInteface.replaceRoundInBlock(eq(proposedBlock), eq(0), any())) + .thenReturn(proposedBlock); + round.handleCommitMessage( messageFactory.createCommit(roundIdentifier, proposedBlock.getHash(), remoteCommitSeal)); @@ -352,6 +360,9 @@ public void blockIsImportedOnlyOnceIfQuorumCommitsAreReceivedPriorToProposal() { bftExtraDataCodec, parentHeader); + when(bftBlockInteface.replaceRoundInBlock(eq(proposedBlock), eq(0), any())) + .thenReturn(proposedBlock); + round.handleCommitMessage( messageFactory.createCommit(roundIdentifier, proposedBlock.getHash(), remoteCommitSeal)); @@ -382,6 +393,9 @@ public void exceptionDuringNodeKeySigningDoesNotEscape() { bftExtraDataCodec, parentHeader); + when(bftBlockInteface.replaceRoundInBlock(eq(proposedBlock), eq(0), any())) + .thenReturn(proposedBlock); + round.handleProposalMessage( messageFactory.createProposal( roundIdentifier, proposedBlock, Collections.emptyList(), Collections.emptyList())); diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundStateTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundStateTest.java similarity index 96% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundStateTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundStateTest.java index ff76a19b8ad..8cdd29c4009 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/statemachine/RoundStateTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/statemachine/RoundStateTest.java @@ -12,7 +12,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.statemachine; +package org.hyperledger.besu.consensus.qbft.core.statemachine; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; @@ -23,12 +23,12 @@ import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.messagewrappers.BftMessage; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.validation.MessageValidator; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.validation.MessageValidator; import org.hyperledger.besu.crypto.SignatureAlgorithm; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.cryptoservices.NodeKey; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidatorTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/CommitValidatorTest.java similarity index 96% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidatorTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/CommitValidatorTest.java index 02ca653f2a3..3960cf64f9b 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/CommitValidatorTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/CommitValidatorTest.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Commit; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Commit; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.datatypes.Hash; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidatorTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/PrepareValidatorTest.java similarity index 95% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidatorTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/PrepareValidatorTest.java index b6c63b5598b..91a36ee61a0 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/PrepareValidatorTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/PrepareValidatorTest.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; import org.hyperledger.besu.datatypes.Hash; import org.junit.jupiter.api.Test; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalPayloadValidatorTest.java similarity index 92% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalPayloadValidatorTest.java index 09e9455d89e..0cc93a4c46d 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalPayloadValidatorTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalPayloadValidatorTest.java @@ -12,22 +12,23 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftExtraDataEncoder; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; import org.hyperledger.besu.consensus.common.bft.BftContext; +import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; @@ -43,6 +44,7 @@ import java.util.Optional; +import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -55,6 +57,7 @@ public class ProposalPayloadValidatorTest { @Mock private BlockValidator blockValidator; @Mock private MutableBlockchain blockChain; @Mock private WorldStateArchive worldStateArchive; + @Mock private BftExtraDataCodec bftExtraDataCodec; private ProtocolContext protocolContext; private static final int CHAIN_HEIGHT = 3; @@ -66,7 +69,6 @@ public class ProposalPayloadValidatorTest { private final MessageFactory messageFactory = new MessageFactory(nodeKey); final ConsensusRoundIdentifier roundIdentifier = ConsensusRoundHelpers.createFrom(targetRound, 1, 0); - final QbftExtraDataCodec bftExtraDataCodec = new QbftExtraDataCodec(); @BeforeEach public void setup() { @@ -80,6 +82,7 @@ public void setup() { @Test public void validationPassesWhenProposerAndRoundMatchAndBlockIsValid() { + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); final ProposalPayloadValidator payloadValidator = new ProposalPayloadValidator( expectedProposer, roundIdentifier, blockValidator, protocolContext); @@ -101,6 +104,7 @@ public void validationPassesWhenProposerAndRoundMatchAndBlockIsValid() { @Test public void validationPassesWhenBlockRoundDoesNotMatchProposalRound() { + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); final ProposalPayloadValidator payloadValidator = new ProposalPayloadValidator( expectedProposer, roundIdentifier, blockValidator, protocolContext); @@ -126,6 +130,7 @@ public void validationPassesWhenBlockRoundDoesNotMatchProposalRound() { @Test public void validationFailsWhenBlockFailsValidation() { + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); final ConsensusRoundIdentifier roundIdentifier = ConsensusRoundHelpers.createFrom(targetRound, 1, 0); @@ -199,6 +204,8 @@ public void validationFailsWhenMessageMismatchesExpectedHeight() { @Test public void validationFailsForBlockWithIncorrectHeight() { + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + final ProposalPayloadValidator payloadValidator = new ProposalPayloadValidator( expectedProposer, roundIdentifier, blockValidator, protocolContext); diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalValidatorTest.java similarity index 87% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalValidatorTest.java index 43afff35018..c5c2627427d 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ProposalValidatorTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ProposalValidatorTest.java @@ -12,32 +12,33 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftExtraDataEncoder; -import static org.hyperledger.besu.consensus.qbft.validation.ValidationTestHelpers.createEmptyRoundChangePayloads; -import static org.hyperledger.besu.consensus.qbft.validation.ValidationTestHelpers.createPreparePayloads; +import static org.hyperledger.besu.consensus.qbft.core.validation.ValidationTestHelpers.createEmptyRoundChangePayloads; +import static org.hyperledger.besu.consensus.qbft.core.validation.ValidationTestHelpers.createPreparePayloads; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.when; import org.hyperledger.besu.consensus.common.bft.BftContext; +import org.hyperledger.besu.consensus.common.bft.BftExtraData; +import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftHelpers; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Prepare; -import org.hyperledger.besu.consensus.qbft.messagewrappers.Proposal; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Prepare; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.Proposal; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.BlockProcessingResult; import org.hyperledger.besu.ethereum.BlockValidator; @@ -54,6 +55,7 @@ import java.util.Map; import java.util.Optional; +import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -91,10 +93,10 @@ public RoundSpecificItems( @Mock private WorldStateArchive worldStateArchive; @Mock private BftProtocolSchedule protocolSchedule; @Mock private ProtocolSpec protocolSpec; + @Mock private BftExtraDataCodec bftExtraDataCodec; private ProtocolContext protocolContext; private final Map roundItems = new HashMap<>(); - final QbftExtraDataCodec bftExtraDataEncoder = new QbftExtraDataCodec(); @BeforeEach public void setup() { @@ -102,7 +104,7 @@ public void setup() { new ProtocolContext( blockChain, worldStateArchive, - setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataEncoder), + setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataCodec), new BadBlockManager()); // typically tests require the blockValidation to be successful @@ -118,6 +120,7 @@ public void setup() { when(protocolSpec.getBlockValidator()).thenReturn(blockValidator); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); roundItems.put(ROUND_ID.ZERO, createRoundSpecificItems(0)); roundItems.put(ROUND_ID.ONE, createRoundSpecificItems(1)); } @@ -127,7 +130,7 @@ private RoundSpecificItems createRoundSpecificItems(final int roundNumber) { return new RoundSpecificItems( ProposedBlockHelpers.createProposalBlock( - validators.getNodeAddresses(), roundIdentifier, bftExtraDataEncoder), + validators.getNodeAddresses(), roundIdentifier, bftExtraDataCodec), roundIdentifier, new ProposalValidator( protocolContext, @@ -136,7 +139,7 @@ private RoundSpecificItems createRoundSpecificItems(final int roundNumber) { validators.getNodeAddresses(), roundIdentifier, validators.getNode(0).getAddress(), - bftExtraDataEncoder)); + bftExtraDataCodec)); } // NOTE: tests herein assume the ProposalPayloadValidator works as expected, so other than @@ -177,6 +180,10 @@ public void validationFailsIfBlockIsInvalid() { @Test public void validationFailsIfRoundZeroHasNonEmptyPrepares() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final Prepare prepareMsg = validators .getMessageFactory(1) @@ -350,6 +357,10 @@ public void validationFailsIfBlockHashInLatestPreparedMetadataDoesNotMatchPropos roundChanges.add(preparedRoundChange); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final Proposal proposal = validators .getMessageFactory(0) @@ -395,6 +406,10 @@ public void validationFailsIfPreparesAreNonEmptyButNoRoundChangeHasPreparedMetad @Test public void validationFailsIfPiggybackedPreparePayloadIsFromNonValidator() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE); final List> roundChanges = createPreparedRoundZeroRoundChanges(); @@ -418,6 +433,10 @@ public void validationFailsIfPiggybackedPreparePayloadIsFromNonValidator() { @Test public void validationFailsIfPiggybackedPreparePayloadHasDuplicatedAuthors() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE); final List> roundChanges = createPreparedRoundZeroRoundChanges(); @@ -440,6 +459,10 @@ public void validationFailsIfPiggybackedPreparePayloadHasDuplicatedAuthors() { @Test public void validationFailsIfInsufficientPiggybackedPreparePayloads() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE); final List> roundChanges = createPreparedRoundZeroRoundChanges(); @@ -461,6 +484,10 @@ public void validationFailsIfInsufficientPiggybackedPreparePayloads() { @Test public void validationFailsIfPreparePayloadsDoNotMatchMetadataInRoundChanges() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE); final List> roundChanges = createPreparedRoundZeroRoundChanges(); @@ -483,6 +510,10 @@ public void validationFailsIfPreparePayloadsDoNotMatchMetadataInRoundChanges() { @Test public void validationFailsIfPreparePayloadsDoNotMatchBlockHashInRoundChanges() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE); final List> roundChanges = createPreparedRoundZeroRoundChanges(); @@ -505,6 +536,10 @@ public void validationFailsIfPreparePayloadsDoNotMatchBlockHashInRoundChanges() @Test public void validationFailsIfTwoRoundChangesArePreparedOnSameRoundDifferentBlock() { + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.decode(any())) + .thenReturn(new BftExtraData(Bytes.EMPTY, emptyList(), Optional.empty(), 0, emptyList())); + final RoundSpecificItems roundItem = roundItems.get(ROUND_ID.ONE); final List> roundChanges = createPreparedRoundZeroRoundChanges(); diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/QbftNode.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/QbftNode.java similarity index 91% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/QbftNode.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/QbftNode.java index d66952b6960..0d8f6cb00bf 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/QbftNode.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/QbftNode.java @@ -12,9 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; import org.hyperledger.besu.datatypes.Address; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/QbftNodeList.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/QbftNodeList.java similarity index 92% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/QbftNodeList.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/QbftNodeList.java index 2f1ac09af12..c787cbc5acb 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/QbftNodeList.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/QbftNodeList.java @@ -12,9 +12,9 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; -import org.hyperledger.besu.consensus.qbft.payload.MessageFactory; +import org.hyperledger.besu.consensus.qbft.core.payload.MessageFactory; import org.hyperledger.besu.datatypes.Address; import java.util.Collection; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidatorTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangeMessageValidatorTest.java similarity index 89% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidatorTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangeMessageValidatorTest.java index 82e8fb5c7a8..573caa4bad5 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangeMessageValidatorTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangeMessageValidatorTest.java @@ -12,30 +12,30 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static com.google.common.collect.Iterables.toArray; import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.hyperledger.besu.consensus.common.bft.BftContextBuilder.setupContextWithBftExtraDataEncoder; -import static org.hyperledger.besu.consensus.qbft.validation.ValidationTestHelpers.createPreparePayloads; -import static org.hyperledger.besu.consensus.qbft.validation.ValidationTestHelpers.createPreparedCertificate; +import static org.hyperledger.besu.consensus.qbft.core.validation.ValidationTestHelpers.createPreparePayloads; +import static org.hyperledger.besu.consensus.qbft.core.validation.ValidationTestHelpers.createPreparedCertificate; import static org.mockito.Mockito.any; import static org.mockito.Mockito.lenient; import static org.mockito.Mockito.when; import org.hyperledger.besu.consensus.common.bft.BftContext; +import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec; import org.hyperledger.besu.consensus.common.bft.BftHelpers; import org.hyperledger.besu.consensus.common.bft.BftProtocolSchedule; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundHelpers; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.ProposedBlockHelpers; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec; -import org.hyperledger.besu.consensus.qbft.messagewrappers.RoundChange; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.messagewrappers.RoundChange; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.BlockProcessingResult; @@ -51,6 +51,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import org.apache.tuweni.bytes.Bytes; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -66,6 +67,7 @@ public class RoundChangeMessageValidatorTest { @Mock private BftProtocolSchedule protocolSchedule; @Mock private BlockValidator blockValidator; @Mock private ProtocolSpec protocolSpec; + @Mock private BftExtraDataCodec bftExtraDataCodec; private ProtocolContext protocolContext; private RoundChangeMessageValidator messageValidator; @@ -76,7 +78,6 @@ public class RoundChangeMessageValidatorTest { new ConsensusRoundIdentifier(CHAIN_HEIGHT, 3); private final ConsensusRoundIdentifier roundIdentifier = ConsensusRoundHelpers.createFrom(targetRound, 0, -1); - private final QbftExtraDataCodec bftExtraDataEncoder = new QbftExtraDataCodec(); @BeforeEach public void setup() { @@ -84,7 +85,7 @@ public void setup() { new ProtocolContext( blockChain, worldStateArchive, - setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataEncoder), + setupContextWithBftExtraDataEncoder(BftContext.class, emptyList(), bftExtraDataCodec), new BadBlockManager()); lenient().when(protocolSchedule.getByBlockHeader(any())).thenReturn(protocolSpec); @@ -116,6 +117,8 @@ public void roundChangeWithValidPiggyBackDataIsValid() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -127,7 +130,7 @@ public void roundChangeWithValidPiggyBackDataIsValid() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = createPreparedCertificate( block, roundIdentifier, toArray(validators.getNodes(), QbftNode.class)); @@ -142,6 +145,8 @@ public void roundChangeWithBlockRoundMismatchingPreparesIsValid() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -153,7 +158,7 @@ public void roundChangeWithBlockRoundMismatchingPreparesIsValid() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = createPreparedCertificate( block, @@ -212,6 +217,8 @@ public void insufficientPiggyBackedPrepareMessagesIsInvalid() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -223,7 +230,7 @@ public void insufficientPiggyBackedPrepareMessagesIsInvalid() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = createPreparedCertificate( block, roundIdentifier, validators.getNode(0), validators.getNode(1)); @@ -238,6 +245,8 @@ public void prepareFromNonValidatorFails() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -251,7 +260,7 @@ public void prepareFromNonValidatorFails() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = createPreparedCertificate( block, roundIdentifier, validators.getNode(0), validators.getNode(1), nonValidator); @@ -266,6 +275,8 @@ public void validationFailsIfPreparedMetadataContainsDifferentRoundToBlock() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -277,7 +288,7 @@ public void validationFailsIfPreparedMetadataContainsDifferentRoundToBlock() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = new PreparedCertificate( block, @@ -300,6 +311,8 @@ public void validationFailsIfPreparesContainsDifferentRoundToBlock() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -311,7 +324,7 @@ public void validationFailsIfPreparesContainsDifferentRoundToBlock() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = new PreparedCertificate( block, @@ -336,6 +349,8 @@ public void validationFailsIfPreparesContainsWrongHeight() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -347,7 +362,7 @@ public void validationFailsIfPreparesContainsWrongHeight() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = new PreparedCertificate( block, @@ -372,6 +387,8 @@ public void validationFailsIfPreparesHaveDuplicateAuthors() { when(payloadValidator.validate(any())).thenReturn(true); when(blockValidator.validateAndProcessBlock(any(), any(), any(), any())) .thenReturn(new BlockProcessingResult(Optional.empty())); + when(bftExtraDataCodec.encode(any())).thenReturn(Bytes.EMPTY); + when(bftExtraDataCodec.encodeWithoutCommitSeals(any())).thenReturn(Bytes.EMPTY); messageValidator = new RoundChangeMessageValidator( payloadValidator, @@ -383,7 +400,7 @@ public void validationFailsIfPreparesHaveDuplicateAuthors() { final Block block = ProposedBlockHelpers.createProposalBlock( - Collections.emptyList(), roundIdentifier, bftExtraDataEncoder); + Collections.emptyList(), roundIdentifier, bftExtraDataCodec); final PreparedCertificate prepCert = createPreparedCertificate( block, diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidatorTest.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangePayloadValidatorTest.java similarity index 96% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidatorTest.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangePayloadValidatorTest.java index f4a91024b4a..e1f1df801ad 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/RoundChangePayloadValidatorTest.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/RoundChangePayloadValidatorTest.java @@ -12,14 +12,14 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparedRoundMetadata; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparedRoundMetadata; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.cryptoservices.NodeKey; import org.hyperledger.besu.cryptoservices.NodeKeyUtils; diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ValidationTestHelpers.java b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ValidationTestHelpers.java similarity index 88% rename from consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ValidationTestHelpers.java rename to consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ValidationTestHelpers.java index 63a6e4e8e2d..e8b6538e81a 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validation/ValidationTestHelpers.java +++ b/consensus/qbft-core/src/test/java/org/hyperledger/besu/consensus/qbft/core/validation/ValidationTestHelpers.java @@ -12,13 +12,13 @@ * * SPDX-License-Identifier: Apache-2.0 */ -package org.hyperledger.besu.consensus.qbft.validation; +package org.hyperledger.besu.consensus.qbft.core.validation; import org.hyperledger.besu.consensus.common.bft.ConsensusRoundIdentifier; import org.hyperledger.besu.consensus.common.bft.payload.SignedData; -import org.hyperledger.besu.consensus.qbft.payload.PreparePayload; -import org.hyperledger.besu.consensus.qbft.payload.RoundChangePayload; -import org.hyperledger.besu.consensus.qbft.statemachine.PreparedCertificate; +import org.hyperledger.besu.consensus.qbft.core.payload.PreparePayload; +import org.hyperledger.besu.consensus.qbft.core.payload.RoundChangePayload; +import org.hyperledger.besu.consensus.qbft.core.statemachine.PreparedCertificate; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.Block; diff --git a/consensus/qbft/build.gradle b/consensus/qbft/build.gradle index 23e5576ebac..5481d9776e8 100644 --- a/consensus/qbft/build.gradle +++ b/consensus/qbft/build.gradle @@ -31,6 +31,7 @@ jar { dependencies { implementation project(':config') implementation project(':consensus:common') + implementation project(':consensus:qbft-core') implementation project(':crypto:services') implementation project(':datatypes') implementation project(':ethereum:api') @@ -67,20 +68,4 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' testImplementation 'org.mockito:mockito-core' testImplementation 'org.mockito:mockito-junit-jupiter' - - integrationTestImplementation project(':crypto:algorithms') - integrationTestImplementation project(path: ':crypto:services', configuration: 'testSupportArtifacts') - integrationTestImplementation project(path: ':consensus:common', configuration: 'testSupportArtifacts') - integrationTestImplementation project(':evm') - integrationTestImplementation project(':metrics:core') - integrationTestImplementation project(':testutil') - - integrationTestImplementation 'org.assertj:assertj-core' - integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api' - integrationTestImplementation 'org.mockito:mockito-core' - integrationTestImplementation 'org.mockito:mockito-junit-jupiter' - - integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter' - - testSupportImplementation 'org.mockito:mockito-core' } diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/protocol/Istanbul100SubProtocol.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/protocol/Istanbul100SubProtocol.java index 37f04391cbd..70e4a8e5445 100644 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/protocol/Istanbul100SubProtocol.java +++ b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/protocol/Istanbul100SubProtocol.java @@ -14,7 +14,7 @@ */ package org.hyperledger.besu.consensus.qbft.protocol; -import org.hyperledger.besu.consensus.qbft.messagedata.QbftV1; +import org.hyperledger.besu.consensus.qbft.core.messagedata.QbftV1; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.Capability; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.SubProtocol; diff --git a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/CreateBlockForProposalBehaviour.java b/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/CreateBlockForProposalBehaviour.java deleted file mode 100644 index 2a29e8452e3..00000000000 --- a/consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/statemachine/CreateBlockForProposalBehaviour.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright ConsenSys AG. - * - * 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.consensus.qbft.statemachine; - -import org.hyperledger.besu.ethereum.core.Block; - -/** The functional interface Create block for proposal behaviour. */ -@FunctionalInterface -public interface CreateBlockForProposalBehaviour { - - /** - * Create block. - * - * @param headerTimeStampSeconds the header time stamp seconds - * @return the block - */ - Block create(long headerTimeStampSeconds); -} diff --git a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLoggerTest.java b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLoggerTest.java index dabf26749a5..1a531cb344f 100644 --- a/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLoggerTest.java +++ b/consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLoggerTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.consensus.common.ForkSpec; import org.hyperledger.besu.consensus.common.ForksSchedule; import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions; +import org.hyperledger.besu.consensus.qbft.core.validator.ValidatorModeTransitionLogger; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture; diff --git a/settings.gradle b/settings.gradle index 761449b6ca1..2473b7c0502 100644 --- a/settings.gradle +++ b/settings.gradle @@ -36,6 +36,7 @@ include 'consensus:common' include 'consensus:ibft' include 'consensus:merge' include 'consensus:qbft' +include 'consensus:qbft-core' include 'datatypes' include 'crypto:algorithms' include 'crypto:services'