Skip to content
This repository was archived by the owner on Jun 5, 2026. It is now read-only.

Commit 873884d

Browse files
nicolae-leonte-goSatpalSandhu61chris-j-hnamtruongbaptiste-b-pegasys
authored
QLight (#1363)
* qlight: introduce the qlight protocol, the corresponding server/client handlers and the configuration/initialization logic * qlight: register server peers to the peer set to allow for graceful protocol manager shutdown * qlight poc - add support for privacy marker transaction * qlight: add rpc proxying * qlight: sort out contract extension * qlight: eliminate tx receipt checks and replace with RPC calls for private transactions which are not referenced in public chain data * qlight: transfer private block data over the RPC connection (only private data notifications remain on the P2P connection) * qlight: force max peers to 1 and disable the local P2P listener for the qlight clients * qlight: add private state root checks, restructure client cache logic * qlight: apply updates from handler.go * qlight: refactor client-side handler use pointer embedding, error on unexpected msg types, no-op tx broadcast loop * qlight: refactor server-side handler error on unexpected msg types, remove tx fetcher * qlight: refactor server-side handler remove un-initialised and unstarted downloader, add TODOs to note additional testing/checking * qlight: refactor client & server-side handlers remove unused handlers * qlight: allow qlight client to start in "raft mode" and remove raft P2P checks which ensure that the P2P node is in the raft cluster * qlight: refactor client handler remove unnecessary start/stop code for a qlight client * qlight: add NewBlockHashesMsg to the QLightServerProtocolManager to handle the end of sync block broadcast from the client * qlight: separate qlight into it's own P2P server (QP2P) on the server side, reintroduce raft peer checks * qlight: add basic tls configuration for qlight P2P * qlight: add file based permissioning to the qserver (qlight P2P server) * qlight: add client token cli parameter, one way tls for the RPC client, token validation on qlight server (if multitenancy is enabled) * qlight: transfer private block info over P2P protocol, remove RPC private block transfer code * qlight: remove server-side cache this is no longer needed as we are now pushing private block data directly to clients using the qlite p2p protocol instead of the client requesting private block data using the RPC API * qlight: cleanup & remove eth_getQuorumPayloadsForBlock API * qlight: remove unnecessary intermediary type for private data Fields were converted to strings, transported, and then converted back to byte slices etc. * qlight: add transaction notifications as empty txs in the client cache (they are overwritten when private block data arrives) * Fix error message formatting which was breaking unit test. * qlight: move qlight initialization logic to private.InitializeConection * qlight: remove RegisterIdlePeer and disconnect when a qlight server connects to another qlight server * qlight: move tls.Config construction to the qlight package * qlight: decouple private block data retrieval and authorisation from qlight_server_handler * qlight: introduce the qlight protocol, the corresponding server/client handlers and the configuration/initialization logic * qlight: add rpc proxying * qlight: register server peers to the peer set to allow for graceful protocol manager shutdown * qlight: sort out contract extension * qlight: eliminate tx receipt checks and replace with RPC calls for private transactions which are not referenced in public chain data * qlight: transfer private block data over the RPC connection (only private data notifications remain on the P2P connection) * qlight: add private state root checks, restructure client cache logic * qlight: allow qlight client to start in "raft mode" and remove raft P2P checks which ensure that the P2P node is in the raft cluster * qlight: separate qlight into it's own P2P server (QP2P) on the server side, reintroduce raft peer checks * qlight: add file based permissioning to the qserver (qlight P2P server) * qlight: transfer private block info over P2P protocol, remove RPC private block transfer code * qlight: remove server-side cache this is no longer needed as we are now pushing private block data directly to clients using the qlite p2p protocol instead of the client requesting private block data using the RPC API * qlight: cleanup & remove eth_getQuorumPayloadsForBlock API * qlight: remove unnecessary intermediary type for private data Fields were converted to strings, transported, and then converted back to byte slices etc. * qlight: unit tests for clientCache and PrivateBlockDataResolver * qlight: fix lint issues * qlight: add auth provider tests * qlight: move qlight p2p config properties under the qlight.server.p2p prefix * qlight: add caching proxy tests * qlight: rebase and handler rewrite * qlight: add extra tls config params * Separate qlight client options for clarity * Correction to description of qlight maxpeers option. * qlight: allow qlight to cope with un-retrievable private state roots caused by enabling the private state cache on the qlight server * qlight: cleanup * qlight: introduce periodic checks for the qlight client token (on the qlight server) * qlight: fix config unit tests * qlight: refactor qlight config logic * qlight: fix rpc tls client config * use only 1 cacert config * qlight: error handling and constants * qlight: allow the client token to be updated in a running process * use disallowed wording * structure qlight client config * qlight: fix ExtraMetadata rlp decoding (initialize ACHashes map) * qlight: add auth token config params * qlight: merge fixes * qlight: remove unnecessary break stmts * Update eth/protocols/qlight/broadcast.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * qlight: use inclusive terms (black listed -> disallowed) * qlight: fix case statements * Update cmd/geth/config.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update cmd/geth/config.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update cmd/geth/config.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update internal/ethapi/proxy_api.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update eth/handler_qlight_client.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update internal/ethapi/proxy_api.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update internal/ethapi/proxy_api.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update internal/ethapi/proxy_api.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update node/config.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * Update node/node.go Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> * qlight: review feedback * qlight: add pmt unit test * qlight: add pmt unit test (check returned err) Co-authored-by: SatpalSandhu61 <quorum@satpal.co.uk> Co-authored-by: chris <chrishounsom@icloud.com> Co-authored-by: Nam Truong <nam.p.truong@outlook.com> Co-authored-by: baptiste-b-pegasys <85155432+baptiste-b-pegasys@users.noreply.github.com> Co-authored-by: Antony Denyer <email@antonydenyer.co.uk> Co-authored-by: Krish Swaminathan <39480483+Krish1979@users.noreply.github.com>
1 parent 551d69b commit 873884d

60 files changed

Lines changed: 4807 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/geth/config.go

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"bufio"
21+
"crypto/tls"
2122
"errors"
2223
"fmt"
2324
"math/big"
@@ -34,9 +35,13 @@ import (
3435
"github.com/ethereum/go-ethereum/log"
3536
"github.com/ethereum/go-ethereum/metrics"
3637
"github.com/ethereum/go-ethereum/node"
38+
"github.com/ethereum/go-ethereum/p2p"
39+
"github.com/ethereum/go-ethereum/p2p/enode"
3740
"github.com/ethereum/go-ethereum/params"
41+
"github.com/ethereum/go-ethereum/permission/core"
3842
"github.com/ethereum/go-ethereum/private"
3943
"github.com/ethereum/go-ethereum/private/engine"
44+
"github.com/ethereum/go-ethereum/qlight"
4045
"github.com/naoina/toml"
4146
"gopkg.in/urfave/cli.v1"
4247
)
@@ -135,6 +140,8 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
135140

136141
// Apply flags.
137142
utils.SetNodeConfig(ctx, &cfg.Node)
143+
utils.SetQLightConfig(ctx, &cfg.Node, &cfg.Eth)
144+
138145
stack, err := node.New(&cfg.Node)
139146
if err != nil {
140147
utils.Fatalf("Failed to create the protocol stack: %v", err)
@@ -144,10 +151,74 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, gethConfig) {
144151
cfg.Ethstats.URL = ctx.GlobalString(utils.EthStatsURLFlag.Name)
145152
}
146153
applyMetricConfig(ctx, &cfg)
154+
if cfg.Eth.QuorumLightServer {
155+
p2p.SetQLightTLSConfig(readQLightServerTLSConfig(ctx))
156+
// permissioning for the qlight P2P server
157+
stack.QServer().SetNewTransportFunc(p2p.NewQlightServerTransport)
158+
if ctx.GlobalIsSet(utils.QuorumLightServerP2PPermissioningFlag.Name) {
159+
prefix := "qlight"
160+
if ctx.GlobalIsSet(utils.QuorumLightServerP2PPermissioningPrefixFlag.Name) {
161+
prefix = ctx.GlobalString(utils.QuorumLightServerP2PPermissioningPrefixFlag.Name)
162+
}
163+
fbp := core.NewFileBasedPermissoningWithPrefix(prefix)
164+
stack.QServer().SetIsNodePermissioned(fbp.IsNodePermissionedEnode)
165+
}
166+
}
167+
if cfg.Eth.QuorumLightClient.Enabled() {
168+
p2p.SetQLightTLSConfig(readQLightClientTLSConfig(ctx))
169+
stack.Server().SetNewTransportFunc(p2p.NewQlightClientTransport)
170+
}
147171

148172
return stack, cfg
149173
}
150174

