Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: accesslist request and metrics initial number #283

Merged
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ Silius was tested on the following networks, and some public endpoints are avail

| Chain | Supported Status | Public RPC URL |
| :--------: | :-------: | :-------: |
| Ethereum | :heavy_check_mark:| :soon: |
| Ethereum | :heavy_check_mark:| <https://rpc.silius.xyz/api/v1/chain/ethereum-mainnet> |
| Ethereum Goerli | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/ethereum-goerli> |
| Ethereum Sepolia| :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/ethereum-sepolia> |
| Ethereum Holesky| :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/ethereum-holesky> |
| Polygon | :x: | :soon: |
| Polygon | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/polygon-mainnet> |
| Polygon Mumbai| :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/polygon-mumbai> |
| Linea | :x: | :soon: |
| Linea | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/linea-mainnet> |
| Linea Goerli | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/linea-goerli> |
| Optimism | :x: | :soon: |
| Optimism | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/optimism-mainnet> |
| Optimism Goerli | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/optimism-goerli> |
| Optimism Sepolia | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/optimism-sepolia> |
| Arbitrum | :x: | :soon: |
| Arbitrum | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/arbitrum-mainnet> |
| Arbitrum Goerli | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/arbitrum-goerli> |
| Arbitrum Sepolia | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/arbitrum-sepolia> |
| BSC | :x: | :soon: |
| BSC | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/bsc-mainnet> |
| BSC Testnet | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/bsc-testnet> |
| Base | :x: | :soon: |
| Base | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/base-mainnet> |
| Base Goerli | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/base-goerli> |
| Base Sepolia | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/base-sepolia> |
| Avalanche | :x: | :soon: |
| Avalanche | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/avalanche-mainnet> |
| Avalanche Fuji | :heavy_check_mark: | <https://rpc.silius.xyz/api/v1/chain/avalanche-fuji> |

Bundler's account: `0x0a4E15d25E97e747bD568979A3B7dbEb95970Eb3`
Expand Down
2 changes: 2 additions & 0 deletions bin/silius/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ where
client,
uopool_grpc_client,
metrics_args.enable_metrics,
args.enable_access_list,
);
}
SendStrategy::Flashbots => {
Expand Down Expand Up @@ -180,6 +181,7 @@ where
client,
uopool_grpc_client,
metrics_args.enable_metrics,
args.enable_access_list,
);
}
}
Expand Down
5 changes: 5 additions & 0 deletions bin/silius/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ pub struct BundlerArgs {
/// By default, this option is set to `ethereum-client`.
#[clap(long, default_value = "ethereum-client", value_parser=parse_send_bundle_mode)]
pub send_bundle_mode: SendStrategy,

/// Indicates whether the access list is enabled.
#[clap(long)]
pub enable_access_list: bool,
}

/// UoPool CLI args
Expand Down Expand Up @@ -352,6 +356,7 @@ mod tests {
send_bundle_mode: SendStrategy::EthereumClient,
bundler_addr: IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
bundler_port: 3002,
enable_access_list: false,
},
BundlerArgs::try_parse_from(args).unwrap()
);
Expand Down
65 changes: 37 additions & 28 deletions crates/bundler/src/bundler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alloy_chains::{Chain, NamedChain};
use alloy_chains::Chain;
use ethers::{
providers::Middleware,
signers::Signer,
Expand Down Expand Up @@ -45,6 +45,8 @@ where
pub eth_client: Arc<M>,
/// Client that sends the bundle to some network
pub client: Arc<S>,
/// Whether add access list into tx
pub enable_access_list: bool,
}

impl<M, S> Bundler<M, S>
Expand All @@ -56,6 +58,7 @@ where
///
/// # Returns
/// * `Self` - A new `Bundler` instance
#[allow(clippy::too_many_arguments)]
pub fn new(
wallet: Wallet,
beneficiary: Address,
Expand All @@ -64,8 +67,18 @@ where
min_balance: U256,
eth_client: Arc<M>,
client: Arc<S>,
enable_access_list: bool,
) -> Self {
Self { wallet, beneficiary, entry_point, chain, min_balance, eth_client, client }
Self {
wallet,
beneficiary,
entry_point,
chain,
min_balance,
eth_client,
client,
enable_access_list,
}
}

/// Functions that generates a bundle of user operations (i.e.,
Expand Down Expand Up @@ -95,34 +108,30 @@ where
)
.tx;

