erigon-pulse/cmd/rpcdaemon/commands/daemon.go
ledgerwatch 8e3ac8a21c
Erigon2 upgrade 2 prototype (#4341)
* Erigon2 upgrade 2 prototype

* Latest erigon-lib

* Fixes

* Fix print

* Fix maxSpan

* Reduce maxSpan

* Remove duplicate joins

* TxNum

* Fix resuming

* first draft of history22

* Introduce historical reads

* Update to erigon-lib

* Update erigon-lib

* Update erigon-lib

* Fixes and tracing for checkChangeSets

* More trace

* Print account details

* fix getHeader

* Update to erigon-lib main

* Add tracer indices and event log indices

* Fix calltracer

* Fix calltracer

* Duplicate rpcdaemon into rpcdaemon22

* Fix tests

* Fix tests

* Fix tests

* Update to latest erigon-lib

Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2022-06-10 16:18:43 +01:00

135 lines
3.5 KiB
Go

package commands
import (
"github.com/ledgerwatch/erigon-lib/gointerfaces/starknet"
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon-lib/kv/kvcache"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/cli/httpcfg"
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/rpchelper"
"github.com/ledgerwatch/erigon/turbo/services"
)
// APIList describes the list of available RPC apis
func APIList(db kv.RoDB, borDb kv.RoDB, eth rpchelper.ApiBackend, txPool txpool.TxpoolClient, mining txpool.MiningClient,
starknet starknet.CAIROVMClient, filters *rpchelper.Filters, stateCache kvcache.Cache,
blockReader services.FullBlockReader, cfg httpcfg.HttpCfg) (list []rpc.API) {
base := NewBaseApi(filters, stateCache, blockReader, cfg.WithDatadir)
if cfg.TevmEnabled {
base.EnableTevmExperiment()
}
ethImpl := NewEthAPI(base, db, eth, txPool, mining, cfg.Gascap)
erigonImpl := NewErigonAPI(base, db, eth)
starknetImpl := NewStarknetAPI(base, db, starknet, txPool)
txpoolImpl := NewTxPoolAPI(base, db, txPool)
netImpl := NewNetAPIImpl(eth)
debugImpl := NewPrivateDebugAPI(base, db, cfg.Gascap)
traceImpl := NewTraceAPI(base, db, &cfg)
web3Impl := NewWeb3APIImpl(eth)
dbImpl := NewDBAPIImpl() /* deprecated */
engineImpl := NewEngineAPI(base, db, eth)
adminImpl := NewAdminAPI(eth)
parityImpl := NewParityAPIImpl(db)
borImpl := NewBorAPI(base, db, borDb) // bor (consensus) specific
for _, enabledAPI := range cfg.API {
switch enabledAPI {
case "eth":
list = append(list, rpc.API{
Namespace: "eth",
Public: true,
Service: EthAPI(ethImpl),
Version: "1.0",
})
case "debug":
list = append(list, rpc.API{
Namespace: "debug",
Public: true,
Service: PrivateDebugAPI(debugImpl),
Version: "1.0",
})
case "net":
list = append(list, rpc.API{
Namespace: "net",
Public: true,
Service: NetAPI(netImpl),
Version: "1.0",
})
case "txpool":
list = append(list, rpc.API{
Namespace: "txpool",
Public: true,
Service: TxPoolAPI(txpoolImpl),
Version: "1.0",
})
case "web3":
list = append(list, rpc.API{
Namespace: "web3",
Public: true,
Service: Web3API(web3Impl),
Version: "1.0",
})
case "trace":
list = append(list, rpc.API{
Namespace: "trace",
Public: true,
Service: TraceAPI(traceImpl),
Version: "1.0",
})
case "db": /* Deprecated */
list = append(list, rpc.API{
Namespace: "db",
Public: true,
Service: DBAPI(dbImpl),
Version: "1.0",
})
case "erigon":
list = append(list, rpc.API{
Namespace: "erigon",
Public: true,
Service: ErigonAPI(erigonImpl),
Version: "1.0",
})
case "starknet":
list = append(list, rpc.API{
Namespace: "starknet",
Public: true,
Service: StarknetAPI(starknetImpl),
Version: "1.0",
})
case "engine":
list = append(list, rpc.API{
Namespace: "engine",
Public: true,
Service: EngineAPI(engineImpl),
Version: "1.0",
})
case "bor":
list = append(list, rpc.API{
Namespace: "bor",
Public: true,
Service: BorAPI(borImpl),
Version: "1.0",
})
case "admin":
list = append(list, rpc.API{
Namespace: "admin",
Public: false,
Service: AdminAPI(adminImpl),
Version: "1.0",
})
case "parity":
list = append(list, rpc.API{
Namespace: "parity",
Public: false,
Service: ParityAPI(parityImpl),
Version: "1.0",
})
}
}
return list
}