175+
func readQLightClientTLSConfig(ctx *cli.Context) *tls.Config {
176+
if !ctx.GlobalIsSet(utils.QuorumLightTLSFlag.Name) {
177+
return nil
178+
}
179+
if !ctx.GlobalIsSet(utils.QuorumLightTLSCACertsFlag.Name) {
180+
utils.Fatalf("QLight tls flag is set but no client certificate authorities has been provided")
181+
}
182+
tlsConfig, err := qlight.NewTLSConfig(&qlight.TLSConfig{
183+
CACertFileName: ctx.GlobalString(utils.QuorumLightTLSCACertsFlag.Name),
184+
CertFileName: ctx.GlobalString(utils.QuorumLightTLSCertFlag.Name),
185+
KeyFileName: ctx.GlobalString(utils.QuorumLightTLSKeyFlag.Name),
186+
ServerName: enode.MustParse(ctx.GlobalString(utils.QuorumLightClientServerNodeFlag.Name)).IP().String(),
187+
CipherSuites: ctx.GlobalString(utils.QuorumLightTLSCipherSuitesFlag.Name),
188+
})
189+
190+
if err != nil {
191+
utils.Fatalf("Unable to load the specified tls configuration: %v", err)
192+
}
193+
return tlsConfig
194+
}
195+
196+
func readQLightServerTLSConfig(ctx *cli.Context) *tls.Config {
197+
if !ctx.GlobalIsSet(utils.QuorumLightTLSFlag.Name) {
198+
return nil
199+
}
200+
if !ctx.GlobalIsSet(utils.QuorumLightTLSCertFlag.Name) {
201+
utils.Fatalf("QLight TLS is enabled but no server certificate has been provided")
202+
}
203+
if !ctx.GlobalIsSet(utils.QuorumLightTLSKeyFlag.Name) {
204+
utils.Fatalf("QLight TLS is enabled but no server key has been provided")
205+
}
206+
207+
tlsConfig, err := qlight.NewTLSConfig(&qlight.TLSConfig{
208+
CertFileName: ctx.GlobalString(utils.QuorumLightTLSCertFlag.Name),
209+
KeyFileName: ctx.GlobalString(utils.QuorumLightTLSKeyFlag.Name),
210+
ClientCACertFileName: ctx.GlobalString(utils.QuorumLightTLSCACertsFlag.Name),
211+
ClientAuth: ctx.GlobalInt(utils.QuorumLightTLSClientAuthFlag.Name),
212+
CipherSuites: ctx.GlobalString(utils.QuorumLightTLSCipherSuitesFlag.Name),
213+
})
214+
215+
if err != nil {
216+
utils.Fatalf("QLight TLS - unable to read server tls configuration: %v", err)
217+
}
218+
219+
return tlsConfig
220+
}
221+
151222
// makeFullNode loads geth configuration and creates the Ethereum backend.
152223
func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
153224
stack, cfg := makeConfigNode(ctx)
@@ -174,7 +245,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
174245
utils.RegisterPermissionService(stack, ctx.Bool(utils.RaftDNSEnabledFlag.Name), backend.ChainConfig().ChainID)
175246
}
176247

