Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🚑 Re-initialise BSPs' challenge cycle when changing stake #292

Merged
merged 28 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a653b18
test: :test_tube: Add tests exposing issue with submit proofs and cha…
ffarall Dec 18, 2024
d835381
fix: :ambulance: Add functionality to re-initialise challenge cycle o…
ffarall Dec 18, 2024
369b3ef
fix: :rotating_light: Add newly added function to mock implementation
ffarall Dec 18, 2024
4b63738
revert: :fire: Remove `reinitialise_challeng_cycle`
ffarall Dec 18, 2024
5286252
Merge branch 'main' into fix/change-stake-while-proving
ffarall Dec 18, 2024
f898da7
fix: :ambulance: Keep record of last tick proven and next to prove, a…
ffarall Dec 20, 2024
69d60b9
test: :white_check_mark: Fix tests from other pallets as a consequenc…
ffarall Dec 20, 2024
4bd7e2d
chore: :label: Update `api-augment`
ffarall Dec 20, 2024
9bf41d5
feat: :sparkles: Use runtime API to get next tick to prove for BSPs
ffarall Dec 20, 2024
57190eb
chore: :label: Update api-augment
ffarall Dec 20, 2024
b8c26cb
Merge branch 'main' into fix/change-stake-while-proving
ffarall Dec 26, 2024
2c23044
fix: :rotating_light: Rename inner field from `provider` to `providerId`
ffarall Dec 26, 2024
72d0ca8
Merge branch 'main' into fix/change-stake-while-proving
ffarall Dec 26, 2024
5e4dea0
fix: :white_check_mark: Replace manual calculation of next challenge …
ffarall Dec 27, 2024
303415c
chore: :zap: Benchmark with new changes
ffarall Dec 27, 2024
7bd6f47
fix: :bug: Use runtime API to get next challenge tick in `proof_submi…
ffarall Dec 27, 2024
3c076a1
chore: :label: Run `typegen`
ffarall Dec 27, 2024
064374f
Merge branch 'main' into fix/change-stake-while-proving
ffarall Dec 27, 2024
c77bf82
chore: :zap: Update weights after merge
ffarall Dec 27, 2024
318a65a
chore: :label: Run `typegen`
ffarall Dec 27, 2024
19b02ae
fix: :white_check_mark: Fix submit proof test now doesn't expect last…
ffarall Dec 28, 2024
3ae82d0
chore: :zap: Update weights
ffarall Dec 28, 2024
40dc0df
chore: :label: Update `api-augment`
ffarall Dec 30, 2024
46c1cec
ci: Increase CI shards for BSP Net tests to 5
ffarall Dec 30, 2024
87ec4b3
Merge branch 'main' into fix/change-stake-while-proving
ffarall Dec 30, 2024
00bf135
docs: :bulb: Update comment clarifying slashing scenario
ffarall Dec 30, 2024
cdb608f
Merge branch 'main' into fix/change-stake-while-proving
ffarall Dec 30, 2024
4113f52
chore: :label: Update `api-augment`
ffarall Dec 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
950 changes: 475 additions & 475 deletions .github/workflows/parachain.yml

Large diffs are not rendered by default.

65 changes: 36 additions & 29 deletions api-augment/dist/interfaces/lookup.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api-augment/dist/interfaces/lookup.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions api-augment/dist/types/interfaces/augment-api-events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2141,9 +2141,9 @@ declare module "@polkadot/api-base/types/events" {
**/
ProofAccepted: AugmentedEvent<
ApiType,
[provider: H256, proof: PalletProofsDealerProof, lastTickProven: u32],
[providerId: H256, proof: PalletProofsDealerProof, lastTickProven: u32],
{
provider: H256;
providerId: H256;
proof: PalletProofsDealerProof;
lastTickProven: u32;
}
Expand Down
39 changes: 22 additions & 17 deletions api-augment/dist/types/interfaces/augment-api-query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import type {
PalletPaymentStreamsDynamicRatePaymentStream,
PalletPaymentStreamsFixedRatePaymentStream,
PalletPaymentStreamsProviderLastChargeableInfo,
PalletProofsDealerProofSubmissionRecord,
PalletStorageProvidersBackupStorageProvider,
PalletStorageProvidersBucket,
PalletStorageProvidersMainStorageProvider,
Expand Down Expand Up @@ -1380,23 +1381,6 @@ declare module "@polkadot/api-base/types/storage" {
**/
lastDeletedTick: AugmentedQuery<ApiType, () => Observable<u32>, []> &
QueryableStorageEntry<ApiType, []>;
/**
* A mapping from a Provider to the last tick for which they SHOULD have submitted a proof.
* If for a Provider `p`, `LastTickProviderSubmittedAProofFor[p]` is `n`, then the
* Provider should submit a proof for tick `n + stake_to_challenge_period(p)`.
*
* This gets updated when a Provider submits a proof successfully and is used to determine the
* next tick for which the Provider should submit a proof, and it's deadline.
*
* If the Provider fails to submit a proof in time and is slashed, this will still get updated
* to the tick it should have submitted a proof for.
**/
lastTickProviderSubmittedAProofFor: AugmentedQuery<
ApiType,
(arg: H256 | string | Uint8Array) => Observable<Option<u32>>,
[H256]
> &
QueryableStorageEntry<ApiType, [H256]>;
/**
* The number of blocks that have been considered _not_ full in the last [`Config::BlockFullnessPeriod`].
*
Expand Down Expand Up @@ -1434,6 +1418,27 @@ declare module "@polkadot/api-base/types/storage" {
[]
> &
QueryableStorageEntry<ApiType, []>;
/**
* A mapping from a Provider to its [`ProofSubmissionRecord`], which stores the last tick
* the Provider submitted a proof for, and the next tick the Provider should submit a proof for.
*
* Normally the difference between these two ticks is equal to the Provider's challenge period,
* but if the Provider's period is changed, this change only affects the next cycle. In other words,
* for one cycle, `next_tick_to_submit_proof_for - last_tick_proven ≠ provider_challenge_period`.
*
* If a Provider submits a proof successfully, both fields are updated.
*
* If the Provider fails to submit a proof in time and is slashed, only `next_tick_to_submit_proof_for`
* is updated.
**/
providerToProofSubmissionRecord: AugmentedQuery<
ApiType,
(
arg: H256 | string | Uint8Array
) => Observable<Option<PalletProofsDealerProofSubmissionRecord>>,
[H256]
> &
QueryableStorageEntry<ApiType, [H256]>;
slashableProviders: AugmentedQuery<
ApiType,
(arg: H256 | string | Uint8Array) => Observable<Option<u32>>,
Expand Down
13 changes: 11 additions & 2 deletions api-augment/dist/types/interfaces/augment-api-runtime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import type {
GetChallengePeriodError,
GetChallengeSeedError,
GetCheckpointChallengesError,
GetLastTickProviderSubmittedProofError,
GetNextDeadlineTickError,
GetProofSubmissionRecordError,
GetUsersWithDebtOverThresholdError,
IsStorageRequestOpenToVolunteersError,
MainStorageProviderId,
Expand Down Expand Up @@ -488,7 +488,7 @@ declare module "@polkadot/api-base/types/calls" {
ApiType,
(
providerId: ProviderId | string | Uint8Array
) => Observable<Result<BlockNumber, GetLastTickProviderSubmittedProofError>>
) => Observable<Result<BlockNumber, GetProofSubmissionRecordError>>
>;
/**
* Get the next deadline tick.
Expand All @@ -499,6 +499,15 @@ declare module "@polkadot/api-base/types/calls" {
providerId: ProviderId | string | Uint8Array
) => Observable<Result<BlockNumber, GetNextDeadlineTickError>>
>;
/**
* Get the next tick for which the submitter should submit a proof.
**/
getNextTickToSubmitProofFor: AugmentedCall<
ApiType,
(
providerId: ProviderId | string | Uint8Array
) => Observable<Result<BlockNumber, GetProofSubmissionRecordError>>
>;
/**
* Generic call
**/
Expand Down
16 changes: 10 additions & 6 deletions api-augment/dist/types/interfaces/augment-api-tx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3327,19 +3327,23 @@ declare module "@polkadot/api-base/types/submittable" {
* is provided, the proof submitter is considered to be the Provider.
* Relies on a Providers pallet to get the root for the Provider.
* Validates that the proof corresponds to a challenge that was made in the past,
* by checking the `TickToChallengesSeed` StorageMap. The challenge tick that the
* Provider should have submitted a proof is calculated based on the last tick they
* submitted a proof for ([`LastTickProviderSubmittedAProofFor`]), and the proving period for
* that Provider, which is a function of their stake.
* by checking the [`TickToChallengesSeed`] StorageMap. The challenge tick that the
* Provider should be submitting a proof for is retrieved from [`ProviderToProofSubmissionRecord`],
* and it was calculated based on the last tick they submitted a proof for, and the challenge
* period for that Provider, at the time of the previous proof submission or when it was
* marked as slashable.
*
* This extrinsic also checks that there hasn't been a checkpoint challenge round
* in between the last time the Provider submitted a proof for and the tick
* for which the proof is being submitted. If there has been, the Provider is
* subject to slashing.
* expected to include responses to the checkpoint challenges in the proof.
*
* If valid:
* - Pushes forward the Provider in the [`TickToProvidersDeadlines`] StorageMap a number
* of ticks corresponding to the stake of the Provider.
* - Registers this tick as the last tick in which the Provider submitted a proof.
* - Registers the last tick for which the Provider submitted a proof for in
* [`ProviderToProofSubmissionRecord`], as well as the next tick for which the Provider
* should submit a proof for.
*
* Execution of this extrinsic should be refunded if the proof is valid.
**/
Expand Down
4 changes: 2 additions & 2 deletions api-augment/dist/types/interfaces/augment-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1265,8 +1265,8 @@ import type {
GetChallengeSeedError,
GetCheckpointChallengesError,
GetFileFromFileStorageResult,
GetLastTickProviderSubmittedProofError,
GetNextDeadlineTickError,
GetProofSubmissionRecordError,
GetUsersWithDebtOverThresholdError,
IncompleteFileStatus,
IsStorageRequestOpenToVolunteersError,
Expand Down Expand Up @@ -1763,8 +1763,8 @@ declare module "@polkadot/types/types/registry" {
GetChallengeSeedError: GetChallengeSeedError;
GetCheckpointChallengesError: GetCheckpointChallengesError;
GetFileFromFileStorageResult: GetFileFromFileStorageResult;
GetLastTickProviderSubmittedProofError: GetLastTickProviderSubmittedProofError;
GetNextDeadlineTickError: GetNextDeadlineTickError;
GetProofSubmissionRecordError: GetProofSubmissionRecordError;
GetUsersWithDebtOverThresholdError: GetUsersWithDebtOverThresholdError;
GiltBid: GiltBid;
GlobalValidationData: GlobalValidationData;
Expand Down
Loading
Loading