Giter VIP home page Giter VIP logo

skandha's Introduction

Skandha

A modular, developer-friendly Typescript Bundler for Ethereum EIP-4337 Account Abstraction

Warning! This repo/software is under active development

Important links

Install Skandha | Chains supported | UserOp Fee history

⚙️ How to run (from Source code)

Run with one-liner:

curl -fsSL https://skandha.run | bash

Or follow the steps below:

  1. install all dependencies by running yarn
  2. build yarn build && yarn bootstrap
  3. cp config.json.default config.json
  4. edit config.json
  5. (optional) run local geth-node from test/geth-dev
  6. run ./skandha
  7. Skandha will run for all chains available in config.json
  8. Networks will be available at http://localhost:14337/{chainId}/ (e.g. for dev http://localhost:14337/1337/)

For a video tutorial on the above, you can view this here.

🐳 How to run (a Docker image)

  1. cp config.json.default config.json
  2. edit config.json
  3. docker build -t etherspot/skandha .
  4. docker run --mount type=bind,source="$(pwd)"/config.json,target=/usr/app/config.json,readonly -dp 14337:14337 etherspot/skandha standalone

📜 Additional features

  • Unsafe mode - bypass opcode & stake validation
  • Redirect RPC - Redirect ETH rpc calls to the underlying execution client. This is needed if you use UserOp.js
  • P2P - Exchange of UserOps between all the nodes in the network. Heavily inspired by the Lodestar's implementation of p2p (https://github.com/ChainSafe/lodestar/)

⚡️ CLI Options

  • --unsafeMode - enables unsafeMode
  • --redirectRpc - enables redirecting eth rpc calls
  • --executor.bundlingMode manual|auto - sets bundling mode to manual or auto on start. Default value is auto

🔑 Relayer Configuration

Simplest config.json

{
  "networks": {
    "mumbai": {
      "entryPoints": [
        "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
      ],
      "relayers": [
        "0x{RELAYER-PRIVATE-KEY}"
      ],
      "beneficiary": "0x{BENEFICIARY-ADDRESS}",
      "rpcEndpoint": "https://polygon-mumbai.blockpi.network/v1/rpc/public"
    }
  }
}

config.json with a default value of each config parameter

{
  "networks": {
    "dev": { # network Id (check packages/params/src/networks/<network>.ts)
      "entryPoints": [ # supported entry points
        "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789"
      ],
      "relayers": [
        "0x0101010101010101010101010101010101010101010101010101010101010101",
        "test test test test test test test test test test test junk"
      ], # relayers private keys, can access from here or via environment variables (SKANDHA_MUMBAI_RELAYERS | SKANDHA_DEV_RELAYERS | etc.)
      "beneficiary": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", # optional, fee collector, avaiable via env var (SKANDHA_MUMBAI_BENEFICIARY | etc) - if not set, relayer will be used
      "rpcEndpoint": "http://localhost:8545", # rpc provider, also available via env variable (SKANDHA_MUMBAI_RPC | etc)
      "minInclusionDenominator": 10, # optional, see EIP-4337
      "throttlingSlack": 10, # optional, see EIP-4337
      "banSlack": 50 # optional, see EIP-4337
      "minStake": 10000000000, # optional, min stake of an entity (in wei)
      "minUnstakeDelay": 0, # optional, min unstake delay of an entity
      "minSignerBalance": 1, # optional, default is 0.1 ETH. If the relayer's balance drops lower than this, it will be selected as a fee collector
      "multicall": "0xcA11bde05977b3631167028862bE2a173976CA11", # optional, multicall3 contract (see https://github.com/mds1/multicall#multicall3-contract-addresses)
      "estimationStaticBuffer": 21000, # optional,adds certain amount of gas to callGasLimit on estimation
      "validationGasLimit": 10e6, # optional,gas limit during simulateHandleOps and simulateValidation calls
      "receiptLookupRange": 1024, # optional,limits the block range of getUserOperationByHash and getUserOperationReceipt
      "etherscanApiKey": "", # optional,etherscan api is used to fetch gas prices
      "conditionalTransactions": false, # optional,enable conditional transactions
      "rpcEndpointSubmit": "", # optional,rpc endpoint that is used only during submission of a bundle
      "gasPriceMarkup": 0, # optional,adds % markup on reported gas price via skandha_getGasPrice, 10000 = 100.00%, 500 = 5%
      "enforceGasPrice": false, # optional,do not bundle userops with low gas prices
      "enforceGasPriceThreshold": 1000, # optional,gas price threshold in bps. If set to 500, userops' gas price is allowed to be 5% lower than the network's gas price
      "eip2930": false, # optional, enables eip-2930
      "useropsTTL": 300, # optional, Userops time to live (in seconds)
      "whitelistedEntities": { # optional, Entities that bypass stake and opcode validation (array of addresses)
        "factory": [],
        "paymaster": [],
        "account": []
      },
      "bundleGasLimitMarkup": 25000, # optional, adds some amount of additional gas to a bundle tx
      "relayingMode": "classic"; # optional, "flashbots" for Flashbots Builder API, "merkle" for Merkle.io, "kolibri" for kolibr.io
      "bundleInterval": 10000, # bundle creation interval
      "bundleSize": 4, # optional, max size of a bundle, 4 userops by default
      "pvgMarkup": 0 # optional, adds some gas on top of estimated PVG
    }
  }
}

