Skip to content

Commit

Permalink
Merge branch 'staging' into 1309-improve-transaction-sending-api-usab…
Browse files Browse the repository at this point in the history
…ility-when-passing-nonce-and-max-fee
  • Loading branch information
avilagaston9 committed Nov 11, 2024
2 parents 03e564f + d589ea5 commit 2c7ba0a
Show file tree
Hide file tree
Showing 41 changed files with 642 additions and 72 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,13 @@ build_all_ffi_linux: ## Build all FFIs for Linux
@echo "All Linux FFIs built successfully."

__EXPLORER__:

run_explorer_without_docker_db: explorer_ecto_setup_db
@cd explorer/ && \
pnpm install --prefix assets && \
mix setup && \
./start.sh

run_explorer: explorer_run_db explorer_ecto_setup_db
@cd explorer/ && \
pnpm install --prefix assets && \
Expand Down
42 changes: 35 additions & 7 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ impl Batcher {
Ok(msg) => msg,
Err(e) => {
warn!("Failed to deserialize message: {}", e);
self.metrics.user_error(&["deserialize_error", ""]);
return Ok(());
}
};
Expand Down Expand Up @@ -477,7 +478,7 @@ impl Batcher {
ValidityResponseMessage::InvalidChainId,
)
.await;

self.metrics.user_error(&["invalid_chain_id", ""]);
return Ok(());
}

Expand All @@ -493,7 +494,8 @@ impl Batcher {
),
)
.await;

self.metrics
.user_error(&["invalid_paument_service_address", ""]);
return Ok(());
}

Expand All @@ -505,6 +507,7 @@ impl Batcher {
ValidityResponseMessage::InvalidSignature,
)
.await;
self.metrics.user_error(&["invalid_signature", ""]);
return Ok(());
};
info!("Message signature verified");
Expand All @@ -513,6 +516,7 @@ impl Batcher {
if proof_size > self.max_proof_size {
error!("Proof size exceeds the maximum allowed size.");
send_message(ws_conn_sink.clone(), ValidityResponseMessage::ProofTooLarge).await;
self.metrics.user_error(&["proof_too_large", ""]);
return Ok(());
}

Expand All @@ -536,6 +540,10 @@ impl Batcher {
)),
)
.await;
self.metrics.user_error(&[
"disabled_verifier",
&format!("{}", verification_data.proving_system),
]);
return Ok(());
}

Expand All @@ -546,6 +554,10 @@ impl Batcher {
ValidityResponseMessage::InvalidProof(ProofInvalidReason::RejectedProof),
)
.await;
self.metrics.user_error(&[
"rejected_proof",
&format!("{}", verification_data.proving_system),
]);
return Ok(());
}
}
Expand All @@ -565,6 +577,7 @@ impl Batcher {
ValidityResponseMessage::InsufficientBalance(addr),
)
.await;
self.metrics.user_error(&["insufficient_balance", ""]);
return Ok(());
}

Expand All @@ -586,6 +599,7 @@ impl Batcher {
"Failed to get user nonce from Ethereum for address {addr:?}. Error: {e:?}"
);
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidNonce).await;
self.metrics.user_error(&["invalid_nonce", ""]);
return Ok(());
}
};
Expand All @@ -604,6 +618,7 @@ impl Batcher {
let Some(user_balance) = self.get_user_balance(&addr).await else {
error!("Could not get balance for address {addr:?}");
send_message(ws_conn_sink.clone(), ValidityResponseMessage::EthRpcError).await;
self.metrics.user_error(&["eth_rpc_error", ""]);
return Ok(());
};

Expand All @@ -616,6 +631,7 @@ impl Batcher {
error!("Failed to get user proof count: User not found in user states, but it should have been already inserted");
std::mem::drop(batch_state_lock);
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidNonce).await;
self.metrics.user_error(&["invalid_nonce", ""]);
return Ok(());
};

Expand All @@ -626,6 +642,7 @@ impl Batcher {
ValidityResponseMessage::InsufficientBalance(addr),
)
.await;
self.metrics.user_error(&["insufficient_balance", ""]);
return Ok(());
}

Expand All @@ -634,13 +651,15 @@ impl Batcher {
error!("Failed to get cached user nonce: User not found in user states, but it should have been already inserted");
std::mem::drop(batch_state_lock);
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidNonce).await;
self.metrics.user_error(&["invalid_nonce", ""]);
return Ok(());
};

if expected_nonce < msg_nonce {
std::mem::drop(batch_state_lock);
warn!("Invalid nonce for address {addr}, had nonce {expected_nonce:?} < {msg_nonce:?}");
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidNonce).await;
self.metrics.user_error(&["invalid_nonce", ""]);
return Ok(());
}

Expand All @@ -662,13 +681,17 @@ impl Batcher {

let Some(user_min_fee) = batch_state_lock.get_user_min_fee(&addr).await else {
std::mem::drop(batch_state_lock);
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidMaxFee).await;
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidNonce).await;
self.metrics.user_error(&["invalid_nonce", ""]);
return Ok(());
};

// Force current max fee to be less or equal than previous max fee
if nonced_verification_data.max_fee > user_min_fee {
nonced_verification_data.max_fee = user_min_fee;
if msg_max_fee > user_min_fee {
std::mem::drop(batch_state_lock);
warn!("Invalid max fee for address {addr}, had fee {user_min_fee:?} < {msg_max_fee:?}");
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidMaxFee).await;
self.metrics.user_error(&["invalid_max_fee", ""]);
return Ok(());
}

// * ---------------------------------------------------------------------*
Expand All @@ -687,6 +710,7 @@ impl Batcher {
{
error!("Error while adding entry to batch: {e:?}");
send_message(ws_conn_sink, ValidityResponseMessage::AddToBatchError).await;
self.metrics.user_error(&["add_to_batch_error", ""]);
return Ok(());
};

Expand Down Expand Up @@ -727,6 +751,7 @@ impl Batcher {
std::mem::drop(batch_state_lock);
warn!("Invalid nonce for address {addr}. Queue entry with nonce {nonce} not found");
send_message(ws_conn_sink.clone(), ValidityResponseMessage::InvalidNonce).await;
self.metrics.user_error(&["invalid_nonce", ""]);
return;
};

Expand All @@ -739,7 +764,8 @@ impl Batcher {
ValidityResponseMessage::InvalidReplacementMessage,
)
.await;

self.metrics
.user_error(&["invalid_replacement_message", ""]);
return;
}

Expand Down Expand Up @@ -776,6 +802,8 @@ impl Batcher {
ValidityResponseMessage::InvalidReplacementMessage,
)
.await;
self.metrics
.user_error(&["invalid_replacement_message", ""]);
return;
}

Expand Down
16 changes: 15 additions & 1 deletion batcher/aligned-batcher/src/metrics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::{thread, time::Duration};

// Prometheus
use prometheus::{opts, register_int_counter, register_int_gauge, IntCounter, IntGauge};
use prometheus::{
opts, register_int_counter, register_int_counter_vec, register_int_gauge, IntCounter,
IntCounterVec, IntGauge,
};

use warp::{Filter, Rejection, Reply};

Expand All @@ -12,6 +15,7 @@ pub struct BatcherMetrics {
pub sent_batches: IntCounter,
pub reverted_batches: IntCounter,
pub canceled_batches: IntCounter,
pub user_errors: IntCounterVec,
pub batcher_started: IntCounter,
pub gas_price_used_on_latest_batch: IntGauge,
pub broken_ws_connections: IntCounter,
Expand All @@ -28,6 +32,10 @@ impl BatcherMetrics {
register_int_counter!(opts!("reverted_batches", "Reverted Batches"))?;
let canceled_batches =
register_int_counter!(opts!("canceled_batches", "Canceled Batches"))?;
let user_errors = register_int_counter_vec!(
opts!("user_errors", "User Errors"),
&["error_type", "proving_system"]
)?;
let batcher_started = register_int_counter!(opts!("batcher_started", "Batcher Started"))?;
let gas_price_used_on_latest_batch =
register_int_gauge!(opts!("gas_price_used_on_latest_batch", "Gas Price"))?;
Expand All @@ -41,6 +49,7 @@ impl BatcherMetrics {
registry.register(Box::new(sent_batches.clone()))?;
registry.register(Box::new(reverted_batches.clone()))?;
registry.register(Box::new(canceled_batches.clone()))?;
registry.register(Box::new(user_errors.clone()))?;
registry.register(Box::new(gas_price_used_on_latest_batch.clone()))?;
registry.register(Box::new(batcher_started.clone()))?;
registry.register(Box::new(broken_ws_connections.clone()))?;
Expand All @@ -61,6 +70,7 @@ impl BatcherMetrics {
sent_batches,
reverted_batches,
canceled_batches,
user_errors,
batcher_started,
gas_price_used_on_latest_batch,
broken_ws_connections,
Expand Down Expand Up @@ -89,4 +99,8 @@ impl BatcherMetrics {
thread::sleep(Duration::from_secs(2));
self.batcher_started.inc();
}

pub fn user_error(&self, label_values: &[&str]) {
self.user_errors.with_label_values(label_values).inc();
}
}
33 changes: 33 additions & 0 deletions contracts/script/deploy/config/sepolia/aligned.sepolia.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"chainInfo": {
"chainId": 11155111
},
"permissions" : {
"owner": "<owner_address>",
"aggregator": "<aggregator_address>",
"upgrader": "<upgrader_address>",
"churner": "<churner_address>",
"ejector": "<ejector_address>",
"deployer": "<deployer_address>",
"initalPausedStatus": 0
},
"minimumStakes": [
1
],
"strategyWeights": [
[
{
"0_strategy": "0x80528D6e9A2BAbFc766965E0E26d5aB08D9CFaF9",
"1_multiplier": 1e+18
}
]
],
"operatorSetParams": [
{
"0_maxOperatorCount": 200,
"1_kickBIPsOfOperatorStake": 11000,
"2_kickBIPsOfTotalStake": 50
}
],
"uri": ""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"address": {
"batcherWallet": "<batcher_wallet_address>",
"alignedLayerServiceManager": "<aligned_layer_service_manager_address>"
},
"permissions": {
"owner": "<owner_address>"
},
"eip712": {
"noncedVerificationDataTypeHash": "0x41817b5c5b0c3dcda70ccb43ba175fdcd7e586f9e0484422a2c6bba678fdf4a3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"addresses": {
"alignedLayerProxyAdmin": "0x9c50f5054784d6c5523C79c3aFA82E3184430CaC",
"alignedLayerServiceManager": "0xD0fAb108d175765f70Dd2e929b74ec107db6E0e8",
"alignedLayerServiceManagerImplementation": "0xbC86427A646540cF78c92F6C7432716460b97a06",
"blsApkRegistry": "0x9A5B215027F85319957a3a92205BFc18529d9309",
"blsApkRegistryImplementation": "0xEAE702d667bD851C9cAa59e71b23765Bea04A5aF",
"indexRegistry": "0xD316A01F902d0fDF169a53AB22daB38c06c6E60E",
"indexRegistryImplementation": "0x8009D6A252a41bc8fb648F71F3aa78d08231221d",
"operatorStateRetriever": "0xc24023c7e43Dc6A407b1B961A6602ee6d5408A75",
"registryCoordinator": "0x9C04afc13D57608a867E61BD91a10d8689B24ff8",
"registryCoordinatorImplementation": "0xFc326289eF3d5ba5E525e27530329727831E834B",
"serviceManagerRouter": "0x074c28d7ff24c06ab747e08772ed582c3b7C887e",
"stakeRegistry": "0x1888568D57Cf6834d74ef62A78e7EF1ADbd55582",
"stakeRegistryImplementation": "0x05671b5B23d16B2e198729b9Ce94696780d384b9",
"batcherPaymentService": "0x4a40a9F0D29B62a2852ed893B18fAD9CfEcB14FA",
"batcherPaymentServiceImplementation": "0xc40562950D62e3DbFf881149cf07833Cd0A425A9"
},
"chainInfo": {
"chainId": 11155111,
"deploymentBlock": 6833988
},
"permissions": {
"alignedLayerAggregator": "0x1380D03142156d8D9950b001A566dc5cc439dE81",
"alignedLayerChurner": "0x1380D03142156d8D9950b001A566dc5cc439dE81",
"alignedLayerEjector": "0x1380D03142156d8D9950b001A566dc5cc439dE81",
"alignedLayerOwner": "0x1380D03142156d8D9950b001A566dc5cc439dE81",
"alignedLayerUpgrader": "0x1380D03142156d8D9950b001A566dc5cc439dE81",
"pauserRegistry": "0xC2316E03d0871f667e75C62181089988Eb4DB7Db"
}
}
38 changes: 38 additions & 0 deletions contracts/script/output/sepolia/eigenlayer_deployment_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"addresses": {
"avsDirectory": "0x2f1F293185c7b57E1E8e07B95C9f04D33418854c",
"avsDirectoryImplementation": "0x6DC4C39E3e6FC3bdbb054C6Cf87FEf8E33DBBCa9",
"baseStrategyImplementation": "0x942CfD2F80f517D6e6129277b027750D01Aa3Eb1",
"beaconOracle": "0x0000000000000000000000000000000000000000",
"delayedWithdrawalRouter": "0x02eE8752d9d6ee1B366BD04d24Bbaa3547ABc0c1",
"delayedWithdrawalRouterImplementation": "0x5FC324E99fb6db1859225C3E53b2688ce7FbF5E1",
"delegationManager": "0x7F250FA1f844Ae88eAdF919ca3a95e327B639d8F",
"delegationManagerImplementation": "0x77E8329dc5290Ef8BA61A997132316a39f731968",
"eigenLayerPauserReg": "0xC2316E03d0871f667e75C62181089988Eb4DB7Db",
"eigenLayerProxyAdmin": "0x3b9b847F251260d6681E2dF937E84Ae4Db1191e5",
"eigenPodBeacon": "0x879Fce476F58b5691a6AF29C2895e9fDF956642C",
"eigenPodImplementation": "0x953F32aE91ec538eBAD2110b3276dEDe9a886519",
"eigenPodManager": "0x1c49661c978c587d98a4dF730CfBaAeE8836d813",
"eigenPodManagerImplementation": "0xE3A2b29e35E878f24bcf46b3d53004aBD5105d99",
"emptyContract": "0xCf334DbB9bEefC53e3e9Fa0feb7319B702155408",
"rewardsCoordinator": "0x420324e8834D2bfF217319D497DDB2B221dea46C",
"rewardsCoordinatorImplementation": "0xF2Fdf5cDBd262DAE8aCF77f85fc1A7546B5FBa3D",
"slasher": "0xF953eDdb64b624FcEbb133f3D991BA05B122bEC8",
"slasherImplementation": "0xB4Fe2669dA4ee0A67E292F1f09d2b83E07C0fb26",
"strategies": {
"MOCK": "0x3eb924d928c138898FC089328f840105969bD6a0"
},
"strategyManager": "0xAcd358E6CCdE1634A1e80F143cF467Bf40fac4BA",
"strategyManagerImplementation": "0x7A7122D7a5194217Be6181c76484dCc10E8BFf83"
},
"chainInfo": {
"chainId": 11155111,
"deploymentBlock": 6200286
},
"numStrategies": 1,
"parameters": {
"executorMultisig": "0x97aEC5F28181abe5d2aD40dBe7FbaEe014529b7D",
"operationsMultisig": "0x97aEC5F28181abe5d2aD40dBe7FbaEe014529b7D",
"pauserMultisig": "0x97aEC5F28181abe5d2aD40dBe7FbaEe014529b7D"
}
}
12 changes: 2 additions & 10 deletions contracts/script/upgrade/AlignedLayerUpgrader.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,8 @@ contract AlignedLayerUpgrader is Script {
)
);

vm.startBroadcast();

alignedLayerProxyAdmin.upgrade(
TransparentUpgradeableProxy(
payable(address(alignedLayerServiceManager))
),
address(alignedLayerServiceManagerImplementation)
);

vm.stopBroadcast();
// Not link the new implementation to the proxy
// Because this must be executed in the multisig

return (
address(alignedLayerServiceManager),
Expand Down
Loading

0 comments on commit 2c7ba0a

Please sign in to comment.