Skip to content

Commit

Permalink
BlockState/TransactionState and metadata changes (#2149)
Browse files Browse the repository at this point in the history
* Some metadata changes

* Remove BlockFailureReason

* TransactionState

* Remove tx metadata from block metadata

* nits

* Add earliest_attachment_slot

* Add transaction_failure_details

* rust TransactionFailureReason

* nodejs TransactionFailureReason

* python TransactionFailureReason

* fix

* lint

* remove ./block-failure-reason export

* disable tests

* disable more tests

* fmt

* cleanup

* lint

---------

Co-authored-by: Alex Coats <[email protected]>
Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2024
1 parent ffb6fc2 commit 640b3bf
Show file tree
Hide file tree
Showing 18 changed files with 481 additions and 618 deletions.
1 change: 0 additions & 1 deletion bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
EpochIndex,
Address,
} from '../types/block';
import { HexEncodedString } from '../utils';
import {
BlockMetadataResponse,
InfoResponse,
Expand Down
1 change: 0 additions & 1 deletion bindings/nodejs/lib/types/client/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import type { BasicOutputBuilderParams } from '../output_builder_params/basic-ou
import type { AccountOutputBuilderParams } from '../output_builder_params/account-output-params';
import type { FoundryOutputBuilderParams } from '../output_builder_params/foundry-output-params';
import type { NftOutputBuilderParams } from '../output_builder_params/nft-output-params';
import { HexEncodedString } from '../../utils';
import { TransactionId } from '../..';

// Node routes.
Expand Down
57 changes: 0 additions & 57 deletions bindings/nodejs/lib/types/models/api/block-failure-reason.ts

This file was deleted.

10 changes: 0 additions & 10 deletions bindings/nodejs/lib/types/models/api/block-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { BlockState } from '../state';
import { BlockFailureReason } from './block-failure-reason';
import { Block, BlockId } from '../../block';
import { TransactionMetadataResponse } from './transaction-response';

/**
* Response from the metadata endpoint.
Expand All @@ -18,14 +16,6 @@ export interface BlockMetadataResponse {
* The block state.
*/
blockState: BlockState;
/**
* The block failure reason.
*/
blockFailureReason?: BlockFailureReason;
/**
* The metadata of the transaction in the block.
*/
transactionMetadata?: TransactionMetadataResponse;
}

