Skip to content

Commit

Permalink
Merge branch 'main' into 861-fix-batcher-nonce-verification-order-in-…
Browse files Browse the repository at this point in the history
…handle_message-function

# Conflicts:
#	batcher/aligned-batcher/src/lib.rs
  • Loading branch information
NicolasRampoldi committed Sep 4, 2024
2 parents ea00344 + c6d8459 commit 6446270
Show file tree
Hide file tree
Showing 120 changed files with 4,899 additions and 1,298 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/explorer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
ssh -o "StrictHostKeyChecking=no" ${USERNAME}@${HOST_NAME} "
cd ${APP_DIR} &&
git fetch &&
git reset --hard HEAD &&
git clean -fd &&
git checkout ${REF} &&
git pull &&
sudo systemctl restart ${SERVICE_NAME}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/lint-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Lint contracts
on:
push:
branches: [main]
pull_request:
branches: ["*"]
paths:
- "contracts/src/core/*.sol"
- ".github/workflows/lint-contracts.yml"

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install dependencies
run: npm install
working-directory: contracts

- name: Run Solhint
run: npm run lint:sol
working-directory: contracts
25 changes: 17 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ anvil_upgrade_index_registry:
@echo "Upgrading Index Registry Contracts..."
. contracts/scripts/anvil/upgrade_index_registry.sh

lint_contracts:
@cd contracts && npm run lint:sol

anvil_start:
@echo "Starting Anvil..."
anvil --load-state contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json
Expand Down Expand Up @@ -441,6 +444,12 @@ upgrade_batcher_payment_service:
build_aligned_contracts:
@cd contracts/src/core && forge build

show_aligned_error_codes:
@echo "\nAlignedLayerServiceManager errors:"
@cd contracts/src/core && forge inspect IAlignedLayerServiceManager.sol:IAlignedLayerServiceManager errors
@echo "\nBatcherPaymentService errors:"
@cd contracts/src/core && forge inspect BatcherPaymentService.sol:BatcherPaymentService errors

__BUILD__:
build_binaries:
@echo "Building aggregator..."
Expand Down Expand Up @@ -616,39 +625,39 @@ build_all_ffi_linux: ## Build all FFIs for Linux


__EXPLORER__:
run_explorer: run_db ecto_setup_db
run_explorer: explorer_run_db explorer_ecto_setup_db
@cd explorer/ && \
pnpm install --prefix assets && \
mix setup && \
./start.sh

build_db:
explorer_build_db:
@cd explorer && \
docker build -t explorer-postgres-image .

run_db: remove_db_container
explorer_run_db: explorer_remove_db_container
@cd explorer && \
docker run -d --name explorer-postgres-container -p 5432:5432 -v explorer-postgres-data:/var/lib/postgresql/data explorer-postgres-image

ecto_setup_db:
explorer_ecto_setup_db:
@cd explorer/ && \
./ecto_setup_db.sh

remove_db_container:
explorer_remove_db_container:
@cd explorer && \
docker stop explorer-postgres-container || true && \
docker rm explorer-postgres-container || true

clean_db: remove_db_container
explorer_clean_db: explorer_remove_db_container
@cd explorer && \
docker volume rm explorer-postgres-data || true

dump_db:
explorer_dump_db:
@cd explorer && \
docker exec -t explorer-postgres-container pg_dumpall -c -U explorer_user > dump.$$(date +\%Y\%m\%d_\%H\%M\%S).sql
@echo "Dumped database successfully to /explorer"

