Giter Site home page Giter Site logo

o1-labs / archive-node-api Goto Github PK

View Code? Open in Web Editor NEW
15.0 15.0 4.0 524 KB

This is a GraphQL server that is built with the intention of exposing information from Mina's Archive Node

TypeScript 88.36% Shell 9.98% Dockerfile 0.61% JavaScript 1.06%

archive-node-api's People

Contributors

martinminkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

staketab

archive-node-api's Issues

[BUG] Returning incorrect events

Given the following transaction:
https://berkeley.minaexplorer.com/transaction/5JtsLnRiszbYZLHfELTN8RMn841yN81FZbro5sJF5QYtvfkknThC

The following query returns incorrect events:

{
  events(
    input: {address: "B62qk6bVJYmHzQHp8xyKKVsb6MBYEQndeXCRvcRGW2NKqEHjqRb6gyD", from: 281, to: 281}
  ) {
    blockInfo {
      distanceFromMaxBlockHeight
      height
      globalSlotSinceGenesis
      stateHash
      parentHash
      chainStatus
    }
    eventData {
      data
      transactionInfo {
        hash
        memo
        status
      }
    }
  }
}

Not sure if a similar issue exists with actions as well. Need to investigate.

Inconsistent sorting of results

The results of actions/events do not always match the order of the transaction. It is also inconsistent when applying various filters.

query getActions {
  actions(
    input: {address: "B62qq1miZzh8QMumJ2dhJSvPxdeShGQ2G2cH4YXwxNLpPSvKdRVTb3q" }
  ) {
    actionData {
      data
    }
  }
}

This query returns the data out of order:

{
  "data": {
    "actions": [
      {
        "actionData": [
          {
            "data": [
              "22"
            ]
          },
          {
            "data": [
              "20"
            ]
          },
          {
            "data": [
              "19"
            ]
          },
          {
            "data": [
              "18"
            ]
          },
          {
            "data": [
              "17"
            ]
          },
          {
            "data": [
              "16"
            ]
          },
          {
            "data": [
              "15"
            ]
          },
          {
            "data": [
              "14"
            ]
          },
          {
            "data": [
              "13"
            ]
          },
          {
            "data": [
              "12"
            ]
          },
          {
            "data": [
              "11"
            ]
          },
          {
            "data": [
              "10"
            ]
          },
          {
            "data": [
              "9"
            ]
          },
          {
            "data": [
              "8"
            ]
          },
          {
            "data": [
              "21"
            ]
          },
          {
            "data": [
              "7"
            ]
          }
        ]
      },

However, adding additional filtering returns the data as ordered in the actual transaction:

query getActions {
  actions(
    input: {address: "B62qq1miZzh8QMumJ2dhJSvPxdeShGQ2G2cH4YXwxNLpPSvKdRVTb3q", from: 2500, to: 2500 }
  ) {
    actionData {
      data
    }
  }
}

Add Action State to actions resolver

Description

While implementing actions, the actions state was overlooked as part of the integration with SnarkyJS. We should add field to the Actions resolver that returns the action state from an account update after applying a list of actions.

Archive Node API POS Testing

This epic aims to ensure the consistent implementation of the proof of stake selection algorithm for blocks at the highest tip across both our main Mina client and the Archive Node API server. The ongoing work referenced in this pull request represents a small segment of this process.

The concern is keeping both implementations synchronized and compatible, which we plan to validate through a differential test comparing both software pieces. This epic captures the sequence of tasks necessary to reach this objective.

Tasks Involved

  • Write a Technical Specification: This involves the preparation of a detailed technical document outlining our proposed approach to the implementation.
  • Implement Changes in the OCaml Client: Apply the required modifications to the OCaml client to adapt it to our approach.
  • Implement Changes for the Archive Node API Server: We will introduce necessary changes in the Archive Node API server.
  • Integration in CI Pipelines: Lastly, we'll incorporate this workflow into the relevant Continuous Integration (CI) pipelines, allowing for automated checks in the future.

By following this plan, we aim to maintain a synchronized and effective implementation of our algorithm across all relevant platforms.

This work is required for #80 to land.

Add sanity checks during the application startup

  • For later: it will be good to know from the app if it can be used with the connection string provided right after the startup:
    • Like add checks during/after the app startup:
      • if it is possible to connect to DB configured?
      • if current app is compatible with DB schema connected?
    • And notify users in terminal output if there are errors or all is good.

Allow .env usage

.env (git ignored) and .env.example (under version control) where you can specify defaults/examples instead of For an example of some sensible defaults, see below: README section.

Support different chain-tip selection methods

Suggestions to improve the best tip chain selection was made in a Discord channel, see here: https://discord.com/channels/484437221055922177/1086196859627917343/1087343997812486174

For those without Discord, the contents of the message are:

"
Potential options for the archive node api could be:
the latest finalized block by some num of confirmations n
the latest undisputed block (what I mean by that is that if there are multiple blocks proposed in a slot, the next proposer has selected a block out of those)
the latest unconfirmed block (for example the block in the latest filled slot with the lowest timestamp)
all blocks with the potential of becoming canonical

Doing it this way keeps the possibility of only retrieving confirmed data while also giving the developer the option to modify that behaviour if needed.
"

By supporting these different options, we can let the user define how they want to query the data for the Archive Node.

Add module for performance testing

Description

Add an easy-to-run module that will run some performance testing on the GraphQL server. The module should output a easy to read report of all metrics gathered when running the benchmarks

Incorrect default port in Readme

Server starts on port 8080 by default, not the 4000 as it is mentioned in Readme (it will be also good to mention the PORT envar configuration option).

[Bug] Events/Actions transaction information is incorrectly fetched

Description

Transaction Information related to events/actions are defined on the top level of the actions/events resolvers:

type EventOutput {

The GraphQL schema represents an invalid data format for events/actions. The way the GraphQL schema is defined, it implies that events/actions will always have the same transaction information in a block. But this is incorrect since events/actions can be dispatched from different zkApp transactions, which all get included in a single block. Right now, the Archive Node API, will look at the first transaction fetched from the Postgres DB and assume that that transaction emitted all events/actions under a block.

We will need to fix the transaction information to be related to individual emitted actions/events since they can all have different transaction information related to a block.

Fix Boolean env vars parsing

By default any non-empty string env var in condition like this if (process.env.VAR) { will be parsed into boolean: true. So we need to check against another string if (process.env.VAR === 'true') {.

Add a testing plan

Description

We should add a plan on how to test the server accurately. Currently, this is left out of the RFC, but @shimkiv has graciously voluntureed to come up with some ideas. Once a formal plan is in place, it should be added to the RFC.

Related issue: #9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.