/**
Expand Down
1 change: 0 additions & 1 deletion bindings/nodejs/lib/types/models/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

export * from './info';
export * from './plugins';
export * from './block-failure-reason';
export * from './block-response';
export * from './committee-response';
export * from './congestion-response';
Expand Down
136 changes: 69 additions & 67 deletions bindings/nodejs/lib/types/models/api/transaction-failure-reason.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,74 @@
export enum TransactionFailureReason {
None = 0,
ConflictRejected = 1,
InputAlreadySpent = 2,
InputCreationAfterTxCreation = 3,
UnlockSignatureInvalid = 4,
ChainAddressUnlockInvalid = 5,
DirectUnlockableAddressUnlockInvalid = 6,
MultiAddressUnlockInvalid = 7,
CommitmentInputReferenceInvalid = 8,
BicInputReferenceInvalid = 9,
RewardInputReferenceInvalid = 10,
StakingRewardCalculationFailure = 11,
DelegationRewardCalculationFailure = 12,
InputOutputBaseTokenMismatch = 13,
ManaOverflow = 14,
InputOutputManaMismatch = 15,
ManaDecayCreationIndexExceedsTargetIndex = 16,
NativeTokenSumUnbalanced = 17,
SimpleTokenSchemeMintedMeltedTokenDecrease = 18,
SimpleTokenSchemeMintingInvalid = 19,
SimpleTokenSchemeMeltingInvalid = 20,
SimpleTokenSchemeMaximumSupplyChanged = 21,
SimpleTokenSchemeGenesisInvalid = 22,
MultiAddressLengthUnlockLengthMismatch = 23,
MultiAddressUnlockThresholdNotReached = 24,
SenderFeatureNotUnlocked = 25,
IssuerFeatureNotUnlocked = 26,
StakingRewardInputMissing = 27,
StakingCommitmentInputMissing = 28,
StakingRewardClaimingInvalid = 29,
StakingFeatureRemovedBeforeUnbonding = 30,
StakingFeatureModifiedBeforeUnbonding = 31,
StakingStartEpochInvalid = 32,
StakingEndEpochTooEarly = 33,
BlockIssuerCommitmentInputMissing = 34,
BlockIssuanceCreditInputMissing = 35,
BlockIssuerNotExpired = 36,
BlockIssuerExpiryTooEarly = 37,
ManaMovedOffBlockIssuerAccount = 38,
AccountLocked = 39,
TimelockCommitmentInputMissing = 40,
TimelockNotExpired = 41,
ExpirationCommitmentInputMissing = 42,
ExpirationNotUnlockable = 43,
ReturnAmountNotFulFilled = 44,
NewChainOutputHasNonZeroedId = 45,
ChainOutputImmutableFeaturesChanged = 46,
ImplicitAccountDestructionDisallowed = 47,
MultipleImplicitAccountCreationAddresses = 48,
AccountInvalidFoundryCounter = 49,
AnchorInvalidStateTransition = 50,
AnchorInvalidGovernanceTransition = 51,
FoundryTransitionWithoutAccount = 52,
FoundrySerialInvalid = 53,
DelegationCommitmentInputMissing = 54,
DelegationRewardInputMissing = 55,
DelegationRewardsClaimingInvalid = 56,
DelegationOutputTransitionedTwice = 57,
DelegationModified = 58,
DelegationStartEpochInvalid = 59,
DelegationAmountMismatch = 60,
DelegationEndEpochNotZero = 61,
DelegationEndEpochInvalid = 62,
CapabilitiesNativeTokenBurningNotAllowed = 63,
CapabilitiesManaBurningNotAllowed = 64,
CapabilitiesAccountDestructionNotAllowed = 65,
CapabilitiesAnchorDestructionNotAllowed = 66,
CapabilitiesFoundryDestructionNotAllowed = 67,
CapabilitiesNftDestructionNotAllowed = 68,
Orphaned = 2,
InputAlreadySpent = 3,
InputCreationAfterTxCreation = 4,
UnlockSignatureInvalid = 5,
ChainAddressUnlockInvalid = 6,
DirectUnlockableAddressUnlockInvalid = 7,
MultiAddressUnlockInvalid = 8,
CommitmentInputReferenceInvalid = 9,
BicInputReferenceInvalid = 10,
RewardInputReferenceInvalid = 11,
StakingRewardCalculationFailure = 12,
DelegationRewardCalculationFailure = 13,
InputOutputBaseTokenMismatch = 14,
ManaOverflow = 15,
InputOutputManaMismatch = 16,
ManaDecayCreationIndexExceedsTargetIndex = 17,
NativeTokenSumUnbalanced = 18,
SimpleTokenSchemeMintedMeltedTokenDecrease = 19,
SimpleTokenSchemeMintingInvalid = 20,
SimpleTokenSchemeMeltingInvalid = 21,
SimpleTokenSchemeMaximumSupplyChanged = 22,
SimpleTokenSchemeGenesisInvalid = 23,
MultiAddressLengthUnlockLengthMismatch = 24,
MultiAddressUnlockThresholdNotReached = 25,
SenderFeatureNotUnlocked = 26,
IssuerFeatureNotUnlocked = 27,
StakingRewardInputMissing = 28,
StakingCommitmentInputMissing = 29,
StakingRewardClaimingInvalid = 30,
StakingFeatureRemovedBeforeUnbonding = 31,
StakingFeatureModifiedBeforeUnbonding = 32,
StakingStartEpochInvalid = 33,
StakingEndEpochTooEarly = 34,
BlockIssuerCommitmentInputMissing = 35,
BlockIssuanceCreditInputMissing = 36,
BlockIssuerNotExpired = 37,
BlockIssuerExpiryTooEarly = 38,
ManaMovedOffBlockIssuerAccount = 39,
AccountLocked = 40,
TimelockCommitmentInputMissing = 41,
TimelockNotExpired = 42,
ExpirationCommitmentInputMissing = 43,
ExpirationNotUnlockable = 44,
ReturnAmountNotFulFilled = 45,
NewChainOutputHasNonZeroedId = 46,
ChainOutputImmutableFeaturesChanged = 47,
ImplicitAccountDestructionDisallowed = 48,
MultipleImplicitAccountCreationAddresses = 49,
AccountInvalidFoundryCounter = 50,
AnchorInvalidStateTransition = 51,
AnchorInvalidGovernanceTransition = 52,
FoundryTransitionWithoutAccount = 53,
FoundrySerialInvalid = 54,
DelegationCommitmentInputMissing = 55,
DelegationRewardInputMissing = 56,
DelegationRewardsClaimingInvalid = 57,
DelegationOutputTransitionedTwice = 58,
DelegationModified = 59,
DelegationStartEpochInvalid = 60,
DelegationAmountMismatch = 61,
DelegationEndEpochNotZero = 62,
DelegationEndEpochInvalid = 63,
CapabilitiesNativeTokenBurningNotAllowed = 64,
CapabilitiesManaBurningNotAllowed = 65,
CapabilitiesAccountDestructionNotAllowed = 66,
CapabilitiesAnchorDestructionNotAllowed = 67,
CapabilitiesFoundryDestructionNotAllowed = 68,
CapabilitiesNftDestructionNotAllowed = 69,
SemanticValidationFailed = 255,
}

Expand All @@ -86,6 +87,7 @@ export const TRANSACTION_FAILURE_REASON_STRINGS: {
[TransactionFailureReason.None]: 'None.',
[TransactionFailureReason.ConflictRejected]:
'Transaction was conflicting and was rejected.',
[TransactionFailureReason.Orphaned]: 'Transaction was orphaned.',
[TransactionFailureReason.InputAlreadySpent]: 'Input already spent.',
[TransactionFailureReason.InputCreationAfterTxCreation]:
'Input creation slot after tx creation slot.',
Expand Down
12 changes: 10 additions & 2 deletions bindings/nodejs/lib/types/models/api/transaction-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import { TransactionState } from '../state';
import { TransactionId } from '../../block';
import { SlotIndex, TransactionId } from '../../block';
import { TransactionFailureReason } from './transaction-failure-reason';

/**
Expand All @@ -18,7 +18,15 @@ export interface TransactionMetadataResponse {
*/
transactionState: TransactionState;
/**
* The transaction failure reason.
* The slot of the earliest included valid block that contains an attachment of the transaction.
*/
earliestAttachmentSlot: SlotIndex;
/**
* If applicable, indicates the error that occurred during the transaction processing.
*/
transactionFailureReason?: TransactionFailureReason;
/**
* Contains the detailed error message that occurred during the transaction processing if the debug mode was activated in the retainer.
*/
transactionFailureDetails?: string;
}
36 changes: 22 additions & 14 deletions bindings/nodejs/lib/types/models/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,40 @@

