Skip to content

Commit

Permalink
Merge branch 'staging' into 1082-add-a-bitmap-in-ethereum-to-disable-…
Browse files Browse the repository at this point in the history
…verifiers
  • Loading branch information
uri-99 committed Oct 18, 2024
2 parents 742563b + e06df5c commit 9438f62
Show file tree
Hide file tree
Showing 21 changed files with 305 additions and 53 deletions.
26 changes: 26 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# TITLE

## Description

Description of the pull request changes and motivation.

## Type of change

Please delete options that are not relevant.

- [ ] New feature
- [ ] Bug fix
- [ ] Optimization
- [ ] Refactor

## Checklist
- [ ] Linked to Github Issue
- [ ] This change depends on code or research by an external entity
- [ ] Acknowledgements were updated to give credit
- [ ] Unit tests added
- [ ] This change requires new documentation.
- [ ] Documentation has been added/updated.
- [ ] This change is an Optimization
- [ ] Benchmarks added/run
- [ ] Has a known issue
- [Link to the open issue addressing it]()
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ generate_groth16_ineq_proof: ## Run the gnark_plonk_bn254_script
@go run scripts/test_files/gnark_groth16_bn254_infinite_script/cmd/main.go 1

__METRICS__:
# Prometheus and graphana
run_metrics: ## Run metrics using metrics-docker-compose.yaml
@echo "Running metrics..."
@docker compose -f metrics-docker-compose.yaml up
Expand Down Expand Up @@ -698,6 +699,10 @@ tracker_dump_db:
@echo "Dumped database successfully to /operator_tracker"

__TELEMETRY__:
# Collector, Jaeger and Elixir API
telemetry_full_start: open_telemetry_start telemetry_start

# Collector and Jaeger
open_telemetry_start: ## Run open telemetry services using telemetry-docker-compose.yaml
@echo "Running telemetry..."
@docker compose -f telemetry-docker-compose.yaml up -d
Expand All @@ -706,6 +711,7 @@ open_telemetry_prod_start: ## Run open telemetry services with Cassandra using t
@echo "Running telemetry for Prod..."
@docker compose -f telemetry-prod-docker-compose.yaml up -d