match Chain::from_id(self.chain.id()).named() {
// Mumbai
Some(NamedChain::PolygonMumbai) => {
tx.set_nonce(nonce).set_chain_id(self.chain.id());
}
// All other surpported networks, including Mainnet, Goerli
_ => {
let accesslist = self.eth_client.create_access_list(&tx, None).await?.access_list;
tx.set_access_list(accesslist.clone());
let estimated_gas = self.eth_client.estimate_gas(&tx, None).await?;
let accesslist = if self.enable_access_list {
let accesslist = self.eth_client.create_access_list(&tx, None).await?.access_list;
tx.set_access_list(accesslist.clone());
accesslist
} else {
Default::default()
};
let estimated_gas = self.eth_client.estimate_gas(&tx, None).await?;

let (max_fee_per_gas, max_priority_fee) =
self.eth_client.estimate_eip1559_fees(None).await?;
let (max_fee_per_gas, max_priority_fee) =
self.eth_client.estimate_eip1559_fees(None).await?;

tx = TypedTransaction::Eip1559(Eip1559TransactionRequest {
to: tx.to().cloned(),
from: Some(self.wallet.signer.address()),
data: tx.data().cloned(),
chain_id: Some(U64::from(self.chain.id())),
max_priority_fee_per_gas: Some(max_priority_fee),
max_fee_per_gas: Some(max_fee_per_gas),
gas: Some(estimated_gas),
nonce: Some(nonce),
value: None,
access_list: accesslist,
});
}
};
tx = TypedTransaction::Eip1559(Eip1559TransactionRequest {
to: tx.to().cloned(),
from: Some(self.wallet.signer.address()),
data: tx.data().cloned(),
chain_id: Some(U64::from(self.chain.id())),
max_priority_fee_per_gas: Some(max_priority_fee),
max_fee_per_gas: Some(max_fee_per_gas),
gas: Some(estimated_gas),
nonce: Some(nonce),
value: None,
access_list: accesslist,
});

Ok(tx)
}
Expand Down
1 change: 1 addition & 0 deletions crates/bundler/tests/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ async fn setup() -> eyre::Result<TestContext<Provider<Ws>, FlashbotsClient<Provi
U256::from(100000000000000000u64),
eth_client,
client,
true,
);

Ok(TestContext { bundler, _entry_point: ep_address, _anvil: anvil })
Expand Down
2 changes: 2 additions & 0 deletions crates/grpc/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ pub fn bundler_service_run<M, S>(
client: Arc<S>,
uopool_grpc_client: UoPoolClient<tonic::transport::Channel>,
enable_metrics: bool,
enable_access_list: bool,
) where
M: Middleware + Clone + 'static,
S: SendBundleOp + Clone + 'static,
Expand All @@ -190,6 +191,7 @@ pub fn bundler_service_run<M, S>(
min_balance,
eth_client.clone(),
client.clone(),
enable_access_list,
)
})
.collect();
Expand Down
3 changes: 3 additions & 0 deletions crates/metrics/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ pub fn describe_grpc_metrics() {
describe_counter!(GRPC_REQUEST, "grpc request count");
describe_counter!(GRPC_REQUEST_SUCCESS, "grpc request success count");
describe_counter!(GRPC_REQUEST_FAILED, "grpc request failed count");
counter!(GRPC_REQUEST).absolute(0);
counter!(GRPC_REQUEST_SUCCESS).absolute(0);
counter!(GRPC_REQUEST_FAILED).absolute(0);
}
9 changes: 8 additions & 1 deletion crates/metrics/src/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,12 @@ pub fn describe_mempool_metrics() {
describe_counter!(
REPUTATION_SET_ENTRY_ERROR,
"The number of errors when setting a reputation entry"
)
);
counter!(MEMPOOL_ADD_ERROR).absolute(0);
counter!(MEMPOOL_REMOVE_ERROR).absolute(0);
counter!(REPUTATION_SET_ENTRY_ERROR).absolute(0);
gauge!(MEMPOOL_SIZE).set(0f64);
gauge!(REPUTATION_UO_SEEN).set(0f64);
gauge!(REPUTATION_UO_INCLUDED).set(0f64);
gauge!(REPUTATION_STATUS).set(0f64);
}
5 changes: 4 additions & 1 deletion crates/metrics/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,8 @@ impl<F: Future<Output = MethodResponse>> Future for MetricsFuture<F> {
pub fn describe_json_rpc_metrics() {
describe_counter!(RPC_REQUEST, "The number of json rpc requests so far");
describe_counter!(RPC_REQUEST_SUCCESS, "The number of successful json rpc requests so far");
describe_counter!(RPC_REQUEST_FAILED, "The number of failed json rpc requests so far")
describe_counter!(RPC_REQUEST_FAILED, "The number of failed json rpc requests so far");
counter!(RPC_REQUEST).absolute(0);
counter!(RPC_REQUEST_SUCCESS).absolute(0);
counter!(RPC_REQUEST_FAILED).absolute(0);
}
Loading