mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 18:37:26 +08:00
* Update qcommander.sh bootrap (#304) * v2.0.1 (#308) * roll up v2.0.1-b2 to develop * b2-fixed * adjust return data of fast sync so it doesn't return the earliest frame * -b3 * fix: announce peer based on leading frame, not initial frame; fix: looping bug * fix: last batch fails due to underflow; qol: make logging chattier * -b4 * resolve frame cache issue * fix: mint loop + re-migrate * fix: register execution panic * fix: mint loop, other side * fix: handle unexpected return of nil status * final -b4 * handle subtle change to migration * qol: add heuristic to handle corruption scenario * bump genesis * qol: use separate channel for worker * final parameterization, parallelize streams * deprecate signers 10, 11, 14, 17 * adjust signatory check size to match rotated out signers * V2.0.2.3 (#321) * roll up v2.0.1-b2 to develop * b2-fixed * adjust return data of fast sync so it doesn't return the earliest frame * -b3 * fix: announce peer based on leading frame, not initial frame; fix: looping bug * fix: last batch fails due to underflow; qol: make logging chattier * -b4 * resolve frame cache issue * fix: mint loop + re-migrate * fix: register execution panic * fix: mint loop, other side * fix: handle unexpected return of nil status * final -b4 * handle subtle change to migration * qol: add heuristic to handle corruption scenario * bump genesis * qol: use separate channel for worker * final parameterization, parallelize streams * Add direct peers to blossomsub (#309) Co-authored-by: Tyler Sturos <tyler.john@qcommander.sh> * chore(docker): add ca-certificates to fix x509 error. (#307) * Update qcommander.sh bootrap (#304) * chore(docker): add ca-certificates to fix x509 error. --------- Co-authored-by: Tyler Sturos <55340199+tjsturos@users.noreply.github.com> * deprecate signers 10, 11, 14, 17 * adjust signatory check size to match rotated out signers * qol: sync by rebroadcast * upgrade version * more small adjustments * wait a little longer * fix: don't use iterator for frame directly until iterator is fixed * change iterator, genesis for testnet * adjust to previous sync handling * adjust: don't grab the very latest while it's already being broadcasted * ok, ready for testnet * handle rebroadcast quirks * more adjustments from testing * faster * temporarily bulk process on frame candidates * resolve separate frames * don't loop * make worker reset resume to check where it should continue * move window * reduce signature count now that supermajority signed last * resolve bottlenecks * remove GOMAXPROCS limit for now * revisions for v2.0.2.1 * bump version * bulk import * reintroduce sync * small adustments to make life better * check bitmask for peers and keep alive * adjust reconnect * ensure peer doesn't fall off address list * adjust blossomsub to background discovery * bump version * remove dev check * remove debug log line * further adjustments * a little more logic around connection management * v2.0.2.3 * Fix peer discovery (#319) * Fix peer discovery * Make peer discovery connections parallel * Monitor peers via pings (#317) * Support QUILIBRIUM_SIGNATURE_CHECK in client (#314) * Ensure direct peers are not pruned by resource limits (#315) * Support pprof profiling via HTTP (#313) * Fix CPU profiling * Add pprof server support * Additional peering connection improvements (#320) * Lookup peers if not enough external peers are available * Make bootstrap peer discovery sensitive to a lack of bootstrappers --------- Co-authored-by: Tyler Sturos <55340199+tjsturos@users.noreply.github.com> Co-authored-by: Tyler Sturos <tyler.john@qcommander.sh> Co-authored-by: linquanisaac <33619994+linquanisaac@users.noreply.github.com> Co-authored-by: petricadaipegsp <155911522+petricadaipegsp@users.noreply.github.com> --------- Co-authored-by: Tyler Sturos <55340199+tjsturos@users.noreply.github.com> Co-authored-by: Tyler Sturos <tyler.john@qcommander.sh> Co-authored-by: linquanisaac <33619994+linquanisaac@users.noreply.github.com> Co-authored-by: petricadaipegsp <155911522+petricadaipegsp@users.noreply.github.com>
188 lines
4.2 KiB
Go
188 lines
4.2 KiB
Go
package cmd
|
||
|
||
import (
|
||
"bytes"
|
||
"crypto/tls"
|
||
"encoding/hex"
|
||
"fmt"
|
||
"os"
|
||
"strconv"
|
||
"strings"
|
||
|
||
"github.com/cloudflare/circl/sign/ed448"
|
||
"github.com/multiformats/go-multiaddr"
|
||
mn "github.com/multiformats/go-multiaddr/net"
|
||
"github.com/spf13/cobra"
|
||
"golang.org/x/crypto/sha3"
|
||
"google.golang.org/grpc"
|
||
"google.golang.org/grpc/credentials"
|
||
"google.golang.org/grpc/credentials/insecure"
|
||
"source.quilibrium.com/quilibrium/monorepo/node/config"
|
||
)
|
||
|
||
var configDirectory string
|
||
var signatureCheck bool = true
|
||
var NodeConfig *config.Config
|
||
var simulateFail bool
|
||
var LightNode bool = false
|
||
var DryRun bool = false
|
||
|
||
var rootCmd = &cobra.Command{
|
||
Use: "qclient",
|
||
Short: "Quilibrium RPC Client",
|
||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||
if signatureCheck {
|
||
ex, err := os.Executable()
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
b, err := os.ReadFile(ex)
|
||
if err != nil {
|
||
fmt.Println(
|
||
"Error encountered during signature check – are you running this " +
|
||
"from source? (use --signature-check=false)",
|
||
)
|
||
panic(err)
|
||
}
|
||
|
||
checksum := sha3.Sum256(b)
|
||
digest, err := os.ReadFile(ex + ".dgst")
|
||
if err != nil {
|
||
fmt.Println("Digest file not found")
|
||
os.Exit(1)
|
||
}
|
||
|
||
parts := strings.Split(string(digest), " ")
|
||
if len(parts) != 2 {
|
||
fmt.Println("Invalid digest file format")
|
||
os.Exit(1)
|
||
}
|
||
|
||
digestBytes, err := hex.DecodeString(parts[1][:64])
|
||
if err != nil {
|
||
fmt.Println("Invalid digest file format")
|
||
os.Exit(1)
|
||
}
|
||
|
||
if !bytes.Equal(checksum[:], digestBytes) {
|
||
fmt.Println("Invalid digest for node")
|
||
os.Exit(1)
|
||
}
|
||
|
||
count := 0
|
||
|
||
for i := 1; i <= len(config.Signatories); i++ {
|
||
signatureFile := fmt.Sprintf(ex+".dgst.sig.%d", i)
|
||
sig, err := os.ReadFile(signatureFile)
|
||
if err != nil {
|
||
continue
|
||
}
|
||
|
||
pubkey, _ := hex.DecodeString(config.Signatories[i-1])
|
||
if !ed448.Verify(pubkey, digest, sig, "") {
|
||
fmt.Printf("Failed signature check for signatory #%d\n", i)
|
||
os.Exit(1)
|
||
}
|
||
count++
|
||
}
|
||
|
||
if count < ((len(config.Signatories)-4)/2)+((len(config.Signatories)-4)%2) {
|
||
fmt.Printf("Quorum on signatures not met")
|
||
os.Exit(1)
|
||
}
|
||
|
||
fmt.Println("Signature check passed")
|
||
} else {
|
||
fmt.Println("Signature check bypassed, be sure you know what you're doing")
|
||
}
|
||
|
||
_, err := os.Stat(configDirectory)
|
||
if os.IsNotExist(err) {
|
||
fmt.Printf("config directory doesn't exist: %s\n", configDirectory)
|
||
os.Exit(1)
|
||
}
|
||
|
||
NodeConfig, err = config.LoadConfig(configDirectory, "", false)
|
||
if err != nil {
|
||
fmt.Printf("invalid config directory: %s\n", configDirectory)
|
||
os.Exit(1)
|
||
}
|
||
|
||
if NodeConfig.ListenGRPCMultiaddr == "" {
|
||
fmt.Println("gRPC not enabled, using light node")
|
||
LightNode = true
|
||
}
|
||
},
|
||
}
|
||
|
||
func Execute() {
|
||
err := rootCmd.Execute()
|
||
if err != nil {
|
||
os.Exit(1)
|
||
}
|
||
}
|
||
|
||
func GetGRPCClient() (*grpc.ClientConn, error) {
|
||
addr := "rpc.quilibrium.com:8337"
|
||
credentials := credentials.NewTLS(&tls.Config{InsecureSkipVerify: false})
|
||
if !LightNode {
|
||
ma, err := multiaddr.NewMultiaddr(NodeConfig.ListenGRPCMultiaddr)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
|
||
_, addr, err = mn.DialArgs(ma)
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
credentials = insecure.NewCredentials()
|
||
}
|
||
|
||
return grpc.Dial(
|
||
addr,
|
||
grpc.WithTransportCredentials(
|
||
credentials,
|
||
),
|
||
grpc.WithDefaultCallOptions(
|
||
grpc.MaxCallSendMsgSize(600*1024*1024),
|
||
grpc.MaxCallRecvMsgSize(600*1024*1024),
|
||
),
|
||
)
|
||
}
|
||
|
||
func signatureCheckDefault() bool {
|
||
envVarValue, envVarExists := os.LookupEnv("QUILIBRIUM_SIGNATURE_CHECK")
|
||
if envVarExists {
|
||
def, err := strconv.ParseBool(envVarValue)
|
||
if err == nil {
|
||
return def
|
||
} else {
|
||
fmt.Println("Invalid environment variable QUILIBRIUM_SIGNATURE_CHECK, must be 'true' or 'false'. Got: " + envVarValue)
|
||
}
|
||
}
|
||
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
rootCmd.PersistentFlags().StringVar(
|
||
&configDirectory,
|
||
"config",
|
||
".config/",
|
||
"config directory (default is .config/)",
|
||
)
|
||
rootCmd.PersistentFlags().BoolVar(
|
||
&DryRun,
|
||
"dry-run",
|
||
false,
|
||
"runs the command (if applicable) without actually mutating state (printing effect output)",
|
||
)
|
||
rootCmd.PersistentFlags().BoolVar(
|
||
&signatureCheck,
|
||
"signature-check",
|
||
signatureCheckDefault(),
|
||
"bypass signature check (not recommended for binaries) (default true or value of QUILIBRIUM_SIGNATURE_CHECK env var)",
|
||
)
|
||
}
|