sinner

command module
v0.1.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: MIT Imports: 3 Imported by: 0

README

Sinner

Go Reference Go Report Card

Sinner tracks the message lifecycle for the synapse interchain network.

Scope

While this applications goal is to encompass the full range of events sent through SIN, the initial scope is much smaller & pragmatically focused on developers building on SIN & the developent of the off-chain protocols itself. To that end, at a high level the goal of the application is to track the message through the following stages. Completed types are contained in the table below:

Config:

Example Indexer Config:

default_refresh_rate: 1
scribe_url: "http://scribe.com/graphql"
db_path: "/tmp/a.db"
db_type: sqlite
skip_migrations: false
chains:
  - chain_id: 444
    contracts:
      - address: "0x537ab51470984D6D9aDF8953C0D2ed8eDA4050ED"
        start_block: 1
        contract_type: origin
      - address: "0xA944636Ac279e0346AF96Ef7e236025C6cBFE609"
        start_block: 1
        contract_type: execution_hub
  - chain_id: 421614
    contracts:
      - address: "0x537ab51470984D6D9aDF8953C0D2ed8eDA4050ED"
        start_block: 1
        contract_type: origin
      - address: "0xA944636Ac279e0346AF96Ef7e236025C6cBFE609"
        start_block: 1
        contract_type: execution_hub
  - chain_id: 11155111
    contracts:
      - address: "0x537ab51470984D6D9aDF8953C0D2ed8eDA4050ED"
        start_block: 1
        contract_type: origin
      - address: "0xA944636Ac279e0346AF96Ef7e236025C6cBFE609"
        start_block: 1
        contract_type: execution_hub

Example Server Config

http_port: 8080
db_path: "/tmp/a.db"
db_type: sqlite
skip_migrations: true

If running the unified command, the config will be a combination of the above two configs (simply add the http_port to the top of your indexer config).

Message Stages
  1. Message sent on origin chain.
  2. At least one Guard submitted the snapshot for the origin chain taken after the message was sent.
  3. At least one Notary submitted the snapshot for the origin chain taken after the message was sent.
  4. Attestation created from any of the (3) snapshots was submitted to the destination chain.
  5. Optimistic period for the message has passed (awaiting the execution).
  6. An Executor tried to execute the message, but the destination app reverted (awaiting the retry).
  7. An Executor successfully executed the message.
Tracked Events & States

Note: the above only reflects progress in tracking message states in Sinner, not the agents

  1. Origin on origin chain emits an event for every sent message.
  • event Sent(bytes32 indexed messageHash, uint32 indexed nonce, uint32 indexed destination, bytes message);
  1. Summit on Synapse Chain emits an event for every state in the Guard snapshot that was submitted.
  • event StateSaved(bytes state);
  • We are interested in the states that have:
    • Origin domain matching the origin domain of the message.
    • Nonce higher or equal as the nonce of the message.
  1. Inbox on Synapse Chain emits an event for every snapshot that was submitted (both Guard and Notary).
  • event SnapshotAccepted(uint32 indexed domain, address indexed agent, bytes snapPayload, bytes snapSignature)
  • We are only interested in Notary snapshots, so domain != 0.
    • Notary domain could be different from the origin domain of the message, that's fine.
  • snapPayload is a concatenation of encoded states. We are interested in the states that have:
    • Origin domain matching the origin domain of the message.
    • Nonce higher or equal as the nonce of the message.
  • In the same transaction Summit emits an event with the created attestation: - event AttestationSaved(bytes attestation);

In other words, the submitted Guard/Notary snapshot "enables" messages coming from the set of origin domains (matching the domains of the states) with nonce less or equal to the nonce of the submitted state for the origin domain.

  1. LightInbox on the destination chain emits an event for every submitted attestation.
  • event AttestationAccepted(uint32 domain, address notary, bytes attPayload, bytes attSignature);
  • We are only interested in the attestation with payload matching any of the attestations from (3).
  • Optimistic period for the message starts when the first suitable attestation is submitted.
  1. This could be tracked by checking the timestamp of the last mined destination block, no events needed.
  2. Destination emits the event whenever an Executor tries to execute the message.
  • event Executed(uint32 indexed remoteDomain, bytes32 indexed messageHash, bool success);
  • We are only interested in the events that have:
    • remoteDomain matching the origin domain of the message.
    • messageHash matching the hash of the message (emitted in (1)).
    • success equal to false.
  • These "failed" messages could be later retried by any Executor.
  1. Destination emits the event whenever an Executor successfully executes the message.
  • event Executed(uint32 indexed remoteDomain, bytes32 indexed messageHash, bool success);
  • We are only interested in the events that have:
    • remoteDomain matching the origin domain of the message.
    • messageHash matching the hash of the message (emitted in (1)).
    • success equal to true.
  • The executed message could not be retried anymore.

Documentation

Overview

Package main provides the main entry point for the sinner service.

Directories

Path Synopsis
Package api contains the api used by sinner
Package api contains the api used by sinner
Package cmd CLI infra
Package cmd CLI infra
Package config holds the config for both the server and indexer.
Package config holds the config for both the server and indexer.
indexer
Package indexerconfig is the config loader for the indexer
Package indexerconfig is the config loader for the indexer
server
Package serverconfig is the config loader for the server
Package serverconfig is the config loader for the server
Package contracts holds all the contracts and their parsers.
Package contracts holds all the contracts and their parsers.
destination
Package destination is the execution hub contract parser.
Package destination is the execution hub contract parser.
origin
Package origin is the origin contract parser.
Package origin is the origin contract parser.
db
Package db implements the data store
Package db implements the data store
model
Package model holds all the models for the database.
Package model holds all the models for the database.
sql
Package sql provides a datastore implementation for the executor.
Package sql provides a datastore implementation for the executor.
sql/base
Package base contains the base sql implementation
Package base contains the base sql implementation
sql/mysql
Package mysql implements the mysql package
Package mysql implements the mysql package
sql/sqlite
Package sqlite implements the sqlite package
Package sqlite implements the sqlite package
Package fetcher gets data from scribe.
Package fetcher gets data from scribe.
client
Package client provides a GraphQL client for consuming logs.
Package client provides a GraphQL client for consuming logs.
client/contrib
Package main generates a GQL client.
Package main generates a GQL client.
client/model
Package model defines models returned by the graphql server
Package model defines models returned by the graphql server
client/resolver
Package resolvers resolves data from gqlgen
Package resolvers resolves data from gqlgen
client/types
Package types provides the GraphQL types for the Scribe service.
Package types provides the GraphQL types for the Scribe service.
graphql
contrib/client
generate gql schema
generate gql schema
server
Package server provides the GraphQL server.
Package server provides the GraphQL server.
server/graph
Package graph implements the GraphQL schema and resolvers.
Package graph implements the GraphQL schema and resolvers.
server/graph/resolver
Package resolvers provides the GraphQL resolver for the explorer service.
Package resolvers provides the GraphQL resolver for the explorer service.
Package logger handles logging various sinner events and errors.
Package logger handles logging various sinner events and errors.
Package metadata provides a metadata service for sinner.
Package metadata provides a metadata service for sinner.
Package service is the sinner service.
Package service is the sinner service.
Package types holds supplemental types for sinner.
Package types holds supplemental types for sinner.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL