1.3.5 • Published 2 years ago

@kyve/core v1.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Integrations

In order to archive data with KYVE protocol nodes have to run on a storage pool. Every protocol node runs on a runtime which defines how data is being retrieved and how data is being validated. A runtime is just the execution environment for a integration.

Creating a custom integration

Everybody can create a custom integration. For that it is highly recommended to use this package to ensure no unexpected behaviour occurs.

Installation

yarn add @kyve/core

Implement interface IRuntime

The interface IRuntime defines how a runtime needs to be implemented. It has three main methods which need to be implemented. Explanations in detail can be found on the interface itself in the form of comments (src/types/interfaces.ts).

An example implementation of the EVM runtime can be found here:

import { DataItem, IRuntime, Node } from "@kyve/core";
import { providers } from "ethers";

export default class EVM implements IRuntime {
  public name = "@kyve/evm";
  public version = "1.0.0";

  // get block with transactions by height
  public async getDataItem(core: Node, key: string): Promise<DataItem> {
    try {
      // setup web3 provider
      const provider = new providers.StaticJsonRpcProvider({
        url: core.poolConfig.rpc,
      });

      // fetch data item
      const value = await provider.getBlockWithTransactions(+key);

      // throw if data item is not available
      if (!value) throw new Error();

      // Delete the number of confirmations from a transaction to keep data deterministic.
      value.transactions.forEach(
        (tx: Partial<providers.TransactionResponse>) => delete tx.confirmations
      );

      return {
        key,
        value,
      };
    } catch (error) {
      throw error;
    }
  }

  // increment block height by 1
  public async getNextKey(key: string): Promise<string> {
    return (parseInt(key) + 1).toString();
  }

  // save only the hash of a block on KYVE chain
  public async formatValue(value: any): Promise<string> {
    return value.hash;
  }
}

Build your custom integration

Having the runtime implemented the final steps now are choosing suitable prebuild modules for your integration. There are three core features which need to be defined:

Storage Provider

The storage provider is basically the harddrive of KYVE. It saves all the data a bundle has and should be web 3 by nature. Current supported storage providers are:

Compression

The compression type should also be chosen carefully. Each bundle saved on the storage provider gets compressed and decompressed by this algorithm. Current supported compression types are:

  • NoCompression
  • Gzip (recommended)

Cache

The cache of an integration is responsible for precaching data, making data archival much faster. Current supported caches are:

  • JsonFileCache (recommended)

After settling on certain modules the integration can just be built together and started. An example from the EVM integration can be found here:

import { Node, Arweave, Gzip, JsonFileCache } from "@kyve/core";

import EVM from "./runtime";

new Node()
  .addRuntime(new EVM())
  .addStorageProvider(new Arweave())
  .addCompression(new Gzip())
  .addCache(new JsonFileCache())
  .start();

Contributing

To contribute to this repository please follow these steps:

  1. Clone the repository
    git clone git@github.com:KYVENetwork/core.git
  2. Install dependencies
    yarn install
1.2.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.4

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.3

2 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.0-alpha.35

3 years ago

0.0.0-alpha.39

3 years ago

0.0.0-alpha.38

3 years ago

0.0.0-alpha.37

3 years ago

0.0.0-alpha.36

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.0-alpha.34

3 years ago

0.0.0-alpha.33

3 years ago

0.0.0-alpha.31

3 years ago

0.0.0-alpha.30

3 years ago

0.0.0-alpha.32

3 years ago

0.0.0-alpha.29

3 years ago

0.0.0-alpha.28

3 years ago

0.0.0-alpha.27

3 years ago

0.0.0-alpha.26

3 years ago

0.0.0-alpha.24

3 years ago

0.0.0-alpha.23

3 years ago

0.0.0-alpha.22

3 years ago

0.0.0-alpha.21

3 years ago

0.0.0-alpha.25

3 years ago

0.0.0-alpha.20

3 years ago

0.0.0-alpha.19

3 years ago

0.0.0-alpha.18

3 years ago

0.0.0-alpha.17

3 years ago

0.0.0-alpha.16

3 years ago

0.0.0-alpha.15

3 years ago

0.0.0-alpha.13

3 years ago

0.0.0-alpha.14

3 years ago

0.0.0-alpha.12

3 years ago

0.0.0-alpha.11

3 years ago

0.0.0-alpha.10

3 years ago

0.0.0-alpha.9

3 years ago

0.0.0-alpha.8

3 years ago

0.0.0-alpha.7

3 years ago

0.0.0-alpha.6

3 years ago

0.0.0-alpha.5

3 years ago

0.0.0-alpha.4

3 years ago

0.0.0-alpha.3

3 years ago

0.0.0-alpha.2

3 years ago