recover_db: run_db
explorer_recover_db: explorer_run_db
@read -p $$'\e[32mEnter the dump file to recover (e.g., dump.20230607_123456.sql): \e[0m' DUMP_FILE && \
cd explorer && \
docker cp $$DUMP_FILE explorer-postgres-container:/dump.sql && \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ If you want to run an operator, check our [Operator Guide](./docs/operator_guide
## Aligned Infrastructure Guide
If you are developing on Aligned, or want to run your own devnet, check our [setup Aligned guide](docs/guides/6_setup_aligned.md).
If you are developing on Aligned, or want to run your own devnet, check our [setup Aligned guide](docs/3_guides/6_setup_aligned.md).
## Submitting Proofs to Aligned
For submitting proofs generated by your own project to the network via CLI, see the documentation on [submitting proofs to Aligned](docs/guides/0_submitting_proofs.md).
For submitting proofs generated by your own project to the network via CLI, see the documentation on [submitting proofs to Aligned](docs/3_guides/0_submitting_proofs.md).
## Integrating Aligned into your Project
If you are developing applications using Aligned, we offer a [Rust-SDK](docs/guides/1_SDK.md) for submitting proofs directly to the network within your applications.
If you are developing applications using Aligned, we offer a [Rust-SDK](docs/3_guides/1_SDK_how_to.md) for submitting proofs directly to the network within your applications.
3 changes: 3 additions & 0 deletions alerts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ RPC_URL=<YOUR_RPC_URL>
CONTRACT_ADDRESS=<YOUR_CONTRACT_ADDRESS>
NEW_BATCH_TOPIC=<YOUR_NEW_BATCH_TOPIC>
VERIFIED_BATCH_TOPIC=<YOUR_VERIFIED_BATCH_TOPIC>
PAGER_DUTY_KEY=<YOUR_PAGER_DUTY_KEY>
PAGER_DUTY_EMAIL=<YOUR_PAGER_DUTY_EMAIL>
PAGER_DUTY_SERVICE_ID=<YOUR_PAGER_DUTY_SERVICE_ID>

# Variables for process_errors_alerts.sh
SERVICE=<YOUR_SERVICE>
Expand Down
8 changes: 8 additions & 0 deletions alerts/contract_alerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ function send_telegram_message() {
-d disable_notification=true
}

# Function to send PagerDuty alert
# @param message
function send_pagerduty_alert() {
. pagerduty.sh "$1"
}

# Flags to avoid sending multiple alerts
no_new_batches_alert=false
no_verified_batches_alert=false
Expand All @@ -38,6 +44,7 @@ do
message="🚨 ALERT: No new batches in Service Manager since block $from_block"
send_slack_message "$message"
send_telegram_message "$message"
send_pagerduty_alert "$message"
fi
no_new_batches_alert=true
else
Expand All @@ -57,6 +64,7 @@ do
message="🚨 ALERT: No verified batches in Service Manager since block $from_block"
send_slack_message "$message"
send_telegram_message "$message"
send_pagerduty_alert "$message"
fi
no_verified_batches_alert=true
else
Expand Down
16 changes: 16 additions & 0 deletions alerts/pagerduty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
curl --request POST -s \
--url https://api.pagerduty.com/incidents \
--header 'Accept: application/json' \
--header "Authorization: Token token=$PAGER_DUTY_KEY" \
--header 'Content-Type: application/json' \
--header "From: $PAGER_DUTY_EMAIL"\
--data "{
\"incident\": {
\"type\": \"incident\",
\"title\": \"$1\",
\"service\": {
\"id\": \"$PAGER_DUTY_SERVICE_ID\",
\"type\": \"service_reference\"
}
}
}"
12 changes: 12 additions & 0 deletions batcher/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions batcher/aligned-batcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.g
bincode = "1.3.3"
aligned-sdk = { path = "../aligned-sdk" }
ciborium = "=0.2.2"
priority-queue = "2.1.0"
38 changes: 28 additions & 10 deletions batcher/aligned-batcher/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,23 @@ const INITIAL_BACKOFF: u64 = 1000; // Initial backoff for the retry client in mi
const GAS_MULTIPLIER: f64 = 1.125; // Multiplier for the gas price for gas escalator
const GAS_ESCALATOR_INTERVAL: u64 = 12; // Time in seconds between gas escalations

#[derive(Debug, Clone)]
pub struct CreateNewTaskFeeParams {
pub fee_for_aggregator: U256,
pub fee_per_proof: U256,
pub gas_price: U256,
}

impl CreateNewTaskFeeParams {
pub fn new(fee_for_aggregator: U256, fee_per_proof: U256, gas_price: U256) -> Self {
CreateNewTaskFeeParams {
fee_for_aggregator,
fee_per_proof,
gas_price,
}
}
}

pub fn get_provider(eth_rpc_url: String) -> Result<Provider<RetryClient<Http>>, anyhow::Error> {
let provider = Http::from_str(eth_rpc_url.as_str())
.map_err(|e| anyhow::Error::msg(format!("Failed to create provider: {}", e)))?;
Expand Down Expand Up @@ -69,18 +86,19 @@ pub async fn try_create_new_task(
batch_data_pointer: String,
padded_leaves: Vec<[u8; 32]>,
signatures: Vec<SignatureData>,
gas_for_aggregator: U256,
gas_per_proof: U256,
fee_params: CreateNewTaskFeeParams,
payment_service: &BatcherPaymentService,
) -> Result<TransactionReceipt, BatcherSendError> {
let call = payment_service.create_new_task(
batch_merkle_root,
batch_data_pointer,
padded_leaves,
signatures,
gas_for_aggregator,
gas_per_proof,
);
let call = payment_service
.create_new_task(
batch_merkle_root,
batch_data_pointer,
padded_leaves,
signatures,
fee_params.fee_for_aggregator,
fee_params.fee_per_proof,
)
.gas_price(fee_params.gas_price);

info!("Creating task for: {}", hex::encode(batch_merkle_root));

Expand Down
Loading

0 comments on commit 6446270

Please sign in to comment.