💬 Contact

If you have any questions or feedback about the ERC-4337 Bundler project, please feel free to reach out to us.

📄 License

Licensed under the MIT License.

🤝 Shared Mempool (P2P)

Warning

This version of the bundler is not compatible with the latest p2p-spec. If you're looking to run a P2P-bundler, switch to this branch - https://github.com/etherspot/skandha/tree/version1-p2p

🔢 Statistics

Alt

🙏 Acknowledgements

skandha's People

Contributors

0xsulpiride avatar arddluma avatar ch4r10t33r avatar doublespending avatar lazycoder1 avatar omahs avatar taylorferran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skandha's Issues

[BUG] Skandha's RPC interface stores address fields without checksum

Describe the bug

Skandha's RPC interface stores address fields without checksum, however the p2p interface formats addresses into checksum format. This results in inconsistent data in the local mempool and remote mempool.

Expected behavior

Address fields should be checksummed in the RPC interface before being persisted into the local mempool

Steps to reproduce

No response

Additional context

Local_Dump: [UserOperation(sender='0x090587a70f0f69b10bad394b5f963244865225b1', nonce='0x0', initCode='0x', callData='0x', callGasLimit='0x493e0', verificationGasLimit='0xf4240', preVerificationGas='0x493e0', maxFeePerGas='0xee6b2800', maxPriorityFeePerGas='0x3b9aca00', paymasterAndData='0x', signature='0x')]`

Remote_Dump: [UserOperation(sender='0x090587a70f0f69b10BaD394B5F963244865225B1', nonce='0x0', initCode='0x', callData='0x', callGasLimit='0x493e0', verificationGasLimit='0xf4240', preVerificationGas='0x493e0', maxFeePerGas='0xee6b2800', maxPriorityFeePerGas='0x3b9aca00', paymasterAndData='0x', signature='0x')]

Operating system

macOS

Skandha version or commit hash

v1.0.6-alpha

[BUG] Issue parsing eth_call data on Bifrost nodes

Describe the bug

Getting Unexpected behavior due to not normal response returned by Bifrost node
Looks like the parsing cannot be done correctly due to different error code and message returned.

"code": -32603,
"message": "VM Exception while processing transaction: revert",

Expected behavior

How other EVM nodes returns data

{
    "jsonrpc": "2.0",
    "id": 60,
    "error": {
        "code": 3,
        "message": "execution reverted",
        "data": "0x220266b600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001b4141313320696e6974436f6465206661696c6564206f72204f4f470000000000"
    }
}

Steps to reproduce

To reproduce:
https://public-02.testnet.thebifrost.io/rpc

{
      "method": "eth_call",
      "params": [
        {
          "to": "0x91037ed7b25d72f61b80d4376c0e66680997ce5e",
          "data": "0x8cb84e18000000000000000000000000266d07bcedee855ee6c004ffc26d6cf8e924ff1a0000000000000000000000000000000000000000000000000000000000000000"
        },
        "latest"
      ],
      "id": 44,
      "jsonrpc": "2.0"
}

Additional context

How does Bifrost nodes returns:

{
    "jsonrpc": "2.0",
    "error": {
        "code": -32603,
        "message": "VM Exception while processing transaction: revert",
        "data": "0x8b7ac980000000000000000000000000000000000000000000000000000000000012fab30000000000000000000000000000000000000000000000000000000000138cfa00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000"
    },
    "id": 60
}

Operating system

macOS

Skandha version or commit hash

1.0.13-alpha

[FEATURE] Multiple executors per bundler instance

Is your feature request related to a problem? Please describe.
Single executor per bundler instance is a bottleneck.

Describe the solution you'd like

Multiple executors linked to a single instance of a bundler to facilitate parallel processing of UserOps from local mempool.

[FEATURE] Skandha needs to capture TTP metrics

Is your feature request related to a problem? Please describe.
Presently skandha doesn't capture time-to-process (TTP) metrics for each UserOp submitted to it.

Describe the solution you'd like
Skandha will need to capture TTP metrics i.e the time taken between a UserOp being submitted to the RPC endpoint to the time it is relayed to the blockchain and the time that the UserOp is processed on-chain.

[BUG] Cannot Access Associated Slot of Sender In Validation

Describe the bug

Return Error when userOp uses ERC-20 as gas token in Paymaster. When I used alchemy or stackup bundler, the case can pass.

Paymaster: 0x07865c6e87b9f70255377e024ace6630c1eaa37f
GasToken: 0x49040d242126f709b32623704e78bbe0991e6992

I suppose that it is not enough to just find onekeccak candidate: https://github.com/etherspot/skandha/blob/master/packages/executor/src/services/UserOpValidation.ts#L241

Ref other bundler implementations:

Error:
0x49040d242126f709b32623704e78bbe0991e6992 is the gas token address not a paymaster.

'{"jsonrpc":"2.0","id":44,"error":{"message":"unstaked paymaster entity 0x49040d242126f709b32623704e78bbe0991e6992 accessed slot","data":{"paymaster":"0x49040d242126f709b32623704e78bbe0991e6992"},"code":-32502}}'

Expected behavior

Success

Steps to reproduce

No response

Additional context

No response

Operating system

macOS

Skandha version or commit hash

b6e9c68

FEATURE: Archive mode

Skandha should retain UserOp hashes and UserOp receipts for atleast 24 hrs (configurable parameter). This will make it easier for lookups without having to make RPC calls to underlying bundler.

bundler-spec-tests failing

I have been trying to run bundler-spec-tests on this and they are failing, is this implementation a fully compliant implementation?
I am using eth-infinitism's bundler-spec-tests.

[FEATURE] support POA chain

Is your feature request related to a problem? Please describe.
I currently need to set unsafeMode option to bypass stake validation in order to run on POA chain.

Describe the solution you'd like
Skandha bundler should operate without the need for unsafeMode on the POA chain, I've tested it on Besu.

[BUG] Cannot Estimate Gas When Setting `maxFeePerGas` and `maxPriorityFeePerGas` as 0

Describe the bug

Return Error when calling eth_estimateUserOperationGas with valid parameters [maxFeePerGas = 0 and maxPriorityFeePerGas = 0].

I suppose that divisor will become 0 here: https://github.com/etherspot/skandha/blob/master/packages/executor/src/modules/eth.ts#L154-L157

Server Side:

[10:37:58.940] ERROR (80848): division-by-zero [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-division-by-zero ] (fault=“division-by-zero”, operation=“div”, code=NUMERIC_FAULT, version=bignumber/5.7.0)
    err: {
      “type”: “Error”,
      “message”: “division-by-zero [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-division-by-zero ] (fault=\“division-by-zero\“, operation=\“div\“, code=NUMERIC_FAULT, version=bignumber/5.7.0)“,
      “stack”:
          Error: division-by-zero [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-division-by-zero ] (fault=“division-by-zero”, operation=“div”, code=NUMERIC_FAULT, version=bignumber/5.7.0)
              at Logger.makeError (/Users/caiweizhe/Documents/fork-repo/skandha/node_modules/@ethersproject/logger/lib/index.js:238:21)
              at Logger.throwError (/Users/caiweizhe/Documents/fork-repo/skandha/node_modules/@ethersproject/logger/lib/index.js:247:20)
              at throwFault (/Users/caiweizhe/Documents/fork-repo/skandha/node_modules/@ethersproject/bignumber/lib/bignumber.js:303:19)
              at BigNumber.div (/Users/caiweizhe/Documents/fork-repo/skandha/node_modules/@ethersproject/bignumber/lib/bignumber.js:65:13)
              at Eth.estimateUserOperationGas (file:///Users/caiweizhe/Documents/fork-repo/skandha/packages/executor/lib/modules/eth.js:103:49)
              at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
              at async EthAPI.estimateUserOperationGas (file:///Users/caiweizhe/Documents/fork-repo/skandha/packages/api/lib/modules/eth.js:32:16)
              at async Object.<anonymous> (file:///Users/caiweizhe/Documents/fork-repo/skandha/packages/api/lib/app.js:118:34)
      “reason”: “division-by-zero”,
      “code”: “NUMERIC_FAULT”,
      “fault”: “division-by-zero”,
      “operation”: “div”
    }
[10:37:58.941] INFO (80848): RESPONSE ::
    reqId: “req-20"
    body: {
      “error”: “Unexpected behaviour”
    }

Client Side:

Error: bad response (status=500, headers={"vary":"Origin","access-control-allow-origin":"*","content-type":"application/json; charset=utf-8","content-length":"32","date":"Fri, 28 Jul 2023 02:37:58 GMT","connection":"close"}, body="{\"error\":\"Unexpected behaviour\"}", requestBody="{\"method\":\"eth_estimateUserOperationGas\",\"params\":[{\"sender\":\"0x8A0C6A5D9fa1aCD7c1a3Bb497c3E28C09040Ee59\",\"nonce\":\"0x0\",\"initCode\":\"0xd731d6e8e372d7edaa8ddcd1083357c66a3438485fbfb9cf000000000000000000000000c7cc285a947cf05061653f312e4b0022133e8786000000000000000000000000000000000000000000000000000425f980e3bdf5\",\"callData\":\"0x\",\"callGasLimit\":\"0x88b8\",\"verificationGasLimit\":\"0x9da155\",\"preVerificationGas\":\"0x0\",\"maxFeePerGas\":\"0x0\",\"maxPriorityFeePerGas\":\"0x0\",\"paymasterAndData\":\"0x\",\"signature\":\"0xacedeade60761d732314f3ddece87416e88474d0af21055ed557b5f9765a5ee3136c819c21c0f30b6c462610bdf8c5e6aed283a8ab664f94a3d812260bba994d1c\"},\"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789\"],\"id\":111,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="http://127.0.0.1:14337/rpc", code=SERVER_ERROR, version=web/5.7.1)

Expected behavior

Success

Steps to reproduce

No response

Additional context

No response

Operating system

macOS

Skandha version or commit hash

b6e9c68

Unable to call any bundler node path?

Im running skandha bundler node and 'im unable to call the post call just like the your hosted urls
This is my skandha bundler url : http://13.235.70.162:14337/
This is your bundler url : https://mumbai-bundler.etherspot.io/
When call get method both are working fine, when it comes to post call, its showing method not found
Screenshot 2023-12-11 at 2 31 29 PM

BUG: getUserOperationReceipt returns null when the underlying UserOp bundle has failed on-chain

Describe the bug

eth_getUserOperationReceipt returns null when the underlying UserOp bundle has failed on-chain

Expected behavior

The eth_getUserOperationReceipt call should return the actual data (with the failed transaction receipt)

Steps to reproduce

 await networkInstance.addUserOpsToBatch({ to: recipient.toLowerCase(), value: utils.parseEther(value) })
 await networkInstance.addUserOpsToBatch({ to: recipient.toLowerCase(), value: utils.parseEther(value) })

Submit a multi userop bundle on Klaytn chain and then call getUseropReceipt.

Additional context

Issue is prevelant on Klaytn chain which expects a higher gas limit bundle size.

Operating system

Linux

Skandha version or commit hash

v1.0.24-alpha

I followed the skandha docs to start the bundler, but got this error?

Screenshot 2023-12-11 at 1 57 31 PM Screenshot 2023-12-11 at 1 57 46 PM

A modular typescript implementation of ERC4337 (Account Abstraction) bundler client.
https://github.com/etherspot/skandha

Cloning Skandha repo...
fatal: destination path 'skandha' already exists and is not an empty directory.
config.json exists, proceeding with installing...

bash: line 96: yarn: command not found
Choose your mode:

  1. Standalone (run in standalone mode without p2p module)
  2. Node (run in node mode with p2p module)
    Timed out. Using default action: ./skandha standalone
    node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/ubuntu/skandha/packages/cli/lib/index.js' imported from /home/ubuntu/skandha/packages/cli/bin/skandha.js
at new NodeError (node:internal/errors:399:5)
at finalizeResolution (node:internal/modules/esm/resolve:231:11)
at moduleResolve (node:internal/modules/esm/resolve:850:10)
at defaultResolve (node:internal/modules/esm/resolve:1058:11)
at nextResolve (node:internal/modules/esm/hooks:654:28)
at Hooks.resolve (node:internal/modules/esm/hooks:309:30)
at ESMLoader.resolve (node:internal/modules/esm/loader:312:26)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:172:38)
at ESMLoader.import (node:internal/modules/esm/loader:276:22)
at importModuleDynamically (node:internal/modules/esm/translators:107:35) {
code: 'ERR_MODULE_NOT_FOUND'
}

BUG: Skandha shouldn't remove UserOp from local mempool in case of on-chain revert.

Describe the bug

Skandha presently doesn't reprocess a UserOp in case of an on-chain failure. This is incorrect.

Expected behavior

The submitted UserOp should be deleted from the local mempool only after listening to a successful UserOpEvent from the EntryPointContract.

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Skandha version or commit hash

v1.0.24-alpha

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.