Typeberry by Fluffy Labs - v0.4.0
    Preparing search index...

    Class InMemoryBlocks

    In-memory (non-persistent) blocks database.

    Implements

    Index

    Methods

    • Retrieve extrinsic data by hash of the header they are part of.

      NOTE: this is not extrinsic hash!

      Parameters

      Returns
          | ViewOf<
              Extrinsic,
              {
                  assurances: Descriptor<
                      readonly AvailabilityAssurance[] & pvm.WithOpaque<
                          "[0 .. ValidatorsCount)",
                      >,
                      SequenceView<
                          AvailabilityAssurance,
                          ViewOf<
                              AvailabilityAssurance,
                              {
                                  anchor: Descriptor<
                                      Bytes<32> & pvm.WithOpaque<"HeaderHash">,
                                      Bytes<32>,
                                  >;
                                  bitfield: Descriptor<BitVec, BitVec>;
                                  signature: Descriptor<
                                      Bytes<64> & pvm.WithOpaque<"Ed25519Signature">,
                                      Bytes<64>,
                                  >;
                                  validatorIndex: Descriptor<
                                      number & WithBytesRepresentation<2> & pvm.WithOpaque<
                                          "ValidatorIndex[u16]",
                                      >,
                                      Bytes<2>,
                                  >;
                              },
                          >,
                      >,
                  >;
                  disputes: Descriptor<
                      DisputesExtrinsic,
                      ViewOf<
                          DisputesExtrinsic,
                          {
                              culprits: Descriptor<
                                  Culprit[],
                                  SequenceView<
                                      Culprit,
                                      ViewOf<
                                          Culprit,
                                          {
                                              key: Descriptor<(...), (...)>;
                                              signature: Descriptor<(...), (...)>;
                                              workReportHash: Descriptor<(...), (...)>;
                                          },
                                      >,
                                  >,
                              >;
                              faults: Descriptor<
                                  Fault[],
                                  SequenceView<
                                      Fault,
                                      ViewOf<
                                          Fault,
                                          {
                                              key: Descriptor<(...), (...)>;
                                              signature: Descriptor<(...), (...)>;
                                              wasConsideredValid: Descriptor<(...), (...)>;
                                              workReportHash: Descriptor<(...), (...)>;
                                          },
                                      >,
                                  >,
                              >;
                              verdicts: Descriptor<
                                  Verdict[],
                                  SequenceView<
                                      Verdict,
                                      ViewOf<
                                          Verdict,
                                          {
                                              votes: Descriptor<(...), (...)>;
                                              votesEpoch: Descriptor<(...), (...)>;
                                              workReportHash: Descriptor<(...), (...)>;
                                          },
                                      >,
                                  >,
                              >;
                          },
                      >,
                  >;
                  guarantees: Descriptor<
                      readonly ReportGuarantee[] & pvm.WithOpaque<"[0..CoresCount)">,
                      SequenceView<
                          ReportGuarantee,
                          ViewOf<
                              ReportGuarantee,
                              {
                                  credentials: Descriptor<
                                      | readonly (...)[] & pvm.WithOpaque<(...)>
                                      | readonly (...)[] & pvm.WithOpaque<(...)>,
                                      SequenceView<
                                          Credential,
                                          ViewOf<Credential, { signature: ...; validatorIndex: ... }>,
                                      >,
                                  >;
                                  report: Descriptor<
                                      WorkReportNoCodec,
                                      ViewOf<
                                          WorkReportNoCodec,
                                          {
                                              authorizationGasUsed: Descriptor<(...), (...)>;
                                              authorizationOutput: Descriptor<(...), (...)>;
                                              authorizerHash: Descriptor<(...), (...)>;
                                              context: Descriptor<(...), (...)>;
                                              coreIndex: Descriptor<(...), (...)>;
                                              results: Descriptor<(...), (...)>;
                                              segmentRootLookup: Descriptor<(...), (...)>;
                                              workPackageSpec: Descriptor<(...), (...)>;
                                          },
                                      >,
                                  >;
                                  slot: Descriptor<
                                      number & WithBytesRepresentation<4> & pvm.WithOpaque<
                                          "TimeSlot[u32]",
                                      >,
                                      Bytes<4>,
                                  >;
                              },
                          >,
                      >,
                  >;
                  preimages: Descriptor<
                      Preimage[],
                      SequenceView<
                          Preimage,
                          ViewOf<
                              Preimage,
                              {
                                  blob: Descriptor<BytesBlob, BytesBlob>;
                                  requester: Descriptor<
                                      number & WithBytesRepresentation<4> & pvm.WithOpaque<
                                          "ServiceId[u32]",
                                      >,
                                      Bytes<4>,
                                  >;
                              },
                          >,
                      >,
                  >;
                  tickets: Descriptor<
                      readonly SignedTicket[] & pvm.WithOpaque<
                          "Size: [0..chainSpec.maxTicketsPerExtrinsic)",
                      >,
                      SequenceView<
                          SignedTicket,
                          ViewOf<
                              SignedTicket,
                              {
                                  attempt: Descriptor<
                                      number & WithBytesRepresentation<1> & pvm.WithOpaque<
                                          "TicketAttempt[0|1|2]",
                                      >,
                                      U8,
                                  >;
                                  signature: Descriptor<
                                      Bytes<784> & pvm.WithOpaque<"BandersnatchRingSignature">,
                                      Bytes<784>,
                                  >;
                              },
                          >,
                      >,
                  >;
              },
          >
          | null

    • Retrieve header by hash.

      Parameters

      Returns
          | ViewOf<
              Header & CodecRecord<Header>,
              {
                  bandersnatchBlockAuthorIndex: Descriptor<
                      number & WithBytesRepresentation<2> & pvm.WithOpaque<
                          "ValidatorIndex[u16]",
                      >,
                      Bytes<2>,
                  >;
                  entropySource: Descriptor<
                      Bytes<96> & pvm.WithOpaque<"BandersnatchVrfSignature">,
                      Bytes<96>,
                  >;
                  epochMarker: Descriptor<
                      EpochMarker
                      | null,

                          | ViewOf<
                              EpochMarker,
                              {
                                  entropy: Descriptor<
                                      Bytes<32> & pvm.WithOpaque<"EntropyHash">,
                                      Bytes<32>,
                                  >;
                                  ticketsEntropy: Descriptor<
                                      Bytes<32> & pvm.WithOpaque<"EntropyHash">,
                                      Bytes<32>,
                                  >;
                                  validators: Descriptor<
                                      readonly ValidatorKeys[] & pvm.WithOpaque<"ValidatorsCount">,
                                      SequenceView<
                                          ValidatorKeys,
                                          ViewOf<ValidatorKeys, { bandersnatch: ...; ed25519: ... }>,
                                      >,
                                  >;
                              },
                          >
                          | null,
                  >;
                  extrinsicHash: Descriptor<
                      Bytes<32> & pvm.WithOpaque<"ExtrinsicHash">,
                      Bytes<32>,
                  >;
                  offendersMarker: Descriptor<
                      (Bytes<32> & pvm.WithOpaque<"Ed25519Key">)[],
                      SequenceView<Bytes<32> & pvm.WithOpaque<"Ed25519Key">, Bytes<32>>,
                  >;
                  parentHeaderHash: Descriptor<
                      Bytes<32> & pvm.WithOpaque<"HeaderHash">,
                      Bytes<32>,
                  >;
                  priorStateRoot: Descriptor<
                      Bytes<32> & pvm.WithOpaque<"StateRootHash">,
                      Bytes<32>,
                  >;
                  seal: Descriptor<
                      Bytes<96> & pvm.WithOpaque<"BandersnatchVrfSignature">,
                      Bytes<96>,
                  >;
                  ticketsMarker: Descriptor<
                      TicketsMarker
                      | null,

                          | ViewOf<
                              TicketsMarker,
                              {
                                  tickets: Descriptor<
                                      readonly Ticket[] & pvm.WithOpaque<"EpochLength">,
                                      SequenceView<Ticket, ViewOf<Ticket, { attempt: ...; id: ... }>>,
                                  >;
                              },
                          >
                          | null,
                  >;
                  timeSlotIndex: Descriptor<
                      number & WithBytesRepresentation<4> & pvm.WithOpaque<"TimeSlot[u32]">,
                      Bytes<4>,
                  >;
              },
          >
          | null

    • Insert and flush a new block into the database.

      Parameters

      • block: WithHash<
            OpaqueHash & pvm.WithOpaque<"HeaderHash">,
            ViewOf<
                Block,
                {
                    extrinsic: Descriptor<
                        Extrinsic,
                        ViewOf<
                            Extrinsic,
                            {
                                assurances: Descriptor<
                                    readonly AvailabilityAssurance[] & pvm.WithOpaque<
                                        "[0 .. ValidatorsCount)",
                                    >,
                                    SequenceView<
                                        AvailabilityAssurance,
                                        ViewOf<
                                            AvailabilityAssurance,
                                            {
                                                anchor: Descriptor<(...), (...)>;
                                                bitfield: Descriptor<(...), (...)>;
                                                signature: Descriptor<(...), (...)>;
                                                validatorIndex: Descriptor<(...), (...)>;
                                            },
                                        >,
                                    >,
                                >;
                                disputes: Descriptor<
                                    DisputesExtrinsic,
                                    ViewOf<
                                        DisputesExtrinsic,
                                        {
                                            culprits: Descriptor<(...)[], SequenceView<(...), (...)>>;
                                            faults: Descriptor<(...)[], SequenceView<(...), (...)>>;
                                            verdicts: Descriptor<(...)[], SequenceView<(...), (...)>>;
                                        },
                                    >,
                                >;
                                guarantees: Descriptor<
                                    readonly ReportGuarantee[] & pvm.WithOpaque<"[0..CoresCount)">,
                                    SequenceView<
                                        ReportGuarantee,
                                        ViewOf<
                                            ReportGuarantee,
                                            {
                                                credentials: Descriptor<(...), (...)>;
                                                report: Descriptor<(...), (...)>;
                                                slot: Descriptor<(...), (...)>;
                                            },
                                        >,
                                    >,
                                >;
                                preimages: Descriptor<
                                    Preimage[],
                                    SequenceView<
                                        Preimage,
                                        ViewOf<
                                            Preimage,
                                            {
                                                blob: Descriptor<(...), (...)>;
                                                requester: Descriptor<(...), (...)>;
                                            },
                                        >,
                                    >,
                                >;
                                tickets: Descriptor<
                                    readonly SignedTicket[] & pvm.WithOpaque<
                                        "Size: [0..chainSpec.maxTicketsPerExtrinsic)",
                                    >,
                                    SequenceView<
                                        SignedTicket,
                                        ViewOf<
                                            SignedTicket,
                                            {
                                                attempt: Descriptor<(...), (...)>;
                                                signature: Descriptor<(...), (...)>;
                                            },
                                        >,
                                    >,
                                >;
                            },
                        >,
                    >;
                    header: Descriptor<
                        Header & CodecRecord<Header>,
                        ViewOf<
                            Header & CodecRecord<Header>,
                            {
                                bandersnatchBlockAuthorIndex: Descriptor<
                                    number & WithBytesRepresentation<2> & pvm.WithOpaque<
                                        "ValidatorIndex[u16]",
                                    >,
                                    Bytes<2>,
                                >;
                                entropySource: Descriptor<
                                    Bytes<96> & pvm.WithOpaque<"BandersnatchVrfSignature">,
                                    Bytes<96>,
                                >;
                                epochMarker: Descriptor<
                                    EpochMarker
                                    | null,

                                        | ViewOf<
                                            EpochMarker,
                                            {
                                                entropy: Descriptor<(...), (...)>;
                                                ticketsEntropy: Descriptor<(...), (...)>;
                                                validators: Descriptor<(...), (...)>;
                                            },
                                        >
                                        | null,
                                >;
                                extrinsicHash: Descriptor<
                                    Bytes<32> & pvm.WithOpaque<"ExtrinsicHash">,
                                    Bytes<32>,
                                >;
                                offendersMarker: Descriptor<
                                    (Bytes<32> & pvm.WithOpaque<"Ed25519Key">)[],
                                    SequenceView<Bytes<32> & pvm.WithOpaque<"Ed25519Key">, Bytes<32>>,
                                >;
                                parentHeaderHash: Descriptor<
                                    Bytes<32> & pvm.WithOpaque<"HeaderHash">,
                                    Bytes<32>,
                                >;
                                priorStateRoot: Descriptor<
                                    Bytes<32> & pvm.WithOpaque<"StateRootHash">,
                                    Bytes<32>,
                                >;
                                seal: Descriptor<
                                    Bytes<96> & pvm.WithOpaque<"BandersnatchVrfSignature">,
                                    Bytes<96>,
                                >;
                                ticketsMarker: Descriptor<
                                    TicketsMarker
                                    | null,
                                    ViewOf<TicketsMarker, { tickets: Descriptor<(...), (...)> }> | null,
                                >;
                                timeSlotIndex: Descriptor<
                                    number & WithBytesRepresentation<4> & pvm.WithOpaque<
                                        "TimeSlot[u32]",
                                    >,
                                    Bytes<4>,
                                >;
                            },
                        >,
                    >;
                },
            >,
        >

      Returns Promise<void>

    • Create new InMemoryBlocks and insert all given blocks.

      Parameters

      • previousBlocks: WithHash<
            OpaqueHash & pvm.WithOpaque<"HeaderHash">,
            ViewOf<
                Block,
                {
                    extrinsic: Descriptor<
                        Extrinsic,
                        ViewOf<
                            Extrinsic,
                            {
                                assurances: Descriptor<
                                    readonly AvailabilityAssurance[] & pvm.WithOpaque<
                                        "[0 .. ValidatorsCount)",
                                    >,
                                    SequenceView<
                                        AvailabilityAssurance,
                                        ViewOf<
                                            AvailabilityAssurance,
                                            { anchor: ...; bitfield: ...; signature: ...; validatorIndex: ... },
                                        >,
                                    >,
                                >;
                                disputes: Descriptor<
                                    DisputesExtrinsic,
                                    ViewOf<
                                        DisputesExtrinsic,
                                        {
                                            culprits: Descriptor<(...), (...)>;
                                            faults: Descriptor<(...), (...)>;
                                            verdicts: Descriptor<(...), (...)>;
                                        },
                                    >,
                                >;
                                guarantees: Descriptor<
                                    readonly ReportGuarantee[] & pvm.WithOpaque<"[0..CoresCount)">,
                                    SequenceView<
                                        ReportGuarantee,
                                        ViewOf<
                                            ReportGuarantee,
                                            { credentials: ...; report: ...; slot: ... },
                                        >,
                                    >,
                                >;
                                preimages: Descriptor<
                                    Preimage[],
                                    SequenceView<
                                        Preimage,
                                        ViewOf<Preimage, { blob: ...; requester: ... }>,
                                    >,
                                >;
                                tickets: Descriptor<
                                    readonly SignedTicket[] & pvm.WithOpaque<
                                        "Size: [0..chainSpec.maxTicketsPerExtrinsic)",
                                    >,
                                    SequenceView<
                                        SignedTicket,
                                        ViewOf<SignedTicket, { attempt: ...; signature: ... }>,
                                    >,
                                >;
                            },
                        >,
                    >;
                    header: Descriptor<
                        Header & CodecRecord<Header>,
                        ViewOf<
                            Header & CodecRecord<Header>,
                            {
                                bandersnatchBlockAuthorIndex: Descriptor<
                                    number & WithBytesRepresentation<2> & pvm.WithOpaque<
                                        "ValidatorIndex[u16]",
                                    >,
                                    Bytes<2>,
                                >;
                                entropySource: Descriptor<
                                    Bytes<96> & pvm.WithOpaque<"BandersnatchVrfSignature">,
                                    Bytes<96>,
                                >;
                                epochMarker: Descriptor<
                                    EpochMarker
                                    | null,

                                        | ViewOf<
                                            EpochMarker,
                                            { entropy: ...; ticketsEntropy: ...; validators: ... },
                                        >
                                        | null,
                                >;
                                extrinsicHash: Descriptor<
                                    Bytes<32> & pvm.WithOpaque<"ExtrinsicHash">,
                                    Bytes<32>,
                                >;
                                offendersMarker: Descriptor<
                                    (Bytes<(...)> & pvm.WithOpaque<(...)>)[],
                                    SequenceView<Bytes<(...)> & pvm.WithOpaque<(...)>, Bytes<32>>,
                                >;
                                parentHeaderHash: Descriptor<
                                    Bytes<32> & pvm.WithOpaque<"HeaderHash">,
                                    Bytes<32>,
                                >;
                                priorStateRoot: Descriptor<
                                    Bytes<32> & pvm.WithOpaque<"StateRootHash">,
                                    Bytes<32>,
                                >;
                                seal: Descriptor<
                                    Bytes<96> & pvm.WithOpaque<"BandersnatchVrfSignature">,
                                    Bytes<96>,
                                >;
                                ticketsMarker: Descriptor<
                                    TicketsMarker
                                    | null,
                                    ViewOf<TicketsMarker, { tickets: ... }> | null,
                                >;
                                timeSlotIndex: Descriptor<
                                    number & WithBytesRepresentation<4> & pvm.WithOpaque<
                                        "TimeSlot[u32]",
                                    >,
                                    Bytes<4>,
                                >;
                            },
                        >,
                    >;
                },
            >,
        >[]

      Returns InMemoryBlocks