This document describes some of the concepts and details the services of the Audit protocol. It is highly recommended to use the dockerized installation to run the project instead of manually running all the services.
The project consists of the following services:
- A project in Audit-protocol can be any contract (like UniswapV2 pair contract) or aggregate of multiple such contracts.
- Each snapshot is specific to a project
- EpochID represents an identifier for each generated epoch, stored on the smart contract.
- EpochID starts with 1 for the first epoch and increments by 1 for each generated epoch
- Size of each epoch is configured on the smart contract.
The payload commit service has the following functionalities:
- Listens to Rabbitmq "Snapshot Commit" messages.
- Store the snapshot on IPFS and/web3.storage (based on configuration).
- stores cid from IPFS and web3.storage in Redis cache for the given project at provided epochID.
- Creates EIP-712 based structured data hash and generates the signature.
- Submits the signature to the relayer (if configured) otherwise submits snapshot to the smart contract.
- Listens for "snapshot finalized" event on Rabbitmq
- if finalized snapshot for a given project against an epochId has the same SnapshotCID as stored in Redis cache
- store snapshot in local_disk cache
- if finalized SnapshotCID is different, fetch finalized snapshot from IPFS and store in local disk cache
- if finalized snapshot for a given project against an epochId has the same SnapshotCID as stored in Redis cache
- Generates Snapshotter report
Call Flow for payload-commit service
Code for this service is located at payload-commit
The pruning service has the following high-level functionalities:
- Runs as a cron job for every configured interval (default every day)
- Unpins IPFS CIDs of snapshots stored in the local disk for more than configured value (default 7 days)
Call Flow for pruning service
Code for this service is located at pruning
Golang Code is present in go folder and has been structured as below. Common utils that are used by multiple Golang services are available in goutils. Below are list of utils
- caching - Generic caching interface
- logger - Logger initialization and setup code
- redisutils - Redis client initialization and common operations wrapper code
- settings - Parsing the settings and settings defaults
- slackutils - Code to interact with slack workflow
- datamodel - Data models used across services
- ipfsutils - IPFS client initialization and common functionality
- w3s - Web3 storage client initialization and common functionality
- health - Health check listener
- taskmgr - Generic interface for task manager presently only has Rabbitmq task manager
- smartcontract - Smart contract api