177-
if ctx.GlobalBool(utils.RaftModeFlag.Name) {
248+
if ctx.GlobalBool(utils.RaftModeFlag.Name) && !cfg.Eth.QuorumLightClient.Enabled() {
178249
utils.RegisterRaftService(stack, ctx, &cfg.Node, ethService)
179250
}
180251

@@ -296,7 +367,7 @@ func quorumInitialisePrivacy(ctx *cli.Context) error {
296367
return err
297368
}
298369

299-
err = private.InitialiseConnection(cfg)
370+
err = private.InitialiseConnection(cfg, ctx.GlobalIsSet(utils.QuorumLightClientFlag.Name))
300371
if err != nil {
301372
return err
302373
}

cmd/geth/main.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,30 @@ var (
190190
utils.QuorumPTMTlsClientCertFlag,
191191
utils.QuorumPTMTlsClientKeyFlag,
192192
utils.QuorumPTMTlsInsecureSkipVerify,
193+
utils.QuorumLightServerFlag,
194+
utils.QuorumLightServerP2PListenPortFlag,
195+
utils.QuorumLightServerP2PMaxPeersFlag,
196+
utils.QuorumLightServerP2PNetrestrictFlag,
197+
utils.QuorumLightServerP2PPermissioningFlag,
198+
utils.QuorumLightServerP2PPermissioningPrefixFlag,
199+
utils.QuorumLightClientFlag,
200+
utils.QuorumLightClientPSIFlag,
201+
utils.QuorumLightClientTokenEnabledFlag,
202+
utils.QuorumLightClientTokenValueFlag,
203+
utils.QuorumLightClientTokenManagementFlag,
204+
utils.QuorumLightClientRPCTLSFlag,
205+
utils.QuorumLightClientRPCTLSInsecureSkipVerifyFlag,
206+
utils.QuorumLightClientRPCTLSCACertFlag,
207+
utils.QuorumLightClientRPCTLSCertFlag,
208+
utils.QuorumLightClientRPCTLSKeyFlag,
209+
utils.QuorumLightClientServerNodeFlag,
210+
utils.QuorumLightClientServerNodeRPCFlag,
211+
utils.QuorumLightTLSFlag,
212+
utils.QuorumLightTLSCertFlag,
213+
utils.QuorumLightTLSKeyFlag,
214+
utils.QuorumLightTLSCACertsFlag,
215+
utils.QuorumLightTLSClientAuthFlag,
216+
utils.QuorumLightTLSCipherSuitesFlag,
193217
// End-Quorum
194218
}
195219

cmd/geth/usage.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,35 @@ var AppHelpFlagGroups = []flags.FlagGroup{
257257
utils.QuorumEnablePrivacyMarker,
258258
},
259259
},
260+
{
261+
Name: "QUORUM LIGHT CLIENT/SERVER",
262+
Flags: []cli.Flag{
263+
utils.QuorumLightServerFlag,
264+
utils.QuorumLightServerP2PListenPortFlag,
265+
utils.QuorumLightServerP2PMaxPeersFlag,
266+
utils.QuorumLightServerP2PNetrestrictFlag,
267+
utils.QuorumLightServerP2PPermissioningFlag,
268+
utils.QuorumLightServerP2PPermissioningPrefixFlag,
269+
utils.QuorumLightClientFlag,
270+
utils.QuorumLightClientPSIFlag,
271+
utils.QuorumLightClientTokenEnabledFlag,
272+
utils.QuorumLightClientTokenValueFlag,
273+
utils.QuorumLightClientTokenManagementFlag,
274+
utils.QuorumLightClientRPCTLSFlag,
275+
utils.QuorumLightClientRPCTLSInsecureSkipVerifyFlag,
276+
utils.QuorumLightClientRPCTLSCACertFlag,
277+
utils.QuorumLightClientRPCTLSCertFlag,
278+
utils.QuorumLightClientRPCTLSKeyFlag,
279+
utils.QuorumLightClientServerNodeFlag,
280+
utils.QuorumLightClientServerNodeRPCFlag,
281+
utils.QuorumLightTLSFlag,
282+
utils.QuorumLightTLSCertFlag,
283+
utils.QuorumLightTLSKeyFlag,
284+
utils.QuorumLightTLSCACertsFlag,
285+
utils.QuorumLightTLSClientAuthFlag,
286+
utils.QuorumLightTLSCipherSuitesFlag,
287+
},
288+
},
260289
{
261290
Name: "QUORUM PRIVATE TRANSACTION MANAGER",
262291
Flags: []cli.Flag{

0 commit comments

Comments
 (0)