Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA-213: Standalone ValidationManager package #153

Merged
merged 11 commits into from
Oct 20, 2023

Conversation

forshtat
Copy link
Contributor

@forshtat forshtat commented Oct 3, 2023

No description provided.

@forshtat forshtat changed the title Initial commit for standalone ValidationManager package AA-213: Standalone ValidationManager package Oct 3, 2023
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.15;

contract GetCodeHashes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe CodeHashGetter?

import { checkUserOpRulesViolations } from '@account-abstraction/validation-manager'

const userOperation: UserOperation = createUserOp()
checkUserOpRulesViolations(provider, userOperation, entryPoint)
Copy link
Contributor

@shahafn shahafn Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just validateRulesViolations(UserOperation)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the parameters are required.
  • methods should have the verb-subject in their names, so its good idea to have UserOp there.
  • the librarian is validation-manager, so it makes sense to name it "validate" and not "check"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the parameters are required.
  • methods should have the verb-subject in their names, so its good idea to have UserOp there.
  • the librarian is validation-manager, so it makes sense to name it "validate" and not "check"

The rules themselves are actually called "validation rules" so I don't want to ever have to say "validate validation rules", so I called the function 'check'.

Copy link
Contributor

@drortirosh drortirosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally very good refactor.
Just the "abi", which was "externalized" for no reason.

import { ReputationManager } from './ReputationManager'
import Debug from 'debug'
import { ReferencedCodeHashes, StakeInfo, UserOperation, ValidationErrors } from './Types'
import { UserOperation } from './Types'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe UserOperation should be moved to "utils" too ?

export interface StorageMap {
[address: string]: string | SlotMap
}
export const abi = Object.values([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. don't export generic "abi" from a package.
  2. specifically, this one is used when decoding callstack during trace - it should be declared there, not passed through a chain of methods and packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this includes ABIs that are only relevant to our project, won't other users want to supply their own ABIs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test ABIs are not needed, only the "public" ones. They were added for debugging-purposes only, and really can be removed.

import { UserOperationEventEvent } from '@account-abstraction/contracts/dist/types/EntryPoint'
import { UserOperationReceipt } from '../src/RpcTypes'
import { ExecutionManager } from '../src/modules/ExecutionManager'
import { BundlerReputationParams, ReputationManager } from '../src/modules/ReputationManager'
import { MempoolManager } from '../src/modules/MempoolManager'
import { ValidationManager } from '../src/modules/ValidationManager'
import { ValidationManager } from '../../validation-manager/src/ValidationManager'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@account-abstraction/validation-manager

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are executed with ts-node which ignores all scopes and just goes with the flow. Most of the files in tests are imported chaotically. I can fix that if needed.

import { checkRulesViolations } from '@account-abstraction/validation-manager'

const userOperation: UserOperation = createUserOp()
checkRulesViolations(provider, userOperation, entryPoint)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await?

import { EntryPoint__factory } from '@account-abstraction/contracts'
import { parseEther } from 'ethers/lib/utils'
import { Signer } from 'ethers'
import { BundlerConfig } from '../BundlerConfig'
import { EventsManager } from './EventsManager'
import { getNetworkProvider } from '../Config'
import { abi } from './Types'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this abi is a set of ABIs used to simplify decoding of call stacks. it is not a global parameter.

@@ -0,0 +1,20 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need 2 tsconfig files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure but this is needed for yarn workspaces. Removing these used to break the project in the past, did not try since.

*/
function parseCallStack (tracerResults: BundlerCollectorReturn): CallEntry[] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a local parser. no need to "externalize" the abi . Maybe remove unneeded (test) contracts, and add IAccount instead

@forshtat forshtat merged commit 3fcc4ef into main Oct 20, 2023
@forshtat forshtat deleted the AA-213-extract-rules-validator-package branch October 20, 2023 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants