Skip to content

Commit

Permalink
feat(pool): allow staked senders to have multiple UOs in best_operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Jun 18, 2024
1 parent d3b33ab commit 035d507
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
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
2 changes: 1 addition & 1 deletion test/spec-tests/v0_6/bundler-spec-tests

0 comments on commit 035d507

Please sign in to comment.