# Elixir API
telemetry_start: telemetry_run_db telemetry_ecto_migrate ## Run Telemetry API
@cd telemetry_api && \
./start.sh
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,19 @@
> To be used in testnet only.
To learn more about Aligned and how to use it, refer to the [docs page](https://docs.alignedlayer.com/) or [docs folder](./docs/).

# Acknowledgements

Aligned wouldn't be possible without the valuable work of these people:
- [Ethereum](https://ethereum.org/en/), for being the network we all love
- [EigenLayer](https://www.eigenlayer.xyz) for providing restaking and AVS
- Shafi Goldwasser, Silvio Micali, and Charles Rackoff for [inventing ZK proofs](http://people.csail.mit.edu/silvio/Selected%20Scientific%20Papers/Proof%20Systems/The_Knowledge_Complexity_Of_Interactive_Proof_Systems.pdf)
- Eli Ben-Sasson and [Starkware](https://starkware.co) for making them practical
- [Consensys](https://consensys.io) for implementing the GROTH16 and PLONK protocols in [GNARK](https://docs.gnark.consensys.io)
- [RiscZero](https://risczero.com) for its namesake [proving system](https://github.com/risc0/risc0)
- [SuccintLabs](https://succinct.xyz) for creating [SP1](https://github.com/succinctlabs/sp1)
- [Paradigm](https://www.paradigm.xyz) for maintaining the [Ethers crate](https://crates.io/crates/ethers) and [Foundry](https://github.com/foundry-rs/foundry)
- [LambdaClass](https://lambdaclass.com) for writing [lambdaworks](https://github.com/lambdaclass/lambdaworks)


If you believe we missed someone, contact us! We're always happy to give credit where it's due.
36 changes: 16 additions & 20 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ use std::env;
use std::net::SocketAddr;
use std::sync::Arc;

use aligned_sdk::core::constants::{
ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF, AGGREGATOR_GAS_COST, CONSTANT_GAS_COST,
DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER, DEFAULT_MAX_FEE_PER_PROOF,
GAS_PRICE_PERCENTAGE_MULTIPLIER, MIN_FEE_PER_PROOF, PERCENTAGE_DIVIDER,
RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER,
};
use aligned_sdk::core::types::{
ClientMessage, NoncedVerificationData, ProofInvalidReason, ProvingSystemId, ResponseMessage,
ValidityResponseMessage, VerificationCommitmentBatch, VerificationData,
VerificationDataCommitment,
};

use aws_sdk_s3::client::Client as S3Client;
use eth::payment_service::{
try_create_new_task, BatcherPaymentService, CreateNewTaskFeeParams, SignerMiddlewareT,
Expand Down Expand Up @@ -48,20 +55,6 @@ pub mod sp1;
pub mod types;
mod zk_utils;

const AGGREGATOR_GAS_COST: u128 = 400_000;
const BATCHER_SUBMISSION_BASE_GAS_COST: u128 = 125_000;
pub(crate) const ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF: u128 = 13_000;
pub(crate) const CONSTANT_GAS_COST: u128 =
((AGGREGATOR_GAS_COST * DEFAULT_AGGREGATOR_FEE_MULTIPLIER) / DEFAULT_AGGREGATOR_FEE_DIVIDER)
+ BATCHER_SUBMISSION_BASE_GAS_COST;

const DEFAULT_MAX_FEE_PER_PROOF: u128 = ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * 100_000_000_000; // gas_price = 100 Gwei = 0.0000001 ether (high gas price)
const MIN_FEE_PER_PROOF: u128 = ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * 100_000_000; // gas_price = 0.1 Gwei = 0.0000000001 ether (low gas price)
const RESPOND_TO_TASK_FEE_LIMIT_MULTIPLIER: u128 = 5; // to set the respondToTaskFeeLimit variable higher than fee_for_aggregator
const RESPOND_TO_TASK_FEE_LIMIT_DIVIDER: u128 = 2;
const DEFAULT_AGGREGATOR_FEE_MULTIPLIER: u128 = 3; // to set the feeForAggregator variable higher than what was calculated
const DEFAULT_AGGREGATOR_FEE_DIVIDER: u128 = 2;

pub struct Batcher {
s3_client: S3Client,
s3_bucket_name: String,
Expand Down Expand Up @@ -1044,9 +1037,12 @@ impl Batcher {
}
}

if let Some(finalized_batch) = self.is_batch_ready(block_number, gas_price).await {
let modified_gas_price = gas_price * U256::from(GAS_PRICE_PERCENTAGE_MULTIPLIER)
/ U256::from(PERCENTAGE_DIVIDER);

if let Some(finalized_batch) = self.is_batch_ready(block_number, modified_gas_price).await {
let batch_finalization_result = self
.finalize_batch(block_number, finalized_batch, gas_price)
.finalize_batch(block_number, finalized_batch, modified_gas_price)
.await;

// Resetting this here to avoid doing it on every return path of `finalize_batch` function
Expand Down Expand Up @@ -1097,11 +1093,11 @@ impl Batcher {
let fee_per_proof = U256::from(gas_per_proof) * gas_price;
let fee_for_aggregator = (U256::from(AGGREGATOR_GAS_COST)
* gas_price
* U256::from(DEFAULT_AGGREGATOR_FEE_MULTIPLIER))
/ U256::from(DEFAULT_AGGREGATOR_FEE_DIVIDER);
* U256::from(DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER))
/ U256::from(PERCENTAGE_DIVIDER);
let respond_to_task_fee_limit = (fee_for_aggregator
* U256::from(RESPOND_TO_TASK_FEE_LIMIT_MULTIPLIER))
/ U256::from(RESPOND_TO_TASK_FEE_LIMIT_DIVIDER);
* U256::from(RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER))
/ U256::from(PERCENTAGE_DIVIDER);
let fee_params = CreateNewTaskFeeParams::new(
fee_for_aggregator,
fee_per_proof,
Expand Down
16 changes: 9 additions & 7 deletions batcher/aligned-sdk/src/core/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
pub const AGGREGATOR_GAS_COST: u128 = 400_000;
pub const BATCHER_SUBMISSION_BASE_GAS_COST: u128 = 125_000;
pub const ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF: u128 = 13_000;
pub const CONSTANT_GAS_COST: u128 = ((AGGREGATOR_GAS_COST * DEFAULT_AGGREGATOR_FEE_MULTIPLIER)
/ DEFAULT_AGGREGATOR_FEE_DIVIDER)
+ BATCHER_SUBMISSION_BASE_GAS_COST;
pub const CONSTANT_GAS_COST: u128 =
((AGGREGATOR_GAS_COST * DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER) / PERCENTAGE_DIVIDER)
+ BATCHER_SUBMISSION_BASE_GAS_COST;
pub const DEFAULT_MAX_FEE_PER_PROOF: u128 =
ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * 100_000_000_000; // gas_price = 100 Gwei = 0.0000001 ether (high gas price)
pub const MIN_FEE_PER_PROOF: u128 = ADDITIONAL_SUBMISSION_GAS_COST_PER_PROOF * 100_000_000; // gas_price = 0.1 Gwei = 0.0000000001 ether (low gas price)
pub const RESPOND_TO_TASK_FEE_LIMIT_MULTIPLIER: u128 = 5; // to set the respondToTaskFeeLimit variable higher than fee_for_aggregator
pub const RESPOND_TO_TASK_FEE_LIMIT_DIVIDER: u128 = 2;
pub const DEFAULT_AGGREGATOR_FEE_MULTIPLIER: u128 = 3; // to set the feeForAggregator variable higher than what was calculated
pub const DEFAULT_AGGREGATOR_FEE_DIVIDER: u128 = 2;

// % modifiers: (100% is x1, 10% is x0.1, 1000% is x10)
pub const RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER: u128 = 250; // fee_for_aggregator -> respondToTaskFeeLimit modifier
pub const DEFAULT_AGGREGATOR_FEE_PERCENTAGE_MULTIPLIER: u128 = 150; // feeForAggregator modifier
pub const GAS_PRICE_PERCENTAGE_MULTIPLIER: u128 = 110; // gasPrice modifier
pub const PERCENTAGE_DIVIDER: u128 = 100;

/// SDK ///
/// Number of proofs we a batch for estimation.
Expand Down
146 changes: 146 additions & 0 deletions grafana/provisioning/dashboards/aligned/ethereum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 4,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "gwei",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 3,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"lineWidth": 3,
"pointSize": 1,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"disableTextWrap": false,
"editorMode": "code",
"expr": "gas_price * 10^(-9)",
"fullMetaSearch": false,
"hide": false,
"includeNullMetadata": true,
"instant": false,
"legendFormat": "__auto",
"range": true,
"refId": "A",
"useBackend": false
}
],
"title": "Gas Price",
"type": "timeseries"
}
],
"refresh": "",
"schemaVersion": 38,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Ethereum",
"uid": "cc1ca6ab-6a36-41e0-afcf-2946c15afde5",
"version": 6,
"weekStart": ""
}
22 changes: 17 additions & 5 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"net/http"
"time"

"github.com/Layr-Labs/eigensdk-go/logging"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -48,12 +49,23 @@ func NewMetrics(ipPortAddress string, reg prometheus.Registerer, logger logging.
func (m *Metrics) Start(ctx context.Context, reg prometheus.Gatherer) <-chan error {
m.logger.Infof("Starting metrics server at port %v", m.ipPortAddress)
errC := make(chan error, 1)

server := http.Server{
Addr: m.ipPortAddress,
Handler: http.NewServeMux(),
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
MaxHeaderBytes: 1 << 20, // This is 1MB
}

server.Handler.(*http.ServeMux).Handle("/metrics", promhttp.HandlerFor(
reg,
promhttp.HandlerOpts{},
))

go func() {
http.Handle("/metrics", promhttp.HandlerFor(
reg,
promhttp.HandlerOpts{},
))
err := http.ListenAndServe(m.ipPortAddress, nil)
err := server.ListenAndServe()
if err != nil {
errC <- errors.New("prometheus server failed")
} else {
Expand Down
7 changes: 7 additions & 0 deletions prometheus/prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ scrape_configs:
- targets: [ "host.docker.internal:9093" ]
labels:
bot: "batcher"

- job_name: "aligned-tracker"
scrape_interval: 1s
static_configs:
- targets: [ "host.docker.internal:4001" ]
labels:
bot: "tracker"
3 changes: 2 additions & 1 deletion scripts/fund_operator_devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ cast send --from $sender_address \
--value $amount_in_eth \
--private-key $sender_private_key \
--rpc-url "http://localhost:8545" \
"$recipient_address"
"$recipient_address" \
--gas-price $(cast gas-price --rpc-url "http://localhost:8545")
3 changes: 2 additions & 1 deletion scripts/user_fund_payment_service_devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ cast send --from $USER_ADDRESS \
--value $amount_in_eth \
--private-key $USER_PRIVATE_KEY \
--rpc-url "http://localhost:8545" \
"$batcher_payment_service_address"
"$batcher_payment_service_address" \
--gas-price $(cast gas-price --rpc-url "http://localhost:8545")
7 changes: 4 additions & 3 deletions telemetry_api/.env.dev
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ALIGNED_CONFIG_FILE="../contracts/script/output/devnet/alignedlayer_deployment_output.json"
OPERATOR_FETCHER_WAIT_TIME_MS=5000
ENVIRONMENT=devnet
export ALIGNED_CONFIG_FILE="../contracts/script/output/devnet/alignedlayer_deployment_output.json"
export OPERATOR_FETCHER_WAIT_TIME_MS=5000
export ENVIRONMENT=devnet
export RPC_URL=http://localhost:8545
Loading

0 comments on commit 9438f62

Please sign in to comment.