Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Clear expiration flag after user operation removed? #356

@wanliqun

Description

@wanliqun

After we removed the expired user operation, we might need to clear the expiration datetime for it like delete(e.seenAt, userOpHash). This is because if the bundle transaction is successfully mined to block but reverted due to some reason, user tends to send the user operation again to the mempool, and will never be included to next bundle transaction due to expiration drop.

// DropExpired returns a BatchHandlerFunc that will drop UserOperations from the mempool if it has been around
// for longer than the TTL duration.
func (e *ExpireHandler) DropExpired() modules.BatchHandlerFunc {
	return func(ctx *modules.BatchHandlerCtx) error {
		end := len(ctx.Batch) - 1
		for i := end; i >= 0; i-- {
			hash := ctx.Batch[i].GetUserOpHash(ctx.EntryPoint, ctx.ChainID)
			if seenAt, ok := e.seenAt[hash]; !ok {
				e.seenAt[hash] = time.Now()
			} else if seenAt.Add(e.ttl).Before(time.Now()) {
				ctx.MarkOpIndexForRemoval(i)
			}
		}
		return nil
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions