Skip to content

Commit

Permalink
feat: render userOps on mempool tab
Browse files Browse the repository at this point in the history
  • Loading branch information
V00D00-child committed Jul 13, 2024
1 parent 23c3850 commit 5c8eef4
Show file tree
Hide file tree
Showing 15 changed files with 491 additions and 60 deletions.
18 changes: 10 additions & 8 deletions cmd/betsy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ import (
)

type NodeInfo struct {
EthNodeUrl string
BundlerNodeUrl string
DashboardServerUrl string
DevAccounts []wallet.DevAccount
EthNodeUrl string
BundlerNodeUrl string
DashboardServerUrl string
DevAccounts []wallet.DevAccount
PreDeployedContracts wallet.PreDeployedContracts
}

func main() {
Expand Down Expand Up @@ -259,10 +260,11 @@ func main() {

prefix := "http://localhost:"
err = printBetsyInfo(NodeInfo{
EthNodeUrl: prefix + strconv.Itoa(cCtx.Int("eth.port")),
BundlerNodeUrl: bundlerUrl,
DashboardServerUrl: prefix + strconv.Itoa(cCtx.Int("http.port")),
DevAccounts: accounts,
EthNodeUrl: prefix + strconv.Itoa(cCtx.Int("eth.port")),
BundlerNodeUrl: bundlerUrl,
DashboardServerUrl: prefix + strconv.Itoa(cCtx.Int("http.port")),
DevAccounts: accounts,
PreDeployedContracts: betsyWallet.GetPreDeployedContracts(),
})
if err != nil {
log.Err(err).Msg("Failed print Betsy info")
Expand Down
255 changes: 255 additions & 0 deletions contracts/examples/global-counter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion docs/default-accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ The response will look something like this:
```

## References:
- book of geth: https://goethereumbook.org/
- book of geth: https://goethereumbook.org/

curl -X POST --data '{"jsonrpc":"2.0","method":"debug_bundler_dumpMempool","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:4337/rpc
31 changes: 31 additions & 0 deletions docs/mempool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Mempool

Besty maintains in memory mempool by pooling the bundlers `debug_bundler_dumpMempool` rpc method.

Example:
```shell
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_bundler_dumpMempool","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:4337/rpc
```

result:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"sender": "0x0B09809bE0Cc9FA0938C934F5845A98fFfcAA155",
"nonce": "0x00",
"factory": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"factoryData": "0x5fbfb9cf00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8000000000000000000000000000000000000000000000000000000000016d826",
"callData": "0xb61d27f60000000000000000000000009fe46736679d2d9a65f0992f2272de9f3c7fa6e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000004d09de08a00000000000000000000000000000000000000000000000000000000",
"signature": "0x124ac5d541198d44fc334d7aba6fb982cd2be669fc2b7b071623f1855bf4daf34bb22a81e19cd030b6fcade74447e863fddaaac6da749cffa46aea61ad3fc6671b",
"callGasLimit": "0x574e",
"verificationGasLimit": "0x0f4240",
"preVerificationGas": "0xaf30",
"maxPriorityFeePerGas": "0x59682f00",
"maxFeePerGas": "0x667b4fca"
}
]
}
```
14 changes: 7 additions & 7 deletions internal/client/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ type BundlerClient struct {
}

type jsonrpcBase struct {
jsonrpc string
id int
Jsonrpc string `json:"jsonrpc"`
Id int `json:"id"`
}

type debugBundlerDumpMempoolRes struct {
jsonrpcBase
result []data.UserOpV7Hexify
Result []data.UserOpV7Hexify `json:"result"`
}

type debug_bundler_addUserOpsRes struct {
jsonrpcBase
result string
Result string `json:"result"`
}

func NewBundlerClient(bundlerUrl string) *BundlerClient {
Expand Down Expand Up @@ -62,7 +62,7 @@ func (b *BundlerClient) getRequest(rpcMethod string, params []interface{}) (*htt
}

func (b *BundlerClient) Debug_bundler_dumpMempool() ([]data.UserOpV7Hexify, error) {
log.Info().Msgf("Making call to bundler node debug_bundler_dumpMempool at %s", b.bundlerUrl)
log.Debug().Msgf("Making call to bundler node debug_bundler_dumpMempool at %s", b.bundlerUrl)
b.mutex.Lock()
defer b.mutex.Unlock()

Expand Down Expand Up @@ -98,11 +98,11 @@ func (b *BundlerClient) Debug_bundler_dumpMempool() ([]data.UserOpV7Hexify, erro
return nil, err
}

return data.result, nil
return data.Result, nil
}

func (b *BundlerClient) Debug_bundler_addUserOps(ops []data.UserOpV7Hexify) error {
log.Info().Msgf("Making call to bundler node debug_bundler_addUsers at %s", b.bundlerUrl)
log.Debug().Msgf("Making call to bundler node debug_bundler_addUsers at %s", b.bundlerUrl)
b.mutex.Lock()
defer b.mutex.Unlock()

Expand Down
Loading

0 comments on commit 5c8eef4

Please sign in to comment.