-
Notifications
You must be signed in to change notification settings - Fork 105
Enable non zero round BFT bootstrap #6392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adetokunbo
wants to merge
10
commits into
adetokunbo/cip-104-switch-make-traffic-based-app-rewards-the-test-default
Choose a base branch
from
adetokunbo/cip-104-enable-non-zero-round-bootstrap
base: adetokunbo/cip-104-switch-make-traffic-based-app-rewards-the-test-default
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
207d71b
[ci] Simplify now that minimumInitialization packages are present
adetokunbo 2657056
[ci] Allow a warning in UnhideAndExpireRewardCouponV2TimeBasedIntegra…
adetokunbo c1dbf5e
Initial attempt at adding the new integration test
adetokunbo 3460589
Add BFT integration test for non-zero round bootstrap reward totals
adetokunbo 288d94d
Use randomSingleCall for BFT reads of the initial round's reward values
adetokunbo 013364b
[ci] Assert dummy SV raises BFT quorum in bootstrap test
adetokunbo fc1254b
[ci] Reorder BFT bootstrap test to run initial round under f=1 quorum
adetokunbo ff2e89f
[ci] Properly name the test as a SimTime test
adetokunbo 6921aa8
[ci] Add ignore pattern for dummy SV scan warnings
adetokunbo d88545f
[ci] Use the updated version of UnhideAndExpireRewardCouponV2TimeBase…
adetokunbo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
278 changes: 278 additions & 0 deletions
278
...izedtrust/splice/integration/tests/NonZeroRoundBootstrapBftTimeBasedIntegrationTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,278 @@ | ||
| package org.lfdecentralizedtrust.splice.integration.tests | ||
|
|
||
| import com.digitalasset.canton.HasExecutionContext | ||
| import com.digitalasset.canton.concurrent.Threading | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.cometbft.{ | ||
| CometBftConfig, | ||
| CometBftNodeConfig, | ||
| GovernanceKeyConfig, | ||
| SequencingKeyConfig, | ||
| } | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.dso.decentralizedsynchronizer.{ | ||
| ScanConfig, | ||
| SynchronizerNodeConfig, | ||
| } | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.dsorules.DsoRules_AddSv | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.dsorules.actionrequiringconfirmation.ARC_DsoRules | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.dsorules.dsorules_actionrequiringconfirmation.SRARC_AddSv | ||
| import org.lfdecentralizedtrust.splice.codegen.java.splice.types.Round | ||
| import org.lfdecentralizedtrust.splice.config.ConfigTransforms | ||
| import org.lfdecentralizedtrust.splice.http.v0.definitions | ||
| import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition | ||
| import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.{ | ||
| IntegrationTestWithIsolatedEnvironment, | ||
| SpliceTestConsoleEnvironment, | ||
| } | ||
| import org.lfdecentralizedtrust.splice.automation.Trigger | ||
| import org.lfdecentralizedtrust.splice.sv.automation.singlesv.onboarding.SvOnboardingUnlimitedTrafficTrigger | ||
| import org.lfdecentralizedtrust.splice.util.{TimeTestUtil, WalletTestUtil} | ||
|
|
||
| import java.util.Optional | ||
| import scala.jdk.CollectionConverters.* | ||
|
|
||
| /** Tests that SV automation triggers can complete the reward | ||
| * pipeline for the initial round when bootstrapping TBAR at a | ||
| * non-zero round with BFT f >= 1. | ||
| * | ||
| * Adds a dummy 5th SV to increase the BFT quorum from 1 to 2. | ||
| */ | ||
| class NonZeroRoundBootstrapBftTimeBasedIntegrationTest | ||
| extends IntegrationTestWithIsolatedEnvironment | ||
| with HasExecutionContext | ||
| with WalletTestUtil | ||
| with TimeTestUtil { | ||
|
|
||
| private val initialRound = 4815L | ||
|
|
||
| override def environmentDefinition: SpliceEnvironmentDefinition = | ||
| EnvironmentDefinition | ||
| .simpleTopology4SvsWithSimTime(this.getClass.getSimpleName) | ||
| .withoutAutomaticRewardsCollectionAndAmuletMerging | ||
| .addConfigTransforms((_, config) => | ||
| ConfigTransforms.updateAllSvAppFoundDsoConfigs_( | ||
| _.copy(initialRound = initialRound) | ||
| )(config) | ||
| ) | ||
| .addConfigTransform((_, config) => ConfigTransforms.withNoVoteCooldown(config)) | ||
|
|
||
| "SV triggers complete the reward pipeline for the initial round" in { implicit env => | ||
| import definitions.GetRewardAccountingActivityTotalsResponse.members.RewardAccountingActivityTotalsOk | ||
| import definitions.GetRewardAccountingActivityTotalsResponse.members.RewardAccountingActivityTotalsCannotProvide | ||
|
|
||
| // Add a dummy 5th SV with a fake scan URL BEFORE any round | ||
| // advancement. This raises BFT f from 0 to 1, so the initial | ||
| // round's reward pipeline runs under the higher quorum. | ||
| addDummySvWithFakeScanUrl() | ||
|
|
||
| // The dummy SV's participant doesn't exist on the sequencer, so | ||
| // this trigger would poll indefinitely logging "does not yet have | ||
| // a traffic state". Pause it to avoid log noise on CI. | ||
| env.svs.local.foreach( | ||
| _.dsoAutomation.trigger[SvOnboardingUnlimitedTrafficTrigger].pause().futureValue | ||
| ) | ||
|
|
||
| // With f=1, BFT reads need 2 agreeing Ok responses — but only | ||
| // SV1's scan has the initial round's data. The randomSingleCall | ||
| // override for the initial round lets each SV read from a single | ||
| // peer, so the pipeline completes despite the higher quorum. | ||
| advanceTimeForRewardAutomationToRunForCurrentRound | ||
| actAndCheck( | ||
| "Advance to next round opening", | ||
| advanceRoundsToNextRoundOpening, | ||
| )( | ||
| "SV1's scan has reward totals and the initial round is issuing", | ||
| _ => { | ||
| sv1ScanBackend | ||
| .getRewardAccountingActivityTotals(initialRound) shouldBe a[ | ||
| RewardAccountingActivityTotalsOk | ||
| ] | ||
|
|
||
| // The round becoming IssuingMiningRound is DSO-level proof: | ||
| // under BFT f=1, the SummarizingMiningRoundTrigger on each | ||
| // SV must obtain reward accounting totals. For the initial | ||
| // round, only SV1 has local data; other SVs fall back to | ||
| // BFT read (randomSingleCall). If that path failed, fewer | ||
| // than f+1=2 SVs could submit summaries and the round would | ||
| // not advance. | ||
| val (_, issuingRounds) = sv1ScanBackend.getOpenAndIssuingMiningRounds() | ||
| issuingRounds.exists( | ||
| _.payload.round.number == initialRound | ||
| ) shouldBe true | ||
|
|
||
| // SV2's scan does NOT have local reward activity data for | ||
| // the initial round — only SV1's scan seeded it. SV2's SV | ||
| // trigger obtained the totals via BFT (randomSingleCall), | ||
| // but the scan HTTP endpoint queries the local store, so it | ||
| // returns CannotProvide. | ||
| sv2ScanBackend | ||
| .getRewardAccountingActivityTotals(initialRound) shouldBe a[ | ||
| RewardAccountingActivityTotalsCannotProvide | ||
| ] | ||
| }, | ||
| ) | ||
|
|
||
| // Advance two ticks so that verdict ingestion processes batches | ||
| // that see OpenMiningRound(initialRound+1) already archived. | ||
| // A single tick archives the round, but the verdict batch for | ||
| // that tick may be processed before the rewards reference store | ||
| // has indexed the archival — so lookupLatestArchivedOpenMiningRound | ||
| // returns None and last_archived_round stays at initialRound. | ||
| // The second tick generates new verdicts that find the archival | ||
| // already indexed, bumping last_archived_round. | ||
| advanceTimeAndWaitForRoundOpening | ||
| advanceTimeAndWaitForRoundOpening | ||
|
|
||
| // Wait for RewardComputationTrigger to compute totals for the | ||
| // next round now that last_archived_round covers it. | ||
| eventually() { | ||
| sv1ScanBackend | ||
| .getRewardAccountingActivityTotals(initialRound + 1) shouldBe a[ | ||
| RewardAccountingActivityTotalsOk | ||
| ] | ||
| } | ||
|
|
||
| // Advance another round to confirm the pipeline continues past | ||
| // the initial round under normal BFT (f+1=2) without | ||
| // randomSingleCall. | ||
| actAndCheck( | ||
| "Advance past the initial round", | ||
| advanceRoundsToNextRoundOpening, | ||
| )( | ||
| "SV2's scan has local reward totals for the next round", | ||
| _ => | ||
| sv2ScanBackend | ||
| .getRewardAccountingActivityTotals(initialRound + 1) shouldBe a[ | ||
| RewardAccountingActivityTotalsOk | ||
| ], | ||
| ) | ||
| } | ||
|
|
||
| private def addDummySvWithFakeScanUrl()(implicit | ||
| env: SpliceTestConsoleEnvironment | ||
| ): com.digitalasset.canton.topology.PartyId = { | ||
| val dsoInfo = sv1Backend.getDsoInfo() | ||
| val svParty = dsoInfo.svParty | ||
| val dsoParty = dsoInfo.dsoParty | ||
|
|
||
| // Random suffix avoids collisions with stale parties from | ||
| // previous runs (databases persist between local test runs). | ||
| val dummySvParty = sv1Backend.participantClientWithAdminToken.ledger_api.parties | ||
| .allocate(s"dummy-sv5-${scala.util.Random.nextInt().toHexString}") | ||
| .party | ||
|
|
||
| val addSvAction = new ARC_DsoRules( | ||
| new SRARC_AddSv( | ||
| new DsoRules_AddSv( | ||
| dummySvParty.toProtoPrimitive, | ||
| "Dummy-SV5", | ||
| 1000L, | ||
| "PAR::dummy-sv5::dummy", | ||
| new Round(initialRound), | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| val (_, voteRequest) = actAndCheck( | ||
| "sv1 creates vote request to add dummy SV5", | ||
| eventuallySucceeds() { | ||
| sv1Backend.createVoteRequest( | ||
| svParty.toProtoPrimitive, | ||
| addSvAction, | ||
| "url", | ||
| "Add dummy SV5 for BFT threshold test", | ||
| sv1Backend.getDsoInfo().dsoRules.payload.config.voteRequestTimeout, | ||
| None, | ||
| ) | ||
| }, | ||
| )( | ||
| "vote request exists", | ||
| _ => sv1Backend.listVoteRequests().loneElement, | ||
| ) | ||
|
|
||
| actAndCheck( | ||
| "sv2 and sv3 vote yes (3 votes total → executes)", { | ||
| Seq(sv2Backend, sv3Backend).foreach { sv => | ||
| eventuallySucceeds() { | ||
| sv.castVote(voteRequest.contractId, true, "url", "description") | ||
| } | ||
| } | ||
| }, | ||
| )( | ||
| "dummy SV5 is in DsoRules and raises BFT f from 0 to 1", | ||
| _ => { | ||
| val info = sv1Backend.getDsoInfo() | ||
| info.dsoRules.payload.svs.size() shouldBe 5 | ||
| }, | ||
| ) | ||
|
|
||
| // Pause ALL delegate-based triggers to prevent DsoRules contract | ||
| // churn during the SetSynchronizerNodeConfig submission. | ||
| // Sleep briefly after pausing to let in-flight commands complete. | ||
| env.svs.local.foreach( | ||
| _.dsoDelegateBasedAutomation.triggers[Trigger].foreach(_.pause().futureValue) | ||
| ) | ||
| Threading.sleep(2000) | ||
| actAndCheck( | ||
| "Set fake scan URL on dummy SV", | ||
| setDummySvScanUrl(dsoParty, dummySvParty), | ||
| )( | ||
| "Dummy SV's scan URL is in the BFT peer list", | ||
| _ => { | ||
| val nodeState = sv1Backend.getDsoInfo().svNodeStates(dummySvParty) | ||
| nodeState.payload.state.synchronizerNodes.values.asScala | ||
| .exists(_.scan.isPresent) shouldBe true | ||
| }, | ||
| ) | ||
| env.svs.local.foreach( | ||
| _.dsoDelegateBasedAutomation.triggers[Trigger].foreach(_.resume()) | ||
| ) | ||
|
|
||
| dummySvParty | ||
| } | ||
|
|
||
| private def setDummySvScanUrl( | ||
| dsoParty: com.digitalasset.canton.topology.PartyId, | ||
| dummySvParty: com.digitalasset.canton.topology.PartyId, | ||
| )(implicit env: SpliceTestConsoleEnvironment): Unit = { | ||
| val synchronizerId = decentralizedSynchronizerId.toProtoPrimitive | ||
|
|
||
| val nodeConfig = new SynchronizerNodeConfig( | ||
| new CometBftConfig( | ||
| Map.empty[String, CometBftNodeConfig].asJava, | ||
| Seq.empty[GovernanceKeyConfig].asJava, | ||
| Seq.empty[SequencingKeyConfig].asJava, | ||
| ), | ||
| Optional.empty(), // sequencer | ||
| Optional.empty(), // mediator | ||
| // Unreachable URL — BFT marks it as a failed peer, increasing | ||
| // totalNumber (and thus f) without needing a running scan. | ||
| Optional.of(new ScanConfig("http://localhost:1")), | ||
| Optional.empty(), // legacySequencerConfig | ||
| Optional.empty(), // sequencerIdentity | ||
| Optional.empty(), // physicalSynchronizers | ||
| ) | ||
|
|
||
| eventuallySucceeds() { | ||
| val info = sv1Backend.getDsoInfo() | ||
| val currentDsoRulesCid = info.dsoRules.contractId | ||
| val currentNodeStateCid = info.svNodeStates | ||
| .getOrElse(dummySvParty, fail("SvNodeState not found for dummy SV")) | ||
| .contractId | ||
| sv1Backend.participantClientWithAdminToken.ledger_api_extensions.commands | ||
| .submitJava( | ||
| actAs = Seq(dummySvParty), | ||
| readAs = Seq(dsoParty), | ||
| commands = currentDsoRulesCid | ||
| .exerciseDsoRules_SetSynchronizerNodeConfig( | ||
| dummySvParty.toProtoPrimitive, | ||
| synchronizerId, | ||
| nodeConfig, | ||
| currentNodeStateCid, | ||
| ) | ||
| .commands() | ||
| .asScala | ||
| .toSeq, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.