good morning!!!!

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • github/maticnetwork/bor
  • open/bor
2 results
Show changes
Commits on Source (6)
...@@ -13,3 +13,8 @@ jobs: ...@@ -13,3 +13,8 @@ jobs:
run: make all run: make all
- name: "Run tests" - name: "Run tests"
run: make test run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
file: ./cover.out
...@@ -50,7 +50,7 @@ ios: ...@@ -50,7 +50,7 @@ ios:
test: test:
# Skip mobile and cmd tests since they are being deprecated # Skip mobile and cmd tests since they are being deprecated
go test -v $$(go list ./... | grep -v go-ethereum/cmd/) go test -v $$(go list ./... | grep -v go-ethereum/cmd/) -cover -coverprofile=cover.out
lint: ## Run linters. lint: ## Run linters.
$(GORUN) build/ci.go lint $(GORUN) build/ci.go lint
......
...@@ -116,6 +116,9 @@ var ( ...@@ -116,6 +116,9 @@ var (
// errOutOfRangeChain is returned if an authorization list is attempted to // errOutOfRangeChain is returned if an authorization list is attempted to
// be modified via out-of-range or non-contiguous headers. // be modified via out-of-range or non-contiguous headers.
errOutOfRangeChain = errors.New("out of range or non-contiguous chain") errOutOfRangeChain = errors.New("out of range or non-contiguous chain")
// errShutdownDetected is returned if a shutdown was detected
errShutdownDetected = errors.New("shutdown detected")
) )
// SignerFn is a signer callback function to request a header to be signed by a // SignerFn is a signer callback function to request a header to be signed by a
...@@ -916,6 +919,7 @@ func (c *Bor) APIs(chain consensus.ChainHeaderReader) []rpc.API { ...@@ -916,6 +919,7 @@ func (c *Bor) APIs(chain consensus.ChainHeaderReader) []rpc.API {
// Close implements consensus.Engine. It's a noop for bor as there are no background threads. // Close implements consensus.Engine. It's a noop for bor as there are no background threads.
func (c *Bor) Close() error { func (c *Bor) Close() error {
c.HeimdallClient.Close()
return nil return nil
} }
......
...@@ -27,11 +27,13 @@ type IHeimdallClient interface { ...@@ -27,11 +27,13 @@ type IHeimdallClient interface {
Fetch(path string, query string) (*ResponseWithHeight, error) Fetch(path string, query string) (*ResponseWithHeight, error)
FetchWithRetry(path string, query string) (*ResponseWithHeight, error) FetchWithRetry(path string, query string) (*ResponseWithHeight, error)
FetchStateSyncEvents(fromID uint64, to int64) ([]*EventRecordWithTime, error) FetchStateSyncEvents(fromID uint64, to int64) ([]*EventRecordWithTime, error)
Close()
} }
type HeimdallClient struct { type HeimdallClient struct {
urlString string urlString string
client http.Client client http.Client
closeCh chan struct{}
} }
func NewHeimdallClient(urlString string) (*HeimdallClient, error) { func NewHeimdallClient(urlString string) (*HeimdallClient, error) {
...@@ -40,6 +42,7 @@ func NewHeimdallClient(urlString string) (*HeimdallClient, error) { ...@@ -40,6 +42,7 @@ func NewHeimdallClient(urlString string) (*HeimdallClient, error) {
client: http.Client{ client: http.Client{
Timeout: time.Duration(5 * time.Second), Timeout: time.Duration(5 * time.Second),
}, },
closeCh: make(chan struct{}),
} }
return h, nil return h, nil
} }
...@@ -96,13 +99,22 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo ...@@ -96,13 +99,22 @@ func (h *HeimdallClient) FetchWithRetry(rawPath string, rawQuery string) (*Respo
u.Path = rawPath u.Path = rawPath
u.RawQuery = rawQuery u.RawQuery = rawQuery
// create a new ticker for retrying the request
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
for { for {
res, err := h.internalFetch(u) select {
if err == nil && res != nil { case <-h.closeCh:
return res, nil log.Debug("Shutdown detected, terminating request")
return nil, errShutdownDetected
case <-ticker.C:
res, err := h.internalFetch(u)
if err == nil && res != nil {
return res, nil
}
log.Info("Retrying again in 5 seconds for next Heimdall data", "path", u.Path)
} }
log.Info("Retrying again in 5 seconds for next Heimdall span", "path", u.Path)
time.Sleep(5 * time.Second)
} }
} }
...@@ -137,3 +149,9 @@ func (h *HeimdallClient) internalFetch(u *url.URL) (*ResponseWithHeight, error) ...@@ -137,3 +149,9 @@ func (h *HeimdallClient) internalFetch(u *url.URL) (*ResponseWithHeight, error)
return &response, nil return &response, nil
} }
// Close sends a signal to stop the running process
func (h *HeimdallClient) Close() {
close(h.closeCh)
h.client.CloseIdleConnections()
}
...@@ -19,18 +19,4 @@ $ bor server ...@@ -19,18 +19,4 @@ $ bor server
$ bor server --config ./legacy.toml $ bor server --config ./legacy.toml
``` ```
- Modules, vhost and Cors configuration are common for all jsonrpc endpoints.
Before:
```
$ bor --http --http.modules "eth,web" --ws --ws.modules "eth,web"
```
Now:
```
$ bor server --http --ws --jsonrpc.modules "eth,web"
```
- ```Admin```, ```Personal``` and account related endpoints in ```Eth``` are being removed from the JsonRPC interface. Some of this functionality will be moved to the new GRPC server for operational tasks. - ```Admin```, ```Personal``` and account related endpoints in ```Eth``` are being removed from the JsonRPC interface. Some of this functionality will be moved to the new GRPC server for operational tasks.
...@@ -109,8 +109,6 @@ The ```bor server``` command runs the Bor client. ...@@ -109,8 +109,6 @@ The ```bor server``` command runs the Bor client.
- ```jsonrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard. - ```jsonrpc.vhosts```: Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.
- ```jsonrpc.modules```: API's offered over the HTTP-RPC interface.
- ```http```: Enable the HTTP-RPC server. - ```http```: Enable the HTTP-RPC server.
- ```http.addr```: HTTP-RPC server listening interface. - ```http.addr```: HTTP-RPC server listening interface.
...@@ -119,6 +117,8 @@ The ```bor server``` command runs the Bor client. ...@@ -119,6 +117,8 @@ The ```bor server``` command runs the Bor client.
- ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths. - ```http.rpcprefix```: HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```http.modules```: API's offered over the HTTP-RPC interface.
- ```ws```: Enable the WS-RPC server. - ```ws```: Enable the WS-RPC server.
- ```ws.addr```: WS-RPC server listening interface. - ```ws.addr```: WS-RPC server listening interface.
...@@ -127,6 +127,8 @@ The ```bor server``` command runs the Bor client. ...@@ -127,6 +127,8 @@ The ```bor server``` command runs the Bor client.
- ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths. - ```ws.rpcprefix```: HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.
- ```ws.modules```: API's offered over the WS-RPC interface.
- ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well. - ```graphql```: Enable GraphQL on the HTTP-RPC server. Note that GraphQL can only be started if an HTTP server is started as well.
### P2P Options ### P2P Options
......
...@@ -581,10 +581,12 @@ func (s *Ethereum) Stop() error { ...@@ -581,10 +581,12 @@ func (s *Ethereum) Stop() error {
// Then stop everything else. // Then stop everything else.
s.bloomIndexer.Close() s.bloomIndexer.Close()
close(s.closeBloomHandler) close(s.closeBloomHandler)
// closing consensus engine first, as miner has deps on it
s.engine.Close()
s.txPool.Stop() s.txPool.Stop()
s.miner.Close()
s.blockchain.Stop() s.blockchain.Stop()
s.engine.Close() s.miner.Close()
rawdb.PopUncleanShutdownMarker(s.chainDb) rawdb.PopUncleanShutdownMarker(s.chainDb)
s.chainDb.Close() s.chainDb.Close()
s.eventMux.Stop() s.eventMux.Stop()
......
...@@ -214,9 +214,6 @@ type JsonRPCConfig struct { ...@@ -214,9 +214,6 @@ type JsonRPCConfig struct {
// IPCPath is the path of the ipc endpoint // IPCPath is the path of the ipc endpoint
IPCPath string `hcl:"ipc-path,optional"` IPCPath string `hcl:"ipc-path,optional"`
// Modules is the list of enabled api modules
Modules []string `hcl:"modules,optional"`
// VHost is the list of valid virtual hosts // VHost is the list of valid virtual hosts
VHost []string `hcl:"vhost,optional"` VHost []string `hcl:"vhost,optional"`
...@@ -256,6 +253,9 @@ type APIConfig struct { ...@@ -256,6 +253,9 @@ type APIConfig struct {
// Host is the address to bind the api // Host is the address to bind the api
Host string `hcl:"host,optional"` Host string `hcl:"host,optional"`
// Modules is the list of enabled api modules
Modules []string `hcl:"modules,optional"`
} }
type GpoConfig struct { type GpoConfig struct {
...@@ -438,7 +438,6 @@ func DefaultConfig() *Config { ...@@ -438,7 +438,6 @@ func DefaultConfig() *Config {
JsonRPC: &JsonRPCConfig{ JsonRPC: &JsonRPCConfig{
IPCDisable: false, IPCDisable: false,
IPCPath: "", IPCPath: "",
Modules: []string{"web3", "net"},
Cors: []string{"*"}, Cors: []string{"*"},
VHost: []string{"*"}, VHost: []string{"*"},
GasCap: ethconfig.Defaults.RPCGasCap, GasCap: ethconfig.Defaults.RPCGasCap,
...@@ -448,12 +447,14 @@ func DefaultConfig() *Config { ...@@ -448,12 +447,14 @@ func DefaultConfig() *Config {
Port: 8545, Port: 8545,
Prefix: "", Prefix: "",
Host: "localhost", Host: "localhost",
Modules: []string{"web3", "net"},
}, },
Ws: &APIConfig{ Ws: &APIConfig{
Enabled: false, Enabled: false,
Port: 8546, Port: 8546,
Prefix: "", Prefix: "",
Host: "localhost", Host: "localhost",
Modules: []string{"web3", "net"},
}, },
Graphql: &APIConfig{ Graphql: &APIConfig{
Enabled: false, Enabled: false,
...@@ -851,11 +852,11 @@ func (c *Config) buildNode() (*node.Config, error) { ...@@ -851,11 +852,11 @@ func (c *Config) buildNode() (*node.Config, error) {
ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)), ListenAddr: c.P2P.Bind + ":" + strconv.Itoa(int(c.P2P.Port)),
DiscoveryV5: c.P2P.Discovery.V5Enabled, DiscoveryV5: c.P2P.Discovery.V5Enabled,
}, },
HTTPModules: c.JsonRPC.Modules, HTTPModules: c.JsonRPC.Http.Modules,
HTTPCors: c.JsonRPC.Cors, HTTPCors: c.JsonRPC.Cors,
HTTPVirtualHosts: c.JsonRPC.VHost, HTTPVirtualHosts: c.JsonRPC.VHost,
HTTPPathPrefix: c.JsonRPC.Http.Prefix, HTTPPathPrefix: c.JsonRPC.Http.Prefix,
WSModules: c.JsonRPC.Modules, WSModules: c.JsonRPC.Ws.Modules,
WSOrigins: c.JsonRPC.Cors, WSOrigins: c.JsonRPC.Cors,
WSPathPrefix: c.JsonRPC.Ws.Prefix, WSPathPrefix: c.JsonRPC.Ws.Prefix,
GraphQLCors: c.JsonRPC.Cors, GraphQLCors: c.JsonRPC.Cors,
......
...@@ -263,11 +263,6 @@ func (c *Command) Flags() *flagset.Flagset { ...@@ -263,11 +263,6 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.", Usage: "Comma separated list of virtual hostnames from which to accept requests (server enforced). Accepts '*' wildcard.",
Value: &c.cliConfig.JsonRPC.VHost, Value: &c.cliConfig.JsonRPC.VHost,
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "jsonrpc.modules",
Usage: "API's offered over the HTTP-RPC interface",
Value: &c.cliConfig.JsonRPC.Modules,
})
// http options // http options
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
...@@ -290,6 +285,12 @@ func (c *Command) Flags() *flagset.Flagset { ...@@ -290,6 +285,12 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", Usage: "HTTP path path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
Value: &c.cliConfig.JsonRPC.Http.Prefix, Value: &c.cliConfig.JsonRPC.Http.Prefix,
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "http.modules",
Usage: "API's offered over the HTTP-RPC interface",
Value: &c.cliConfig.JsonRPC.Http.Modules,
})
// ws options // ws options
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "ws", Name: "ws",
...@@ -311,6 +312,12 @@ func (c *Command) Flags() *flagset.Flagset { ...@@ -311,6 +312,12 @@ func (c *Command) Flags() *flagset.Flagset {
Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.", Usage: "HTTP path prefix on which JSON-RPC is served. Use '/' to serve on all paths.",
Value: &c.cliConfig.JsonRPC.Ws.Prefix, Value: &c.cliConfig.JsonRPC.Ws.Prefix,
}) })
f.SliceStringFlag(&flagset.SliceStringFlag{
Name: "ws.modules",
Usage: "API's offered over the WS-RPC interface",
Value: &c.cliConfig.JsonRPC.Ws.Modules,
})
// graphql options // graphql options
f.BoolFlag(&flagset.BoolFlag{ f.BoolFlag(&flagset.BoolFlag{
Name: "graphql", Name: "graphql",
......
...@@ -96,7 +96,7 @@ func NewServer(config *Config) (*Server, error) { ...@@ -96,7 +96,7 @@ func NewServer(config *Config) (*Server, error) {
// graphql is started from another place // graphql is started from another place
if config.JsonRPC.Graphql.Enabled { if config.JsonRPC.Graphql.Enabled {
if err := graphql.New(stack, backend.APIBackend, config.JsonRPC.Cors, config.JsonRPC.Modules); err != nil { if err := graphql.New(stack, backend.APIBackend, config.JsonRPC.Cors, config.JsonRPC.VHost); err != nil {
return nil, fmt.Errorf("failed to register the GraphQL service: %v", err) return nil, fmt.Errorf("failed to register the GraphQL service: %v", err)
} }
} }
......
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}
// Code generated by mockery v1.0.0. DO NOT EDIT. // Code generated by mockery v2.10.0. DO NOT EDIT.
package mocks package mocks
...@@ -12,6 +12,11 @@ type IHeimdallClient struct { ...@@ -12,6 +12,11 @@ type IHeimdallClient struct {
mock.Mock mock.Mock
} }
// Close provides a mock function with given fields:
func (_m *IHeimdallClient) Close() {
_m.Called()
}
// Fetch provides a mock function with given fields: path, query // Fetch provides a mock function with given fields: path, query
func (_m *IHeimdallClient) Fetch(path string, query string) (*bor.ResponseWithHeight, error) { func (_m *IHeimdallClient) Fetch(path string, query string) (*bor.ResponseWithHeight, error) {
ret := _m.Called(path, query) ret := _m.Called(path, query)
......