Skip to content

Commit

Permalink
AA-227: Define JSON schema for the alt-mempool configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
forshtat committed Jan 7, 2025
1 parent 2a6a3f4 commit 851cbd6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions packages/utils/src/altmempool/AltMempoolConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
type Role = 'sender' | 'paymaster' | 'factory'

type EnterOpcode = 'CALL' | 'DELEGATECALL' | 'CALLCODE' | 'STATICCALL' | 'CREATE' | 'CREATE2'

export interface AltMempoolRuleExceptionBase {
role?: Role
address?: string
depths?: number[]
enterOpcode?: EnterOpcode[]
enterMethodSelector?: `0x${string}`
}

export interface AltMempoolRuleExceptionBannedOpcode extends AltMempoolRuleExceptionBase {
opcodes: string[]
slots: Array<`0x${string}`>
}

type RuleException = `0x${string}` | Role | AltMempoolRuleExceptionBase | AltMempoolRuleExceptionBannedOpcode

export interface BaseAltMempoolRule {
enabled?: boolean
exceptions?: RuleException[]
}

// TODO: define all current rules
type RuleERC7562 = 'erep010' | 'erep020'

export interface AltMempoolConfig {
[mempoolId: number]: { [rule in RuleERC7562]?: BaseAltMempoolRule }
}

const config: AltMempoolConfig = {
1: {
erep010: {
enabled: true,
exceptions: [
'sender',
'0xdeadbeef',
{
depths: [3],
enterOpcode: ['CALL'],
opcodes: ['SSTORE', 'SLOAD'],
slots: ['0xdeadbeef']
}
]
}
}
}

console.log(config)

0 comments on commit 851cbd6

Please sign in to comment.