Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

warp-contracts-lmdb

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warp-contracts-lmdb

Lmdb database for Warp Contracts SDK

  • 1.0.4
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-90.48%
Maintainers
1
Weekly downloads
 
Created
Source

Warp Contracts Lmdb Cache

Warp Contracts implementation of the SortKeyCache using the LMDB database. Compatible only in node env.

Usage

const warp = WarpFactory
  .custom(arweave, cacheOptions, 'mainnet', new LmdbCache({
    ...cacheOptions,
    dbLocation: `./cache/warp/lmdb-2/contracts`
  }))
  .useWarpGateway(defaultWarpGwOptions, defaultCacheOptions,)
  .build();
  1. yarn install
  2. yarn build

Running node - Docker

DEN docker images are deployed to dockerhub. In order to run node locally:

  1. create a folder (e.g. .secrets) with wallet.json file inside - Arweave JSON Web Key (JWK)
  2. create a folder that will store the sqlite database file (e.g. .db)

To start the node, run the following command:

docker run -t -d -p <host_port>:<container_port> \
-v <path_to_db_dir>:/app/dist/.db \
-v <path_to_jwk_dir>:/app/dist/.secrets warpredstone/den:<version> \
--url='<public_address>' --port=<container_port> --testnet='<is_testnet>' \
--networkId='<network_id>' --networkContractId='<network_contract_id>'

where:

  1. host_port - TCP port on the Docker host
  2. container_port - TCP port in the Docker container - the port the node is listening for the requests, e.g. 8080.
  3. path_to_jwk_dir - path to a folder where wallet.json file is stored (e.g. .secrets)
  4. version - DEN docker image version (e.g. 1.0.8). Check latest available version on dockerhub.
  5. public_address - node's public address, e.g.: http://138.197.7.53
  6. is_testnet - whether network is working in a public RedStone testnet or Arweave mainnet
  7. network_id - DEN id, e.g. redstone_network
  8. network_contract_id - contract tx id that this network is registered in (e.g. FxjoXsxQyuknaqaCV2Si7sq0TF3taBb8uTRmXmC6FQs - SonAR)

Full example:

docker run -t -d -p 8080:8080 \
-v /home/den/.db:/app/dist/.db \
-v /home/den/.secrets:/app/dist/.secrets warpredstone/den:1.0.8 \
--url="http://134.209.84.136" --port=8080 --testnet='false' \
--networkId='redstone_network' --networkContractId='FxjoXsxQyuknaqaCV2Si7sq0TF3taBb8uTRmXmC6FQs'

Endpoints

  1. /ehlo
http://<public_address>:<host_port>/ehlo

e.g. http://134.209.84.136:8080/ehlo

This endpoint returns some basic info about a node:

  • the DEN contract, that it is using (e.g. FxjoXsxQyuknaqaCV2Si7sq0TF3taBb8uTRmXmC6FQs)
  • the network, that the node is connected to (e.g. redstone_network)
  • the contracts, that are evaluated by this network
  • the list of other nodes connected to network
  • current Snowball consensus params
  • node's address, wallet address, etc.
  1. /state
http://<public_address>:<host_port>/state?id=<contract_id>

e.g. http://134.209.84.136:8080/state?id=KT45jaf8n9UwgkEareWxPgLJk4oMWpI5NODgYVIF1fY

This endpoint returns the current state of the contract of id passed in the id query params and some additional data from the Snowball rounds (all the responses from all the nodes that took part in a given round). Each response from the node contains its signature.

In order to verify the signature of a given node

  1. Compute a deepHash of [stateHash, signature.owner], e.g.:
const sigData = await deepHash([
    arweave.utils.stringToBuffer(data.hash),
    arweave.utils.stringToBuffer(data.signature.owner)
]);
  1. Verify the signature:
const verified = await arweave.crypto.verify(
    data.signature.owner,
    sigData,
    data.signature.sig
);

This endpoint also returns info about the network height, at which the state was evaluated, the last evaluated transaction id and amount of evaluated interactions.

  1. /state with validity:
http://<public_address>:<host_port>/state?id=<contract_id>&validity=true

Same as in point 2., but also returns validity. This might affect response times for contracts with several thousands of interactions.

e.g. http://134.209.84.136:8080/state?id=pvudp_Wp8NMDJR6KUsQbzJJ27oLO4fAKXsnVQn86JbU

  1. /state without Snowball
http://<public_address>:<host_port>/state?id=<contract_id>&snowball=false

This allows to get the state evaluated by a given node, without running the Snowball. Should be used only if you fully trust given node.

e.g. http://134.209.84.136:8080/state?id=pvudp_Wp8NMDJR6KUsQbzJJ27oLO4fAKXsnVQn86JbU&snowball=false

DEN Contract

All DENs are registered within a SmartWeave contract (at the time of writing the contract id is FxjoXsxQyuknaqaCV2Si7sq0TF3taBb8uTRmXmC6FQs).

The contract gives an option to register/unregister contracts (by the given DEN operator), register nodes, change network's consensus params, etc.

In the future the staking/slashing features will be added.

Licensing

The primary license for RedStone Distributed Execution Network Node is the Business Source License 1.1 (BUSL-1.1), see LICENSE

FAQs

Package last updated on 06 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc