-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AA-227: Define JSON schema for the alt-mempool configuration (#238)
* AA-227: Rewrite erc7562 parser and define JSON schema for the alt-mempool configuration
- Loading branch information
Showing
22 changed files
with
1,171 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/validation-manager/src/AccountAbstractionEntity.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export enum AccountAbstractionEntity { | ||
account = 'account', | ||
paymaster = 'paymaster', | ||
factory = 'factory', | ||
aggregator = 'aggregator', | ||
senderCreator = 'SenderCreator', | ||
entryPoint = 'EntryPoint', | ||
nativeEntryPoint = 'NativeEntryPoint', | ||
nativeNonceManager = 'NativeNonceManager', | ||
none = 'none' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* [OP-011] the opcodes banned for all entities. | ||
*/ | ||
export const bannedOpCodes = new Set( | ||
[ | ||
'BASEFEE', | ||
'BLOCKHASH', | ||
'COINBASE', | ||
'DIFFICULTY', | ||
'GAS', | ||
'GASLIMIT', | ||
'GASPRICE', | ||
'INVALID', | ||
'NUMBER', | ||
'ORIGIN', | ||
'PREVRANDAO', | ||
'RANDOM', | ||
'SELFDESTRUCT', | ||
'TIMESTAMP' | ||
] | ||
) | ||
|
||
/** | ||
* [OP-080] the opcodes allowed in staked entities. | ||
*/ | ||
export const opcodesOnlyInStakedEntities = new Set( | ||
[ | ||
'BALANCE', | ||
'SELFBALANCE' | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import ow from 'ow' | ||
|
||
export interface ContractSize { | ||
contractSize: number | ||
opcode: number | ||
} | ||
|
||
export interface AccessedSlots { | ||
reads?: Record<string, string[]> | ||
transientReads?: Record<string, unknown> | ||
transientWrites?: Record<string, unknown> | ||
writes?: Record<string, number> | ||
} | ||
|
||
export interface ERC7562Call { | ||
accessedSlots: AccessedSlots | ||
contractSize: Record<string, ContractSize> | ||
error?: string | ||
extCodeAccessInfo: string[] | ||
from: string | ||
gas: string | ||
gasUsed: string | ||
input: string | ||
outOfGas: boolean | ||
output?: string | ||
to: string | ||
type: string | ||
usedOpcodes: Record<number, number> | ||
value?: string | ||
calls?: ERC7562Call[] | ||
keccak?: string[] | ||
} | ||
|
||
const contractSizeSchema = ow.object.exactShape({ | ||
contractSize: ow.number, | ||
opcode: ow.number | ||
}) | ||
|
||
const accessedSlotsSchema = ow.object.exactShape({ | ||
reads: ow.object.valuesOfType(ow.array.ofType(ow.string)), | ||
transientReads: ow.object, | ||
transientWrites: ow.object, | ||
writes: ow.object.valuesOfType(ow.number) | ||
}) | ||
|
||
const erc7562CallSchema = ow.object.exactShape({ | ||
accessedSlots: accessedSlotsSchema, | ||
contractSize: ow.object.valuesOfType(contractSizeSchema), | ||
error: ow.optional.string, | ||
extCodeAccessInfo: ow.array.ofType(ow.string), | ||
from: ow.string, | ||
gas: ow.string, | ||
gasUsed: ow.string, | ||
input: ow.string, | ||
outOfGas: ow.boolean, | ||
output: ow.optional.string, | ||
to: ow.string, | ||
type: ow.string, | ||
usedOpcodes: ow.object.valuesOfType(ow.number), | ||
value: ow.optional.string, | ||
calls: ow.optional.array, | ||
keccak: ow.optional.array.ofType(ow.string) | ||
}) | ||
|
||
/** | ||
* Recursively check the calls ow schema. | ||
*/ | ||
export function validateERC7562Call (value: ERC7562Call): void { | ||
ow(value, erc7562CallSchema) | ||
|
||
if (value.calls != null) { | ||
for (const call of value.calls) { | ||
validateERC7562Call(call) | ||
} | ||
} | ||
} |
Oops, something went wrong.