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(pool): allow staked senders to have multiple UOs in best_operations #732

Merged
merged 1 commit into from
Jun 18, 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
31 changes: 24 additions & 7 deletions crates/pool/src/mempool/uo_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,12 @@ where
.div_mod(self.config.num_shards.into())
.1
== shard_index.into())) &&
// filter out ops from senders we've already seen
senders.insert(op.uo.sender())
// filter out ops from unstaked senders we've already seen
if !op.account_is_staked {
senders.insert(op.uo.sender())
} else {
true
}
})
.take(max)
.map(Into::into)
Expand Down Expand Up @@ -1031,13 +1035,13 @@ mod tests {
async fn test_account_reputation() {
let address = Address::random();
let (pool, uos) = create_pool_insert_ops(vec![
create_op_with_errors(address, 0, 2, None, None, true),
create_op_with_errors(address, 1, 2, None, None, true),
create_op_with_errors(address, 1, 2, None, None, true),
create_op_with_errors(address, 0, 2, None, None, true), // accept
create_op_with_errors(address, 1, 2, None, None, true), // accept
create_op_with_errors(address, 1, 2, None, None, true), // reject
])
.await;
// Only return 1 op per sender
check_ops(pool.best_operations(3, 0).unwrap(), vec![uos[0].clone()]);
// staked, so include all ops
check_ops(pool.best_operations(3, 0).unwrap(), uos[0..2].to_vec());

let rep = pool.dump_reputation();
assert_eq!(rep.len(), 1);
Expand Down Expand Up @@ -1489,6 +1493,19 @@ mod tests {
.is_err());
}

#[tokio::test]
async fn test_best_staked() {
let address = Address::random();
let (pool, uos) = create_pool_insert_ops(vec![
create_op_with_errors(address, 0, 2, None, None, true),
create_op_with_errors(address, 1, 2, None, None, true),
create_op_with_errors(address, 2, 2, None, None, true),
])
.await;
// staked, so include all ops
check_ops(pool.best_operations(3, 0).unwrap(), uos);
}

#[derive(Clone, Debug)]
struct OpWithErrors {
op: UserOperationVariant,
Expand Down
2 changes: 1 addition & 1 deletion test/spec-tests/local/launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ case $1 in
start)
docker-compose up -d
sleep 10
cast send --unlocked --from $(cast rpc eth_accounts | tail -n 1 | tr -d '[]"') --value 1ether 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 > /dev/null
cast send --unlocked --from $(cast rpc eth_accounts | tail -n 1 | tr -d '[]"') --value 100ether 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 > /dev/null
(cd ../$2/bundler-spec-tests/@account-abstraction && yarn deploy --network localhost)
../../../target/debug/rundler node --log.file out.log &
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:3000/health)" != "200" ]]; do sleep 1 ; done
Expand Down
Loading