/**
* The different states of a block.
* 'pending': stored but not accepted/confirmed.
* 'accepted': valid block referenced by some validators.
* 'confirmed': valid block referenced by more than 2/3 of the validators.
* 'finalized': accepted/confirmed block and the slot was finalized, can no longer be reverted.
* 'rejected': rejected by the node, and user should reissue payload if it contains one.
* 'failed': not successfully issued due to failure reason.
* 'pending': The block has been booked by the node but not yet accepted.
* 'accepted': The block has been referenced by the super majority of the online committee.
* 'confirmed': The block has been referenced by the super majority of the total committee.
* 'finalized': The commitment containing the block has been finalized.
* This state is computed based on the accepted/confirmed block's slot being smaller or equal than the latest finalized slot.
* 'dropped': The block has been dropped due to congestion control.
* 'orphaned': The block's slot has been committed by the node without the block being included.
* In this case, the block will never be finalized unless there is a chain switch.
* This state is computed based on the pending block's slot being smaller or equal than the latest committed slot.
*/
export declare type BlockState =
| 'pending'
| 'accepted'
| 'confirmed'
| 'finalized'
| 'rejected'
| 'failed';
| 'dropped'
| 'orphaned';

/**
* The different states of a transaction.
* 'pending': the transaction is not included yet.
* 'accepted': the transaction is included.
* 'confirmed': the transaction is included and its included block is confirmed.
* 'finalized': the transaction is included, its included block is finalized and cannot be reverted anymore.
* 'failed': the transaction is not successfully issued due to failure reason.
* 'pending': The transaction has been booked by the node but not yet accepted.
* 'accepted': The transaction meets the following 4 conditions:
* - Signatures of the transaction are valid.
* - The transaction has been approved by the super majority of the online committee (potential conflicts are resolved by this time).
* - The transactions that created the inputs were accepted (monotonicity).
* - At least one valid attachment was accepted.
* 'committed': The slot of the earliest accepted attachment of the transaction was committed.
* 'finalized': The transaction is accepted and the slot containing the transaction has been finalized by the node.
* This state is computed based on the accepted transaction's earliest included attachment slot being smaller or equal than the latest finalized slot.
* 'failed': The transaction has not been executed by the node due to a failure during processing.
*/
export declare type TransactionState =
| 'pending'
| 'accepted'
| 'confirmed'
| 'committed'
| 'finalized'
| 'failed';
Loading

0 comments on commit 640b3bf

Please sign in to comment.