From 30067b1ee8239fe9274802aab711b716e46b19f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 9 Jan 2025 13:02:48 +0100 Subject: [PATCH 01/16] Update base submodule --- deps/concordium-base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/concordium-base b/deps/concordium-base index 8c925efc..92150abc 160000 --- a/deps/concordium-base +++ b/deps/concordium-base @@ -1 +1 @@ -Subproject commit 8c925efc17405cc2927f20df46ed5b57275840c2 +Subproject commit 92150abc924a39580aa8e5bee1aaee52a5ef4739 From a05ddc7a3df2354409541373a7e473ea4f4bb340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 9 Jan 2025 14:26:34 +0100 Subject: [PATCH 02/16] Update sdk models with p8 changes --- packages/sdk/src/types.ts | 26 +++++++++++++-- packages/sdk/src/types/BlockSpecialEvents.ts | 33 +++++++++++++++++++- packages/sdk/src/types/chainUpdate.ts | 8 ++++- packages/sdk/src/types/transactionEvent.ts | 16 +++++++++- 4 files changed, 78 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 35da39b1..5b188cda 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -453,7 +453,7 @@ export type ChainParametersV1 = ChainParametersCommon & level2Keys: AuthorizationsV1; }; -/** Chain parameters used from protocol version 6 */ +/** Chain parameters used in protocol version 6 and 7 */ export type ChainParametersV2 = ChainParametersCommon & CooldownParametersV1 & TimeParametersV1 & @@ -468,8 +468,24 @@ export type ChainParametersV2 = ChainParametersCommon & level2Keys: AuthorizationsV1; }; +/** + * Validator score parameters. These parameters control the threshold of + * maximal missed rounds before a validator gets suspended. + */ +export interface ValidatorScoreParameters { + /** Maximal number of missed rounds before a validator gets suspended. */ + maxMissedRounds: bigint; +} + +/** Chain parameters used from protocol version 8 */ +export type ChainParametersV3 = ChainParametersV2 & { + version: 3; + /** The current validator score parameters */ + validatorScoreParameters: ValidatorScoreParameters; +}; + /** Union of all chain parameters across all protocol versions */ -export type ChainParameters = ChainParametersV0 | ChainParametersV1 | ChainParametersV2; +export type ChainParameters = ChainParametersV0 | ChainParametersV1 | ChainParametersV2 | ChainParametersV3; export interface Authorization { threshold: number; @@ -1029,6 +1045,12 @@ interface AccountBakerDetailsCommon { bakerSignatureVerifyKey: string; stakedAmount: CcdAmount.Type; pendingChange?: StakePendingChange; + /** + * A flag indicating whether the validator is currently suspended or not. + * In protocol versions prior to protocol version 8, this will always be `false`. + * A suspended validator will not be included in the validator committee the next time it is calculated. + */ + isSuspended: boolean; } /** Protocol version 1-3. */ diff --git a/packages/sdk/src/types/BlockSpecialEvents.ts b/packages/sdk/src/types/BlockSpecialEvents.ts index 9e22bd91..0f2a53f7 100644 --- a/packages/sdk/src/types/BlockSpecialEvents.ts +++ b/packages/sdk/src/types/BlockSpecialEvents.ts @@ -2,6 +2,9 @@ import type { BakerId } from '../types.js'; import * as AccountAddress from './AccountAddress.js'; import * as CcdAmount from './CcdAmount.js'; +/** + * A union of all the different "special events" that can be part of a block. + */ export type BlockSpecialEvent = | BlockSpecialEventBakingRewards | BlockSpecialEventMint @@ -10,7 +13,9 @@ export type BlockSpecialEvent = | BlockSpecialEventPaydayFoundationReward | BlockSpecialEventPaydayAccountReward | BlockSpecialEventBlockAccrueReward - | BlockSpecialEventPaydayPoolReward; + | BlockSpecialEventPaydayPoolReward + | BlockSpecialEventValidatorSuspended + | BlockSpecialEventValidatorPrimedForSuspension; export interface BlockSpecialEventBakingRewards { tag: 'bakingRewards'; @@ -115,6 +120,29 @@ export interface BlockSpecialEventAccountAmount { amount: CcdAmount.Type; } +/** + * A validator was suspended due to too many missed rounds. + */ +export interface BlockSpecialEventValidatorSuspended { + tag: 'validatorSuspended'; + /** The validator that was suspended. */ + bakerId: BakerId; + /** The account address of the validator. */ + account: AccountAddress.Type; +} + +/** + * A validator was primed to be suspended at the next snapshot epoch due to + * too many missed rounds. + */ +export interface BlockSpecialEventValidatorPrimedForSuspension { + tag: 'validatorPrimedForSuspension'; + /** The validator that was primed for suspension. */ + bakerId: BakerId; + /** The account address of the validator. */ + account: AccountAddress.Type; +} + /** * Gets a list of {@link AccountAddress.Type} account addresses affected the {@link BlockSpecialEvent}. * @@ -146,6 +174,9 @@ export function specialEventAffectedAccounts(event: BlockSpecialEvent): AccountA } return [event.baker, event.foundationAccount]; } + case 'validatorSuspended': + case 'validatorPrimedForSuspension': + return [event.account] default: return []; } diff --git a/packages/sdk/src/types/chainUpdate.ts b/packages/sdk/src/types/chainUpdate.ts index 87b9b6b3..99f8b24d 100644 --- a/packages/sdk/src/types/chainUpdate.ts +++ b/packages/sdk/src/types/chainUpdate.ts @@ -14,6 +14,7 @@ import type { MintRate, TimeoutParameters, TransactionFeeDistribution, + ValidatorScoreParameters, VerifyKey, } from '../types.js'; import type * as CcdAmount from './CcdAmount.js'; @@ -103,6 +104,9 @@ export type PendingHigherLevelKeyUpdate = ChainUpdate; +/** A pending update to validator score parameters */ +export type PendingValidatorScoreUpdate = ChainUpdate; + /** A union of chain updates, barring key updates */ export type CommonUpdate = | MicroGtuPerEuroUpdate @@ -123,7 +127,8 @@ export type CommonUpdate = | TimeoutParametersUpdate | MinBlockTimeUpdate | BlockEnergyLimitUpdate - | FinalizationCommitteeParametersUpdate; + | FinalizationCommitteeParametersUpdate + | PendingValidatorScoreUpdate; /** A union of chain updates */ export type UpdateInstructionPayload = CommonUpdate | RootUpdate | Level1Update; @@ -166,6 +171,7 @@ export enum UpdateType { MinBlockTime = 'minBlockTime', BlockEnergyLimit = 'blockEnergyLimit', FinalizationCommitteeParameters = 'finalizationCommitteeParameters', + ValidatorScoreParameters = 'validatorScoreParameters', } export type KeyUpdate = HigherLevelKeyUpdate | AuthorizationKeysUpdate; diff --git a/packages/sdk/src/types/transactionEvent.ts b/packages/sdk/src/types/transactionEvent.ts index a49e559e..b2abfbca 100644 --- a/packages/sdk/src/types/transactionEvent.ts +++ b/packages/sdk/src/types/transactionEvent.ts @@ -44,6 +44,8 @@ export enum TransactionEventTag { BakerSetBakingRewardCommission = 'BakerSetBakingRewardCommission', BakerSetFinalizationRewardCommission = 'BakerSetFinalizationRewardCommission', BakerDelegationRemoved = 'BakerDelegationRemoved', + BakerSuspended = 'BakerSuspended', + BakerResumed = 'BakerResumed', DelegationStakeIncreased = 'DelegationStakeIncreased', DelegationStakeDecreased = 'DelegationStakeDecreased', DelegationSetRestakeEarnings = 'DelegationSetRestakeEarnings', @@ -336,6 +338,16 @@ export interface BakerDelegationRemovedEvent { delegatorId: DelegatorId; } +export interface BakerSuspendedEvent { + tag: TransactionEventTag.BakerSuspended; + bakerId: BakerId; +} + +export interface BakerResumedEvent { + tag: TransactionEventTag.BakerResumed; + bakerId: BakerId; +} + export interface UpdateEnqueuedEvent { tag: TransactionEventTag.UpdateEnqueued; effectiveTime: number; @@ -354,7 +366,9 @@ export type BakerEvent = | BakerAddedEvent | BakerRemovedEvent | BakerKeysUpdatedEvent - | BakerDelegationRemovedEvent; + | BakerDelegationRemovedEvent + | BakerSuspendedEvent + | BakerResumedEvent; export type DelegationEvent = | DelegatorEvent | DelegationSetDelegationTargetEvent From 269f50fac83acdb48a5997b3979dae78cb1e1f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 9 Jan 2025 15:01:07 +0100 Subject: [PATCH 03/16] Translate GRPC values --- packages/sdk/src/grpc/translation.ts | 52 +++++++++++++++++++++++++--- packages/sdk/src/types.ts | 2 +- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index 1ef27c16..bd836baa 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -215,6 +215,7 @@ function trOpenStatus(openStatus: v2.OpenStatus | undefined): v1.OpenStatusText function trBaker(baker: v2.AccountStakingInfo_Baker): v1.AccountBakerDetails { const bakerInfo = baker.bakerInfo; + const isSuspended = baker.isSuspended; const v0: v1.AccountBakerDetails = { version: 0, @@ -228,6 +229,7 @@ function trBaker(baker: v2.AccountStakingInfo_Baker): v1.AccountBakerDetails { ...(baker.pendingChange && { pendingChange: trPendingChange(baker.pendingChange), }), + isSuspended, }; if (baker.poolInfo === undefined) { @@ -499,7 +501,7 @@ function trChainParametersV1(params: v2.ChainParametersV1): v1.ChainParametersV1 }; } -function trChainParametersV2(params: v2.ChainParametersV2): v1.ChainParametersV2 { +function trChainParametersV2(params: v2.ChainParametersV2 | v2.ChainParametersV3): v1.ChainParametersV2 { const common = translateChainParametersCommon(params); const commonRewardParameters = translateRewardParametersCommon(params); @@ -550,6 +552,17 @@ function trChainParametersV2(params: v2.ChainParametersV2): v1.ChainParametersV2 export function blockChainParameters(params: v2.ChainParameters): v1.ChainParameters { switch (params.parameters.oneofKind) { + case 'v3': { + const { version, ...common } = trChainParametersV2(params.parameters.v3); + const cp: v1.ChainParametersV3 = { + ...common, + version: 3, + validatorScoreParameters: { + maxMissedRounds: unwrap(params.parameters.v3.validatorScoreParameters?.maximumMissedRounds), + }, + }; + return cp; + } case 'v2': { return trChainParametersV2(params.parameters.v2); } @@ -559,7 +572,7 @@ export function blockChainParameters(params: v2.ChainParameters): v1.ChainParame case 'v0': { return trChainParametersV0(params.parameters.v0); } - default: + case undefined: throw new Error('Missing chain parameters'); } } @@ -876,6 +889,18 @@ function trBakerEvent(bakerEvent: v2.BakerEvent, account: AccountAddress.Type): delegatorId: unwrap(event.delegationRemoved.delegatorId?.id?.value), }; } + case 'bakerSuspended': { + return { + tag: v1.TransactionEventTag.BakerSuspended, + bakerId: unwrap(event.bakerSuspended.bakerId?.value), + }; + } + case 'bakerResumed': { + return { + tag: v1.TransactionEventTag.BakerResumed, + bakerId: unwrap(event.bakerResumed.bakerId?.value), + }; + } case undefined: throw Error('Unrecognized event type. This should be impossible.'); } @@ -1436,10 +1461,15 @@ export function trPendingUpdateEffect(pendingUpdate: v2.PendingUpdate): v1.Pendi updatePayload: trAuthorizationsV1(effect.level2KeysCpv1), }, }; + case 'validatorScoreParameters': + return { + updateType: v1.UpdateType.ValidatorScoreParameters, + update: { + maxMissedRounds: effect.validatorScoreParameters.maximumMissedRounds + } + } case undefined: throw Error('Unexpected missing pending update'); - default: - throw Error(`Unsupported update: ${effect}`); } } @@ -2408,6 +2438,20 @@ export function blockSpecialEvent(specialEvent: v2.BlockSpecialEvent): v1.BlockS ...(poolOwner !== undefined && { poolOwner }), }; } + case 'validatorSuspended': { + return { + tag: 'validatorSuspended', + account: AccountAddress.fromProto(unwrap(event.validatorSuspended.account)), + bakerId: unwrap(event.validatorSuspended.bakerId?.value), + }; + } + case 'validatorPrimedForSuspension': { + return { + tag: 'validatorPrimedForSuspension', + account: AccountAddress.fromProto(unwrap(event.validatorPrimedForSuspension.account)), + bakerId: unwrap(event.validatorPrimedForSuspension.bakerId?.value), + }; + } case undefined: { throw Error('Error translating BlockSpecialEvent: unexpected undefined'); } diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 5b188cda..918c5b9e 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -478,7 +478,7 @@ export interface ValidatorScoreParameters { } /** Chain parameters used from protocol version 8 */ -export type ChainParametersV3 = ChainParametersV2 & { +export type ChainParametersV3 = Omit & { version: 3; /** The current validator score parameters */ validatorScoreParameters: ValidatorScoreParameters; From 3221a0e42047b69994d85f278fc3ee1dc2119d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Fri, 10 Jan 2025 08:56:46 +0100 Subject: [PATCH 04/16] Update changelog --- packages/sdk/CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 621c3778..a9ad2d5f 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## Unreleased + +### Breaking changes + +- Protocol version 8: + - Add `isSuspended` field to `AccountBakerDetails`. + - Add `BakerSuspendedEvent` and `BakerResumedEvent` to `BakerEvent` union type. + - Add `BlockSpecialEventValidatorSuspended` and `BakerSuspendedEvent` to `BlockSpecialEvent` union type. + - Add `PendingValidatorScoreUpdate` to `UpdateInstructionPayload` union type. + - Add `ChainParametersV3` to `ChainParameters` union type. + ## 8.1.0 ### Added From 8adbf507ef022c50e729dce4349c7d0c486cd7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Fri, 10 Jan 2025 09:59:03 +0100 Subject: [PATCH 05/16] fmt --- packages/sdk/src/grpc/translation.ts | 6 +++--- packages/sdk/src/types/BlockSpecialEvents.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index bd836baa..61c57e65 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -1465,9 +1465,9 @@ export function trPendingUpdateEffect(pendingUpdate: v2.PendingUpdate): v1.Pendi return { updateType: v1.UpdateType.ValidatorScoreParameters, update: { - maxMissedRounds: effect.validatorScoreParameters.maximumMissedRounds - } - } + maxMissedRounds: effect.validatorScoreParameters.maximumMissedRounds, + }, + }; case undefined: throw Error('Unexpected missing pending update'); } diff --git a/packages/sdk/src/types/BlockSpecialEvents.ts b/packages/sdk/src/types/BlockSpecialEvents.ts index 0f2a53f7..ef082ede 100644 --- a/packages/sdk/src/types/BlockSpecialEvents.ts +++ b/packages/sdk/src/types/BlockSpecialEvents.ts @@ -176,7 +176,7 @@ export function specialEventAffectedAccounts(event: BlockSpecialEvent): AccountA } case 'validatorSuspended': case 'validatorPrimedForSuspension': - return [event.account] + return [event.account]; default: return []; } From 27c674353c60d0a33087b0d14c7a1a1fc3f0645f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Fri, 10 Jan 2025 10:35:10 +0100 Subject: [PATCH 06/16] Fix build errors --- packages/sdk/test/client/resources/expectedJsons.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/sdk/test/client/resources/expectedJsons.ts b/packages/sdk/test/client/resources/expectedJsons.ts index 132d0cba..2c0fb06d 100644 --- a/packages/sdk/test/client/resources/expectedJsons.ts +++ b/packages/sdk/test/client/resources/expectedJsons.ts @@ -1405,6 +1405,7 @@ export const bakerAccountInfo: AccountInfoBaker = { bakerSignatureVerifyKey: 'c385ccb5c8a0710a162f2c107123744650ff35f00040bfa262d974bfb3c3f8f1', restakeEarnings: true, stakedAmount: CcdAmount.fromMicroCcd(7349646704751788n), + isSuspended: false, }, accountCooldowns: [], accountAvailableBalance: CcdAmount.fromMicroCcd(100000000000000n), From 4716c1fdcdc805b76ed9e8143cee9b6470fcf718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Mon, 13 Jan 2025 07:04:09 +0100 Subject: [PATCH 07/16] Update packages/sdk/CHANGELOG.md Co-authored-by: Thomas Dinsdale-Young --- packages/sdk/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index a9ad2d5f..178358a9 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -7,7 +7,7 @@ - Protocol version 8: - Add `isSuspended` field to `AccountBakerDetails`. - Add `BakerSuspendedEvent` and `BakerResumedEvent` to `BakerEvent` union type. - - Add `BlockSpecialEventValidatorSuspended` and `BakerSuspendedEvent` to `BlockSpecialEvent` union type. + - Add `BlockSpecialEventValidatorSuspended` and `BlockSpecialEventValidatorPrimedForSuspension` to `BlockSpecialEvent` union type. - Add `PendingValidatorScoreUpdate` to `UpdateInstructionPayload` union type. - Add `ChainParametersV3` to `ChainParameters` union type. From 642260ceaba1a226b7fb5a789b189a706728e96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Mon, 13 Jan 2025 08:33:15 +0100 Subject: [PATCH 08/16] Factor chain parameters type translation into its own function --- packages/sdk/src/grpc/translation.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index 61c57e65..fbcf269e 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -550,18 +550,21 @@ function trChainParametersV2(params: v2.ChainParametersV2 | v2.ChainParametersV3 }; } +function trChainParametersV3(params: v2.ChainParametersV3): v1.ChainParametersV3 { + const { version, ...common } = trChainParametersV2(params); + return { + ...common, + version: 3, + validatorScoreParameters: { + maxMissedRounds: unwrap(params.validatorScoreParameters?.maximumMissedRounds), + }, + }; +} + export function blockChainParameters(params: v2.ChainParameters): v1.ChainParameters { switch (params.parameters.oneofKind) { case 'v3': { - const { version, ...common } = trChainParametersV2(params.parameters.v3); - const cp: v1.ChainParametersV3 = { - ...common, - version: 3, - validatorScoreParameters: { - maxMissedRounds: unwrap(params.parameters.v3.validatorScoreParameters?.maximumMissedRounds), - }, - }; - return cp; + return trChainParametersV3(params.parameters.v3); } case 'v2': { return trChainParametersV2(params.parameters.v2); From 46e01f9199de96c1d9b743202ec6f4e2e843e904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Mon, 13 Jan 2025 09:00:37 +0100 Subject: [PATCH 09/16] Add missing fields to pool info types --- packages/sdk/src/grpc/translation.ts | 3 +++ packages/sdk/src/types.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index fbcf269e..5e86d8bb 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -326,6 +326,8 @@ function transPaydayStatus(status: v2.PoolCurrentPaydayInfo): v1.CurrentPaydayBa bakerEquityCapital: CcdAmount.fromProto(unwrap(status.bakerEquityCapital)), delegatedCapital: CcdAmount.fromProto(unwrap(status.delegatedCapital)), commissionRates: trCommissionRates(status.commissionRates), + isPrimedForSuspension: status.isPrimedForSuspension ?? false, + missedRounds: status.missedRounds ?? 0n, }; } @@ -594,6 +596,7 @@ export function bakerPoolInfo(info: v2.PoolInfoResponse): v1.BakerPoolStatus { currentPaydayStatus: info.currentPaydayInfo !== undefined ? transPaydayStatus(info.currentPaydayInfo) : undefined, allPoolTotalCapital: CcdAmount.fromProto(unwrap(info.allPoolTotalCapital)), + isSuspended: info.isSuspended ?? false, }; } diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 918c5b9e..1c48bacd 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -891,15 +891,28 @@ export interface CommissionRates { finalizationCommission: number; } +/** Information about a baker pool in the current reward period. */ export interface CurrentPaydayBakerPoolStatus { + /** The number of blocks baked in the current reward period. */ blocksBaked: bigint; + /** The number of blocks baked in the current reward period. */ finalizationLive: boolean; + /** The transaction fees accruing to the pool in the current reward period. */ transactionFeesEarned: CcdAmount.Type; + /** The effective stake of the baker in the current reward period. */ effectiveStake: CcdAmount.Type; + /** The lottery power of the baker in the current reward period. */ lotteryPower: number; + /** The effective equity capital of the baker for the current reward period. */ bakerEquityCapital: CcdAmount.Type; + /** The effective delegated capital to the pool for the current reward period. */ delegatedCapital: CcdAmount.Type; + /** The commission rates that apply for the current reward period. */ commissionRates: CommissionRates; + /** A flag indicating whether the pool owner is primed for suspension. Will always be `false` if the protocol version does not support validator suspension. */ + isPrimedForSuspension: boolean; + /** The number of missed rounds in the current reward period. Will always be `0n` if the protocol version does not support validator suspension. */ + missedRounds:bigint; } export enum BakerPoolPendingChangeType { @@ -979,6 +992,11 @@ export interface BakerPoolStatusDetails { currentPaydayStatus?: CurrentPaydayBakerPoolStatus; /** Total capital staked across all pools, including passive delegation. */ allPoolTotalCapital: CcdAmount.Type; + /** + * A flag indicating whether the pool owner is suspended. + * Will always be `false` if the protocol version does not support validator suspension. + */ + isSuspended: boolean; } /** From 19e407d26cf1a1931feab0827e844c80ee3879bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Mon, 13 Jan 2025 09:48:55 +0100 Subject: [PATCH 10/16] FMT --- packages/sdk/src/types.ts | 2 +- packages/sdk/test/client/resources/expectedJsons.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 1c48bacd..2afc9ef6 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -912,7 +912,7 @@ export interface CurrentPaydayBakerPoolStatus { /** A flag indicating whether the pool owner is primed for suspension. Will always be `false` if the protocol version does not support validator suspension. */ isPrimedForSuspension: boolean; /** The number of missed rounds in the current reward period. Will always be `0n` if the protocol version does not support validator suspension. */ - missedRounds:bigint; + missedRounds: bigint; } export enum BakerPoolPendingChangeType { diff --git a/packages/sdk/test/client/resources/expectedJsons.ts b/packages/sdk/test/client/resources/expectedJsons.ts index 2c0fb06d..f71581ba 100644 --- a/packages/sdk/test/client/resources/expectedJsons.ts +++ b/packages/sdk/test/client/resources/expectedJsons.ts @@ -1923,8 +1923,11 @@ export const bakerPoolStatus: BakerPoolStatus = { finalizationCommission: 1, transactionCommission: 0.1, }, + missedRounds: 0n, + isPrimedForSuspension: false, }, allPoolTotalCapital: CcdAmount.fromMicroCcd(46071942529284135n), + isSuspended: false, }; export const passiveDelegationStatus: PassiveDelegationStatus = { @@ -1961,6 +1964,7 @@ export const bakerPoolStatusWithPendingChange: BakerPoolStatus = { effectiveTime: new Date('2022-12-08T07:54:00.000Z'), }, allPoolTotalCapital: CcdAmount.fromMicroCcd(46470271917743628n), + isSuspended: false, }; export const invokeContractResult: InvokeContractResult = { From 29b38eb9944dd36ad1a4ac85cc8ed637ac72d56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Mon, 13 Jan 2025 14:08:46 +0100 Subject: [PATCH 11/16] v9 bump --- packages/sdk/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 0203c653..36156920 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@concordium/web-sdk", - "version": "8.1.1", + "version": "9.0.0", "license": "Apache-2.0", "engines": { "node": ">=16" From 394ffb587b184bf3e7580df34cde6808b9fa4d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Wed, 15 Jan 2025 13:11:11 +0100 Subject: [PATCH 12/16] Add suspended field to configure validator transaction --- packages/sdk/CHANGELOG.md | 1 + packages/sdk/src/serializationHelpers.ts | 1 + packages/sdk/src/types.ts | 9 +++++++-- packages/sdk/test/ci/accountTransactions.test.ts | 5 +++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 7faf819e..43ced804 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -13,6 +13,7 @@ - Add `PendingValidatorScoreUpdate` to `UpdateInstructionPayload` union type. - Add `ChainParametersV3` to `ChainParameters` union type. - Add `isPrimedForSuspension` and `missedRounds` fields to `CurrentPaydayBakerPoolStatus`. + - Add suspended field to the `ConfigureBakerPayload` ## 8.1.1 diff --git a/packages/sdk/src/serializationHelpers.ts b/packages/sdk/src/serializationHelpers.ts index a42216ed..782870fd 100644 --- a/packages/sdk/src/serializationHelpers.ts +++ b/packages/sdk/src/serializationHelpers.ts @@ -357,6 +357,7 @@ const configureBakerSerializationSpec: SerializationSpec transactionFeeCommission: orUndefined(encodeWord32), bakingRewardCommission: orUndefined(encodeWord32), finalizationRewardCommission: orUndefined(encodeWord32), + suspended: orUndefined(encodeBool), }; const getSerializedConfigureBakerBitmap = (payload: ConfigureBakerPayload): Buffer => diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 2afc9ef6..f555a6c5 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1422,9 +1422,9 @@ export type BakerKeysWithProofs = PublicBakerKeys & BakerKeyProofs; export type GenerateBakerKeysOutput = PublicBakerKeys & PrivateBakerKeys & BakerKeyProofs; export interface ConfigureBakerPayload { - /* stake to bake. if set to 0, this removes the account as a baker */ + /** stake to bake. if set to 0, this removes the account as a baker */ stake?: CcdAmount.Type; - /* should earnings from baking be added to staked amount */ + /** should earnings from baking be added to staked amount */ restakeEarnings?: boolean; openForDelegation?: OpenStatus; keys?: BakerKeysWithProofs; @@ -1432,6 +1432,11 @@ export interface ConfigureBakerPayload { transactionFeeCommission?: number; bakingRewardCommission?: number; finalizationRewardCommission?: number; + /** + * Describes whether the validator should change its suspended status. This field is only from protocol version 8 + * and later. + */ + suspended?: boolean; } export interface ConfigureDelegationPayload { diff --git a/packages/sdk/test/ci/accountTransactions.test.ts b/packages/sdk/test/ci/accountTransactions.test.ts index 3bc0ac92..c67c6592 100644 --- a/packages/sdk/test/ci/accountTransactions.test.ts +++ b/packages/sdk/test/ci/accountTransactions.test.ts @@ -57,7 +57,7 @@ test('configureBaker is serialized correctly', async () => { sender: AccountAddress.fromBase58(senderAccountAddress), }; - const payload: Required = { + const payload: ConfigureBakerPayload = { stake: CcdAmount.fromMicroCcd(1000000000n), restakeEarnings: true, openForDelegation: OpenStatus.ClosedForAll, @@ -281,13 +281,14 @@ test('ConfigureBakerPayload serializes to JSON correctly', async () => { transactionFeeCommission: 1, bakingRewardCommission: 1, finalizationRewardCommission: 1, + suspended: true, }; const handler = new ConfigureBakerHandler(); let json = handler.toJSON(payload); let actual = JSONBig.stringify(json); let expected = - '{"stake":"1000000000","restakeEarnings":true,"openForDelegation":2,"keys":{"signatureVerifyKey":"abcdef","electionVerifyKey":"abcdef","aggregationVerifyKey":"abcdef","proofAggregation":"abcdef","proofSig":"abcdef","proofElection":"abcdef"},"metadataUrl":"http://example.com","transactionFeeCommission":1,"bakingRewardCommission":1,"finalizationRewardCommission":1}'; + '{"stake":"1000000000","restakeEarnings":true,"openForDelegation":2,"keys":{"signatureVerifyKey":"abcdef","electionVerifyKey":"abcdef","aggregationVerifyKey":"abcdef","proofAggregation":"abcdef","proofSig":"abcdef","proofElection":"abcdef"},"metadataUrl":"http://example.com","transactionFeeCommission":1,"bakingRewardCommission":1,"finalizationRewardCommission":1,"suspended":true}'; expect(actual).toEqual(expected); // ID test From abd0a437a67698b0a44053a40a2003a9c6068c0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 16 Jan 2025 12:07:06 +0100 Subject: [PATCH 13/16] Update examples --- examples/nodejs/client/getAccountInfo.ts | 4 + examples/nodejs/client/getPoolInfo.ts | 2 + examples/nodejs/package.json | 4 +- examples/reactnative/ios/Podfile.lock | 2 +- yarn.lock | 282 ++++++++++++++++++++++- 5 files changed, 288 insertions(+), 6 deletions(-) diff --git a/examples/nodejs/client/getAccountInfo.ts b/examples/nodejs/client/getAccountInfo.ts index 88283e30..1359134d 100644 --- a/examples/nodejs/client/getAccountInfo.ts +++ b/examples/nodejs/client/getAccountInfo.ts @@ -64,5 +64,9 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c if (accountInfo.type === AccountInfoType.Delegator) { console.log('Delegated stake amount:', accountInfo.accountDelegation.stakedAmount); } + + if (accountInfo.type === AccountInfoType.Baker) { + console.log('Validator pool info:', accountInfo.accountBaker); + } // #endregion documentation-snippet })(); diff --git a/examples/nodejs/client/getPoolInfo.ts b/examples/nodejs/client/getPoolInfo.ts index f449965f..70e761da 100644 --- a/examples/nodejs/client/getPoolInfo.ts +++ b/examples/nodejs/client/getPoolInfo.ts @@ -65,5 +65,7 @@ const client = new ConcordiumGRPCNodeClient(address, Number(port), credentials.c ); console.log('Total capital in CCD of ALL pools:', CcdAmount.toCcd(bakerPool.allPoolTotalCapital)); console.log('Pool commision rates:', bakerPool.poolInfo?.commissionRates); + console.log('Is suspended:', bakerPool.isSuspended); + console.log('Current payday status:', bakerPool.currentPaydayStatus); // #endregion documentation-snippet })(); diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index d1a38b2a..a67f9031 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -20,7 +20,7 @@ "devDependencies": { "@types/node": "^20.12.13", "eslint": "8", - "ts-node": "10.9", + "tsx": "^4.19.2", "typescript": "^5.2.2" }, "scripts": { @@ -30,6 +30,6 @@ "fmt": "yarn prettier --write", "fmt-check": "yarn prettier --check", "build": "tsc --noEmit", - "run-example": "ts-node" + "run-example": "tsx" } } diff --git a/examples/reactnative/ios/Podfile.lock b/examples/reactnative/ios/Podfile.lock index d8dfed02..0d614795 100644 --- a/examples/reactnative/ios/Podfile.lock +++ b/examples/reactnative/ios/Podfile.lock @@ -716,4 +716,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: c70448f9d8b13c40c47391af88ee9f69ffe85d63 -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/yarn.lock b/yarn.lock index e6385dfa..11403466 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3623,7 +3623,7 @@ __metadata: eslint: 8 meow: 11.0 node-fetch: ^3.3.2 - ts-node: 10.9 + tsx: ^4.19.2 typescript: ^5.2.2 languageName: unknown linkType: soft @@ -3933,6 +3933,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/aix-ppc64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/aix-ppc64@npm:0.23.1" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + "@esbuild/android-arm64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/android-arm64@npm:0.18.20" @@ -3940,6 +3947,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/android-arm64@npm:0.23.1" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/android-arm@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/android-arm@npm:0.18.20" @@ -3947,6 +3961,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-arm@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/android-arm@npm:0.23.1" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + "@esbuild/android-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/android-x64@npm:0.18.20" @@ -3954,6 +3975,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/android-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/android-x64@npm:0.23.1" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + "@esbuild/darwin-arm64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/darwin-arm64@npm:0.18.20" @@ -3961,6 +3989,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/darwin-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/darwin-arm64@npm:0.23.1" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/darwin-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/darwin-x64@npm:0.18.20" @@ -3968,6 +4003,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/darwin-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/darwin-x64@npm:0.23.1" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + "@esbuild/freebsd-arm64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/freebsd-arm64@npm:0.18.20" @@ -3975,6 +4017,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/freebsd-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/freebsd-arm64@npm:0.23.1" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/freebsd-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/freebsd-x64@npm:0.18.20" @@ -3982,6 +4031,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/freebsd-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/freebsd-x64@npm:0.23.1" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + "@esbuild/linux-arm64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-arm64@npm:0.18.20" @@ -3989,6 +4045,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-arm64@npm:0.23.1" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/linux-arm@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-arm@npm:0.18.20" @@ -3996,6 +4059,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-arm@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-arm@npm:0.23.1" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + "@esbuild/linux-ia32@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-ia32@npm:0.18.20" @@ -4003,6 +4073,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-ia32@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-ia32@npm:0.23.1" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + "@esbuild/linux-loong64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-loong64@npm:0.18.20" @@ -4010,6 +4087,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-loong64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-loong64@npm:0.23.1" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + "@esbuild/linux-mips64el@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-mips64el@npm:0.18.20" @@ -4017,6 +4101,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-mips64el@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-mips64el@npm:0.23.1" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + "@esbuild/linux-ppc64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-ppc64@npm:0.18.20" @@ -4024,6 +4115,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-ppc64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-ppc64@npm:0.23.1" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + "@esbuild/linux-riscv64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-riscv64@npm:0.18.20" @@ -4031,6 +4129,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-riscv64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-riscv64@npm:0.23.1" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + "@esbuild/linux-s390x@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-s390x@npm:0.18.20" @@ -4038,6 +4143,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-s390x@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-s390x@npm:0.23.1" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + "@esbuild/linux-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/linux-x64@npm:0.18.20" @@ -4045,6 +4157,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/linux-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-x64@npm:0.23.1" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + "@esbuild/netbsd-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/netbsd-x64@npm:0.18.20" @@ -4052,6 +4171,20 @@ __metadata: languageName: node linkType: hard +"@esbuild/netbsd-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/netbsd-x64@npm:0.23.1" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/openbsd-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/openbsd-arm64@npm:0.23.1" + conditions: os=openbsd & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/openbsd-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/openbsd-x64@npm:0.18.20" @@ -4059,6 +4192,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/openbsd-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/openbsd-x64@npm:0.23.1" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + "@esbuild/sunos-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/sunos-x64@npm:0.18.20" @@ -4066,6 +4206,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/sunos-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/sunos-x64@npm:0.23.1" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + "@esbuild/win32-arm64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/win32-arm64@npm:0.18.20" @@ -4073,6 +4220,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/win32-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/win32-arm64@npm:0.23.1" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + "@esbuild/win32-ia32@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/win32-ia32@npm:0.18.20" @@ -4080,6 +4234,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/win32-ia32@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/win32-ia32@npm:0.23.1" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + "@esbuild/win32-x64@npm:0.18.20": version: 0.18.20 resolution: "@esbuild/win32-x64@npm:0.18.20" @@ -4087,6 +4248,13 @@ __metadata: languageName: node linkType: hard +"@esbuild/win32-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/win32-x64@npm:0.23.1" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -13217,6 +13385,89 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:~0.23.0": + version: 0.23.1 + resolution: "esbuild@npm:0.23.1" + dependencies: + "@esbuild/aix-ppc64": 0.23.1 + "@esbuild/android-arm": 0.23.1 + "@esbuild/android-arm64": 0.23.1 + "@esbuild/android-x64": 0.23.1 + "@esbuild/darwin-arm64": 0.23.1 + "@esbuild/darwin-x64": 0.23.1 + "@esbuild/freebsd-arm64": 0.23.1 + "@esbuild/freebsd-x64": 0.23.1 + "@esbuild/linux-arm": 0.23.1 + "@esbuild/linux-arm64": 0.23.1 + "@esbuild/linux-ia32": 0.23.1 + "@esbuild/linux-loong64": 0.23.1 + "@esbuild/linux-mips64el": 0.23.1 + "@esbuild/linux-ppc64": 0.23.1 + "@esbuild/linux-riscv64": 0.23.1 + "@esbuild/linux-s390x": 0.23.1 + "@esbuild/linux-x64": 0.23.1 + "@esbuild/netbsd-x64": 0.23.1 + "@esbuild/openbsd-arm64": 0.23.1 + "@esbuild/openbsd-x64": 0.23.1 + "@esbuild/sunos-x64": 0.23.1 + "@esbuild/win32-arm64": 0.23.1 + "@esbuild/win32-ia32": 0.23.1 + "@esbuild/win32-x64": 0.23.1 + dependenciesMeta: + "@esbuild/aix-ppc64": + optional: true + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-arm64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 0413c3b9257327fb598427688b7186ea335bf1693746fe5713cc93c95854d6388b8ed4ad643fddf5b5ace093f7dcd9038dd58e087bf2da1f04dfb4c5571660af + languageName: node + linkType: hard + "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -14569,7 +14820,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:~2.3.2": +"fsevents@npm:~2.3.2, fsevents@npm:~2.3.3": version: 2.3.3 resolution: "fsevents@npm:2.3.3" dependencies: @@ -14588,7 +14839,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@~2.3.2#~builtin": +"fsevents@patch:fsevents@~2.3.2#~builtin, fsevents@patch:fsevents@~2.3.3#~builtin": version: 2.3.3 resolution: "fsevents@patch:fsevents@npm%3A2.3.3#~builtin::version=2.3.3&hash=18f3a7" dependencies: @@ -14818,6 +15069,15 @@ __metadata: languageName: node linkType: hard +"get-tsconfig@npm:^4.7.5": + version: 4.8.1 + resolution: "get-tsconfig@npm:4.8.1" + dependencies: + resolve-pkg-maps: ^1.0.0 + checksum: 12df01672e691d2ff6db8cf7fed1ddfef90ed94a5f3d822c63c147a26742026d582acd86afcd6f65db67d809625d17dd7f9d34f4d3f38f69bc2f48e19b2bdd5b + languageName: node + linkType: hard + "get-uri@npm:^6.0.1": version: 6.0.3 resolution: "get-uri@npm:6.0.3" @@ -25803,6 +26063,22 @@ __metadata: languageName: node linkType: hard +"tsx@npm:^4.19.2": + version: 4.19.2 + resolution: "tsx@npm:4.19.2" + dependencies: + esbuild: ~0.23.0 + fsevents: ~2.3.3 + get-tsconfig: ^4.7.5 + dependenciesMeta: + fsevents: + optional: true + bin: + tsx: dist/cli.mjs + checksum: 7f9f1b338a73297725a9217cedaaad862f7c81d5264093c74b98a71491ad5413b11248d604c0e650f4f7da6f365249f1426fdb58a1325ab9e15448156b1edff6 + languageName: node + linkType: hard + "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0" From c19a7b2bc37177ac7b8cd4b1b8f301836be59fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 16 Jan 2025 12:50:28 +0100 Subject: [PATCH 14/16] Add missing sequence num --- packages/sdk/src/grpc/translation.ts | 1 + packages/sdk/src/types.ts | 1 + packages/sdk/test/client/resources/expectedJsons.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index 5e86d8bb..8a4c440d 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -2226,6 +2226,7 @@ export function nextUpdateSequenceNumbers(nextNums: v2.NextUpdateSequenceNumbers minBlockTime: unwrap(nextNums.minBlockTime?.value), blockEnergyLimit: unwrap(nextNums.blockEnergyLimit?.value), finalizationCommiteeParameters: unwrap(nextNums.finalizationCommitteeParameters?.value), + validatorScoreParameters: nextNums.validatorScoreParameters?.value ?? 1n, }; } diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index f555a6c5..df19bf50 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -1227,6 +1227,7 @@ export interface NextUpdateSequenceNumbers { minBlockTime: bigint; blockEnergyLimit: bigint; finalizationCommiteeParameters: bigint; + validatorScoreParameters: bigint; } export type BlockFinalizationSummary = BlockFinalizationSummary_None | BlockFinalizationSummary_Record; diff --git a/packages/sdk/test/client/resources/expectedJsons.ts b/packages/sdk/test/client/resources/expectedJsons.ts index f71581ba..7f9c90ac 100644 --- a/packages/sdk/test/client/resources/expectedJsons.ts +++ b/packages/sdk/test/client/resources/expectedJsons.ts @@ -543,6 +543,7 @@ export const seqNums: NextUpdateSequenceNumbers = { blockEnergyLimit: 1n, minBlockTime: 1n, finalizationCommiteeParameters: 1n, + validatorScoreParameters: 1n, }; export const specialEventList: BlockSpecialEvent[] = [ From d220ce95179d38a88b5a1ce196340c742c9b52dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 16 Jan 2025 13:04:14 +0100 Subject: [PATCH 15/16] Handle validator score update payload --- packages/sdk/src/grpc/translation.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/sdk/src/grpc/translation.ts b/packages/sdk/src/grpc/translation.ts index 8a4c440d..dcde0a92 100644 --- a/packages/sdk/src/grpc/translation.ts +++ b/packages/sdk/src/grpc/translation.ts @@ -1538,10 +1538,16 @@ function trUpdatePayload(updatePayload: v2.UpdatePayload | undefined): v1.Update update: keyUpdate, }; } + case 'validatorScoreParametersUpdate': { + return { + updateType: v1.UpdateType.ValidatorScoreParameters, + update: { + maxMissedRounds: payload.validatorScoreParametersUpdate.maximumMissedRounds, + }, + }; + } case undefined: throw new Error('Unexpected missing update payload'); - default: - throw Error(`Unsupported update payload type: ${payload}`); } } @@ -2226,6 +2232,7 @@ export function nextUpdateSequenceNumbers(nextNums: v2.NextUpdateSequenceNumbers minBlockTime: unwrap(nextNums.minBlockTime?.value), blockEnergyLimit: unwrap(nextNums.blockEnergyLimit?.value), finalizationCommiteeParameters: unwrap(nextNums.finalizationCommitteeParameters?.value), + // We fall back to be backwards compatible. validatorScoreParameters: nextNums.validatorScoreParameters?.value ?? 1n, }; } From cb95554a6f2ad66716f60c61f3aa190a1c7d2317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Bruus=20Zeppelin?= Date: Thu, 16 Jan 2025 14:06:13 +0100 Subject: [PATCH 16/16] Changelog update --- packages/sdk/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index 43ced804..36ea5199 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -13,7 +13,8 @@ - Add `PendingValidatorScoreUpdate` to `UpdateInstructionPayload` union type. - Add `ChainParametersV3` to `ChainParameters` union type. - Add `isPrimedForSuspension` and `missedRounds` fields to `CurrentPaydayBakerPoolStatus`. - - Add suspended field to the `ConfigureBakerPayload` + - Add suspended field to the `ConfigureBakerPayload`. + - Add `validatorScoreParameters` to `NextUpdateSequenceNumbers`. ## 8.1.1