Skip to content

Commit

Permalink
bugfix: pass max allowed ops unstaked sender spec test
Browse files Browse the repository at this point in the history
  • Loading branch information
V00D00-child committed Oct 13, 2024
1 parent fe19cb8 commit ebf62a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
15 changes: 10 additions & 5 deletions packages/bundler-builder/src/mempool/mempool-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,14 @@ export const createMempoolManager = (
)
}

// Funtions to interface with reputationManager
/**
* Checks the reputation status of the given stakeInfo.
* Banned: If the entity is banned, an error is thrown as banned entities are not allowed to add UserOperations.
*
* @param title - The title of the entity to check the reputation status for.
* @param stakeInfo - The StakeInfo of the entity to check the reputation status for.
* @param maxTxMempoolAllowedOverride - The maximum number of transactions allowed in the mempool for the entity.
*/
const checkReputationStatus = async (
title: 'account' | 'paymaster' | 'aggregator' | 'deployer',
stakeInfo: StakeInfo,
Expand All @@ -167,7 +174,7 @@ export const createMempoolManager = (
if (foundCount > THROTTLED_ENTITY_MEMPOOL_COUNT) {
await reputationManager.checkThrottled(title, stakeInfo)
}
if (foundCount > maxTxMempoolAllowedEntity) {
if (foundCount >= maxTxMempoolAllowedEntity) {
await reputationManager.checkStake(title, stakeInfo)
}
}
Expand Down Expand Up @@ -200,10 +207,8 @@ export const createMempoolManager = (
const updateSeenStatus = async (
aggregator: string | undefined,
userOp: UserOperation,
senderInfo: StakeInfo,
): Promise<void> => {
try {
await reputationManager.checkStake('account', senderInfo)
await reputationManager.updateSeenStatus(userOp.sender)
} catch (e: any) {
if (!(e instanceof RpcError)) throw e
Expand Down Expand Up @@ -425,7 +430,7 @@ export const createMempoolManager = (
)
}

await updateSeenStatus(aggregatorInfo?.addr, userOp, senderInfo)
await updateSeenStatus(aggregatorInfo?.addr, userOp)
Logger.debug(
{
sender: userOp.sender,
Expand Down
8 changes: 5 additions & 3 deletions packages/bundler-builder/src/reputation/reputation-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,26 +336,28 @@ export const createReputationManager = (
title: 'account' | 'paymaster' | 'aggregator' | 'deployer',
info?: StakeInfo,
): Promise<void> => {
// If the address is whitelisted, we don't need to check the stake
const status = await getStatus(info.addr)
if (info?.addr == null || status === ReputationStatus.OK) {
if (info?.addr == null) {
return
}

// If the address is whitelisted, we don't need to check the stake
const status = await getStatus(info.addr)
requireCond(
status !== ReputationStatus.BANNED,
`${title} ${info.addr} is banned`,
ValidationErrors.Reputation,
{ [title]: info.addr },
)

// Check if min stake and unstake delay are met
requireCond(
BigNumber.from(info.stake).gte(minStake),
`${title} ${info.addr} stake ${tostr(info.stake)} is too low (min=${tostr(
minStake,
)})`,
ValidationErrors.InsufficientStake,
)

requireCond(
BigNumber.from(info.unstakeDelaySec).gte(
BigNumber.from(minUnstakeDelay),
Expand Down

0 comments on commit ebf62a2

Please sign in to comment.