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

feat: bundler conformance to latest specs, handle reputation #226

Merged
merged 2 commits into from
Oct 16, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- uses: actions/checkout@v3
with:
repository: eth-infinitism/bundler-spec-tests
ref: 'e193753db1910fb6d0ee2661d96a8d8f79d6c7d8'
ref: 'bbd61f21e95ed1290678fcbfd9551b1502c81fe9'
submodules: true
- uses: actions/checkout@v3
with:
Expand All @@ -94,7 +94,7 @@ jobs:

- run: pip install jq yq

- run: pdm install && git submodule update --init --recursive && cd @account-abstraction && yarn && yarn compile && cd ../spec && yarn && yarn build
- run: pdm install && git submodule update --init --recursive && cd @account-abstraction && git fetch --all --tags && git checkout tags/v0.6.0 -b v0.6.0 && yarn && yarn compile && cd ../spec && yarn && yarn build

- uses: actions/download-artifact@v3
with:
Expand Down
46 changes: 44 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ make lint
make test
```

Official [bundler spec tests](https://github.com/eth-infinitism/bundler-spec-tests) developed by the [eth-infinitism](https://github.com/eth-infinitism/) team are also included in the repo's CI pipeline (commit: [e193753db1910fb6d0ee2661d96a8d8f79d6c7d8](https://github.com/eth-infinitism/bundler-spec-tests/tree/e193753db1910fb6d0ee2661d96a8d8f79d6c7d8)). You can find more information on how to run tests [here](https://github.com/eth-infinitism/bundler-spec-tests). Make sure your contribution doesn't break the tests!
Official [bundler spec tests](https://github.com/eth-infinitism/bundler-spec-tests) developed by the [eth-infinitism](https://github.com/eth-infinitism/) team are also included in the repo's CI pipeline (commit: [bbd61f21e95ed1290678fcbfd9551b1502c81fe9](https://github.com/eth-infinitism/bundler-spec-tests/tree/bbd61f21e95ed1290678fcbfd9551b1502c81fe9)). You can find more information on how to run tests [here](https://github.com/eth-infinitism/bundler-spec-tests). Make sure your contribution doesn't break the tests!

## Contact

Expand Down
1 change: 0 additions & 1 deletion bin/silius/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ where
chain_id,
args.max_verification_gas,
args.min_stake,
args.min_unstake_delay,
args.min_priority_fee_per_gas,
args.whitelist,
args.uopool_mode,
Expand Down
4 changes: 0 additions & 4 deletions bin/silius/src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ pub struct UoPoolArgs {
#[clap(long, value_parser=parse_u256, default_value = "1")]
pub min_stake: U256,

/// Minimum unstake delay for entities.
#[clap(long, value_parser=parse_u256, default_value = "0")]
pub min_unstake_delay: U256,

/// Minimum priority fee per gas.
#[clap(long, value_parser=parse_u256, default_value = "0")]
pub min_priority_fee_per_gas: U256,
Expand Down
15 changes: 5 additions & 10 deletions crates/grpc/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::uopool::{GAS_INCREASE_PERC, MAX_UOS_PER_UNSTAKED_SENDER};
use ethers::{
providers::Middleware,
types::{Address, H256, U256},
Expand All @@ -7,9 +6,12 @@ use eyre::format_err;
use futures_util::StreamExt;
use silius_contracts::EntryPoint;
use silius_primitives::{
consts::reputation::{
BAN_SLACK, MIN_INCLUSION_RATE_DENOMINATOR, MIN_UNSTAKE_DELAY, THROTTLING_SLACK,
},
get_address,
provider::BlockStream,
reputation::{ReputationEntry, BAN_SLACK, MIN_INCLUSION_RATE_DENOMINATOR, THROTTLING_SLACK},
reputation::ReputationEntry,
Chain, UserOperation,
};
use silius_uopool::{
Expand All @@ -35,7 +37,6 @@ where
chain: Chain,
max_verification_gas: U256,
min_stake: U256,
min_unstake_delay: U256,
min_priority_fee_per_gas: U256,
whitelist: Vec<Address>,
mempool: MempoolBox<VecUo, VecCh, P, E>,
Expand All @@ -57,7 +58,6 @@ where
chain: Chain,
max_verification_gas: U256,
min_stake: U256,
min_unstake_delay: U256,
min_priority_fee_per_gas: U256,
whitelist: Vec<Address>,
mempool: P,
Expand All @@ -73,7 +73,7 @@ where
THROTTLING_SLACK,
BAN_SLACK,
min_stake,
min_unstake_delay,
MIN_UNSTAKE_DELAY.into(),
);
for addr in whitelist.iter() {
reputation.add_whitelist(addr);
Expand All @@ -86,7 +86,6 @@ where
chain,
max_verification_gas,
min_stake,
min_unstake_delay,
min_priority_fee_per_gas,
whitelist,
mempool,
Expand Down Expand Up @@ -199,17 +198,13 @@ where
self.chain,
self.max_verification_gas,
self.min_priority_fee_per_gas,
MAX_UOS_PER_UNSTAKED_SENDER,
GAS_INCREASE_PERC.into(),
)
} else {
StandardUserOperationValidator::new_canonical(
entry_point.clone(),
self.chain,
self.max_verification_gas,
self.min_priority_fee_per_gas,
MAX_UOS_PER_UNSTAKED_SENDER,
GAS_INCREASE_PERC.into(),
)
};

Expand Down
9 changes: 6 additions & 3 deletions crates/grpc/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ where
if !self.is_running() {
info!("Starting auto bundling");

let mut r = self.running.lock();
*r = true;
{
let mut r = self.running.lock();
*r = true;
}

for bundler in self.bundlers.iter() {
let bundler_own = bundler.clone();
Expand All @@ -100,10 +102,11 @@ where
tokio::spawn(async move {
let mut interval = tokio::time::interval(Duration::from_secs(int));
loop {
interval.tick().await;

Vid201 marked this conversation as resolved.
Show resolved Hide resolved
if !is_running(running_lock.clone()) {
break;
}
interval.tick().await;

match Self::get_user_operations(
&uopool_grpc_client,
Expand Down
20 changes: 20 additions & 0 deletions crates/grpc/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,26 @@ pub mod types {
Self::from(value.0)
}
}

impl From<silius_primitives::reputation::StakeInfo> for StakeInfo {
fn from(value: silius_primitives::reputation::StakeInfo) -> Self {
Self {
address: Some(value.address.into()),
stake: value.stake.as_u64(),
unstake_delay: value.unstake_delay.as_u64(),
}
}
}

impl From<StakeInfo> for silius_primitives::reputation::StakeInfo {
fn from(value: StakeInfo) -> Self {
Self {
address: value.address.unwrap_or_default().into(),
stake: value.stake.into(),
unstake_delay: value.unstake_delay.into(),
}
}
}
}

pub mod uopool {
Expand Down
6 changes: 6 additions & 0 deletions crates/grpc/src/protos/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,9 @@ message Log{
H256 transaction_hash = 8;
PbU256 log_index = 9;
}

message StakeInfo {
H160 address = 1;
uint64 stake = 2;
uint64 unstake_delay = 3;
}
13 changes: 13 additions & 0 deletions crates/grpc/src/protos/uopool/uopool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ message GetUserOperationReceiptResponse{
string reason = 10;
}

message GetStakeInfoRequest {
types.H160 addr = 1;
types.H160 ep = 2;
}

message GetStakeInfoResponse {
types.StakeInfo info = 1;
bool is_staked = 2;
}

service UoPool {
rpc Add(AddRequest) returns (AddResponse);
rpc Remove(RemoveRequest) returns (google.protobuf.Empty);
Expand All @@ -112,9 +122,12 @@ service UoPool {
rpc GetSortedUserOperations(GetSortedRequest) returns (GetSortedResponse);
rpc GetUserOperationByHash(UserOperationHashRequest) returns (GetUserOperationByHashResponse);
rpc GetUserOperationReceipt(UserOperationHashRequest) returns (GetUserOperationReceiptResponse);
rpc GetStakeInfo(GetStakeInfoRequest) returns (GetStakeInfoResponse);

// debug
rpc GetAll(GetAllRequest) returns (GetAllResponse);
rpc ClearMempool(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc ClearReputation(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc Clear(google.protobuf.Empty) returns (google.protobuf.Empty);
rpc GetAllReputation(GetAllReputationRequest) returns (GetAllReputationResponse);
rpc SetReputation(SetReputationRequest) returns (SetReputationResponse);
Expand Down
Loading
Loading