Skip to content

Commit 2186caf

Browse files
feat(dot/rpc): implement sync_state_genSyncSpec RPC call (#1827)
1 parent 7abcce6 commit 2186caf

File tree

19 files changed

+182
-23
lines changed

19 files changed

+182
-23
lines changed

chain/dev/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ enabled = true
3636
ws = true
3737
port = 8545
3838
host = "localhost"
39-
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"]
39+
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"]
4040
ws-port = 8546

chain/dev/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var (
8787
// DefaultRPCHTTPPort rpc port
8888
DefaultRPCHTTPPort = uint32(8545)
8989
// DefaultRPCModules rpc modules
90-
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"}
90+
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
9191
// DefaultRPCWSPort rpc websocket port
9292
DefaultRPCWSPort = uint32(8546)
9393
// DefaultRPCEnabled enables the RPC server

chain/gssmr/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ min-peers = 1
3636
enabled = false
3737
port = 8545
3838
host = "localhost"
39-
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"]
39+
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"]
4040
ws-port = 8546

chain/gssmr/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var (
9494
// DefaultRPCHTTPPort rpc port
9595
DefaultRPCHTTPPort = uint32(8545)
9696
// DefaultRPCModules rpc modules
97-
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"}
97+
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
9898
// DefaultRPCWSPort rpc websocket port
9999
DefaultRPCWSPort = uint32(8546)
100100
)

chain/kusama/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enabled = false
3535
external = false
3636
port = 8545
3737
host = "localhost"
38-
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"]
38+
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"]
3939
ws-port = 8546
4040
ws = false
4141
ws-external = false

chain/kusama/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ var (
8383
// DefaultRPCHTTPPort rpc port
8484
DefaultRPCHTTPPort = uint32(8545)
8585
// DefaultRPCModules rpc modules
86-
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"}
86+
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
8787
// DefaultRPCWSPort rpc websocket port
8888
DefaultRPCWSPort = uint32(8546)
8989
)

chain/polkadot/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ nomdns = false
3434
enabled = false
3535
port = 8545
3636
host = "localhost"
37-
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"]
37+
modules = ["system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"]
3838
ws-port = 8546

chain/polkadot/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ var (
8484
// DefaultRPCHTTPPort rpc port
8585
DefaultRPCHTTPPort = uint32(8545)
8686
// DefaultRPCModules rpc modules
87-
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "payment"}
87+
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
8888
// DefaultRPCWSPort rpc websocket port
8989
DefaultRPCWSPort = uint32(8546)
9090
)

dot/build_spec.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,9 @@ func BuildFromDB(path string) (*BuildSpec, error) {
142142
}
143143
tmpGen.Name = gData.Name
144144
tmpGen.ID = gData.ID
145-
tmpGen.Bootnodes = make([]string, len(gData.Bootnodes))
145+
tmpGen.Bootnodes = common.BytesToStringArray(gData.Bootnodes)
146146
tmpGen.ProtocolID = gData.ProtocolID
147147

148-
for i, bn := range gData.Bootnodes {
149-
tmpGen.Bootnodes[i] = string(bn)
150-
}
151-
152148
bs := &BuildSpec{
153149
genesis: tmpGen,
154150
}

dot/node.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
"github.com/ChainSafe/gossamer/dot/metrics"
3232
"github.com/ChainSafe/gossamer/dot/network"
33+
"github.com/ChainSafe/gossamer/dot/rpc"
3334
"github.com/ChainSafe/gossamer/dot/state"
3435
"github.com/ChainSafe/gossamer/dot/state/pruner"
3536
"github.com/ChainSafe/gossamer/dot/telemetry"
@@ -313,7 +314,11 @@ func NewNode(cfg *Config, ks *keystore.GlobalKeystore, stopFunc func()) (*Node,
313314

314315
// check if rpc service is enabled
315316
if enabled := cfg.RPC.isRPCEnabled() || cfg.RPC.isWSEnabled(); enabled {
316-
rpcSrvc := createRPCService(cfg, ns, stateSrvc, coreSrvc, networkSrvc, bp, sysSrvc, fg)
317+
var rpcSrvc *rpc.HTTPServer
318+
rpcSrvc, err = createRPCService(cfg, ns, stateSrvc, coreSrvc, networkSrvc, bp, sysSrvc, fg)
319+
if err != nil {
320+
return nil, fmt.Errorf("failed to create rpc service: %s", err)
321+
}
317322
nodeSrvcs = append(nodeSrvcs, rpcSrvc)
318323
} else {
319324
logger.Debug("rpc service disabled by default", "rpc", enabled)

0 commit comments

Comments
 (0)