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

BlockState/TransactionState and metadata changes #2149

Merged
merged 21 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
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
5 changes: 2 additions & 3 deletions bindings/nodejs/examples/evm/send-evm-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ async function run(): Promise<void> {
// 6. Send signed transaction
const hexSignedTransaction =
getHexEncodedTransaction(signedTransaction);
const sentTransaction = await provider.eth.sendSignedTransaction(
hexSignedTransaction,
);
const sentTransaction =
await provider.eth.sendSignedTransaction(hexSignedTransaction);
console.log('sent Transaction', sentTransaction);
} catch (error) {
console.error('Error: ', error);
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 @@
*/
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;

Check failure on line 31 in bindings/nodejs/lib/types/models/api/transaction-response.ts

View workflow job for this annotation

GitHub Actions / Lint

Don't use `String` as a type. Use string instead
}
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';
9 changes: 6 additions & 3 deletions bindings/python/iota_sdk/client/_node_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def get_info(self, url: str, auth=None) -> InfoResponse:

# Accounts routes.

def get_account_congestion(self, account_id: HexStr, work_score: Optional[int] = None) -> CongestionResponse:
def get_account_congestion(
self, account_id: HexStr, work_score: Optional[int] = None) -> CongestionResponse:
"""Checks if the account is ready to issue a block.
GET /api/core/v3/accounts/{bech32Address}/congestion
"""
Expand Down Expand Up @@ -112,7 +113,8 @@ def get_output_mana_rewards(

# Validators routes.

def get_validators(self, page_size: Optional[int] = None, cursor: Optional[str] = None) -> ValidatorsResponse:
def get_validators(
self, page_size: Optional[int] = None, cursor: Optional[str] = None) -> ValidatorsResponse:
"""Returns information of all stakers (registered validators) and if they are active, ordered by their holding stake.
GET /api/core/v3/validators
"""
Expand All @@ -131,7 +133,8 @@ def get_validator(self, account_id: HexStr) -> ValidatorResponse:

# Committee routes.

def get_committee(self, epoch_index: Optional[EpochIndex] = None) -> CommitteeResponse:
def get_committee(
self, epoch_index: Optional[EpochIndex] = None) -> CommitteeResponse:
"""Returns the information of committee members at the given epoch index. If epoch index is not provided, the
current committee members are returned.
GET /api/core/v3/committee/?epochIndex
Expand Down
3 changes: 2 additions & 1 deletion bindings/python/iota_sdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ def get_node(self) -> Dict[str, Any]:
def get_protocol_parameters(self) -> ProtocolParameters:
"""Gets the protocol parameters.
"""
return ProtocolParameters.from_dict(self._call_method('getProtocolParameters'))
return ProtocolParameters.from_dict(
self._call_method('getProtocolParameters'))

def get_network_id(self) -> int:
"""Gets the network id of the node we're connecting to.
Expand Down
Loading
Loading