mirror of
https://source.quilibrium.com/quilibrium/ceremonyclient.git
synced 2024-12-25 16:15:17 +00:00
v1.1.7 – Improved DB Console, future fix for bloom utils (#26)
This commit is contained in:
parent
a19d1490ea
commit
00a471e84d
@ -1,195 +1,822 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"github.com/libp2p/go-libp2p/core/crypto"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
mn "github.com/multiformats/go-multiaddr/net"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/sha3"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"golang.org/x/term"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/connectivity"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/config"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/execution/ceremony/application"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/store"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
|
||||
"source.quilibrium.com/quilibrium/monorepo/node/tries"
|
||||
)
|
||||
|
||||
var (
|
||||
textColor = lipgloss.Color("#fff")
|
||||
primaryColor = lipgloss.Color("#ff0070")
|
||||
secondaryColor = lipgloss.Color("#ff5c00")
|
||||
windowHeader = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Padding(0, 1)
|
||||
unselectedListStyle = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Width(28).
|
||||
Padding(0, 1)
|
||||
navigatedListStyle = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Width(28).
|
||||
Bold(true).
|
||||
Padding(0, 1)
|
||||
selectedListStyle = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Background(primaryColor).
|
||||
Width(28).
|
||||
Padding(0, 1)
|
||||
statusBarStyle = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Background(primaryColor)
|
||||
statusStyle = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Background(primaryColor).
|
||||
Padding(0, 1)
|
||||
statusItemStyle = lipgloss.NewStyle().
|
||||
Foreground(textColor).
|
||||
Background(secondaryColor).
|
||||
Padding(0, 1)
|
||||
docStyle = lipgloss.NewStyle().Padding(0)
|
||||
border = lipgloss.Border{
|
||||
Top: "─",
|
||||
Bottom: "─",
|
||||
Left: "│",
|
||||
Right: "│",
|
||||
TopLeft: "┌",
|
||||
TopRight: "┐",
|
||||
BottomLeft: "└",
|
||||
BottomRight: "┘",
|
||||
}
|
||||
)
|
||||
|
||||
type DBConsole struct {
|
||||
clockStore store.ClockStore
|
||||
dataProofStore store.DataProofStore
|
||||
nodeConfig *config.Config
|
||||
}
|
||||
|
||||
func newDBConsole(
|
||||
clockStore store.ClockStore,
|
||||
dataProofStore store.DataProofStore,
|
||||
) (*DBConsole, error) {
|
||||
func newDBConsole(nodeConfig *config.Config) (*DBConsole, error) {
|
||||
return &DBConsole{
|
||||
clockStore,
|
||||
dataProofStore,
|
||||
nodeConfig,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Runs the DB console, this is meant for simple debugging, not production use.
|
||||
func (c *DBConsole) Run() {
|
||||
for {
|
||||
fmt.Printf("db> ")
|
||||
type model struct {
|
||||
filters []string
|
||||
cursor int
|
||||
selectedFilter string
|
||||
conn *grpc.ClientConn
|
||||
client protobufs.NodeServiceClient
|
||||
peerId string
|
||||
errorMsg string
|
||||
frame *protobufs.ClockFrame
|
||||
frames []*protobufs.ClockFrame
|
||||
frameIndex int
|
||||
grpcWarn bool
|
||||
committed bool
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
s, err := reader.ReadString('\n')
|
||||
func (m model) Init() tea.Cmd {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
|
||||
case tea.KeyMsg:
|
||||
switch msg.String() {
|
||||
case "ctrl+c", "q":
|
||||
return m, tea.Quit
|
||||
case "up", "w":
|
||||
if m.cursor > 0 {
|
||||
m.cursor--
|
||||
}
|
||||
case "down", "s":
|
||||
if m.cursor < len(m.filters)-1 {
|
||||
m.cursor++
|
||||
}
|
||||
case "left", "a":
|
||||
m.committed = false
|
||||
m.errorMsg = ""
|
||||
if m.frameIndex > 0 {
|
||||
m.frameIndex--
|
||||
if len(m.frames) != 0 && m.conn.GetState() == connectivity.Ready {
|
||||
filter, _ := hex.DecodeString(m.selectedFilter)
|
||||
selector, err := m.frames[m.frameIndex].GetSelector()
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
},
|
||||
)
|
||||
if err == nil && bytes.Equal(
|
||||
frameInfo.ClockFrame.Output,
|
||||
m.frames[m.frameIndex].Output,
|
||||
) {
|
||||
m.committed = true
|
||||
m.frame = frameInfo.ClockFrame
|
||||
} else {
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
Selector: selector.FillBytes(make([]byte, 32)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.errorMsg = hex.EncodeToString(
|
||||
selector.Bytes(),
|
||||
) + ":" + err.Error()
|
||||
break
|
||||
}
|
||||
m.frame = frameInfo.ClockFrame
|
||||
}
|
||||
} else {
|
||||
m.errorMsg = "Not currently connected to node, cannot query."
|
||||
}
|
||||
} else {
|
||||
first := uint64(0)
|
||||
if len(m.frames) != 0 {
|
||||
first = m.frames[0].FrameNumber - 1
|
||||
}
|
||||
|
||||
if first == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
max := uint64(17)
|
||||
if len(m.frames) != 0 {
|
||||
max = first
|
||||
}
|
||||
|
||||
min := max - 16
|
||||
filter, _ := hex.DecodeString(m.selectedFilter)
|
||||
frames, err := m.client.GetFrames(
|
||||
context.Background(),
|
||||
&protobufs.GetFramesRequest{
|
||||
Filter: filter,
|
||||
FromFrameNumber: min,
|
||||
ToFrameNumber: max + 1,
|
||||
IncludeCandidates: true,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.selectedFilter = ""
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
if frames.TruncatedClockFrames != nil {
|
||||
m.frames = frames.TruncatedClockFrames
|
||||
m.frameIndex = len(m.frames) - 1
|
||||
selector, err := m.frames[m.frameIndex].GetSelector()
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
},
|
||||
)
|
||||
if err == nil && bytes.Equal(
|
||||
frameInfo.ClockFrame.Output,
|
||||
m.frames[m.frameIndex].Output,
|
||||
) {
|
||||
m.committed = true
|
||||
m.frame = frameInfo.ClockFrame
|
||||
} else {
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
Selector: selector.FillBytes(make([]byte, 32)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
m.frame = frameInfo.ClockFrame
|
||||
}
|
||||
}
|
||||
}
|
||||
case "right", "d":
|
||||
m.committed = false
|
||||
m.errorMsg = ""
|
||||
if m.frameIndex < len(m.frames)-1 {
|
||||
m.frameIndex++
|
||||
if len(m.frames) != 0 && m.conn.GetState() == connectivity.Ready {
|
||||
filter, _ := hex.DecodeString(m.selectedFilter)
|
||||
selector, err := m.frames[m.frameIndex].GetSelector()
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
},
|
||||
)
|
||||
if err == nil && bytes.Equal(
|
||||
frameInfo.ClockFrame.Output,
|
||||
m.frames[m.frameIndex].Output,
|
||||
) {
|
||||
m.committed = true
|
||||
m.frame = frameInfo.ClockFrame
|
||||
} else {
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
Selector: selector.FillBytes(make([]byte, 32)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.errorMsg = hex.EncodeToString(
|
||||
selector.Bytes(),
|
||||
) + ":" + err.Error()
|
||||
break
|
||||
}
|
||||
m.frame = frameInfo.ClockFrame
|
||||
}
|
||||
} else {
|
||||
m.errorMsg = "Not currently connected to node, cannot query."
|
||||
}
|
||||
} else {
|
||||
min := uint64(1)
|
||||
if len(m.frames) != 0 {
|
||||
min = m.frames[len(m.frames)-1].FrameNumber + 1
|
||||
}
|
||||
|
||||
max := min + 16
|
||||
filter, _ := hex.DecodeString(m.selectedFilter)
|
||||
frames, err := m.client.GetFrames(
|
||||
context.Background(),
|
||||
&protobufs.GetFramesRequest{
|
||||
Filter: filter,
|
||||
FromFrameNumber: min,
|
||||
ToFrameNumber: max,
|
||||
IncludeCandidates: true,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.selectedFilter = ""
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
if frames.TruncatedClockFrames != nil {
|
||||
m.frames = frames.TruncatedClockFrames
|
||||
m.frameIndex = 0
|
||||
selector, err := m.frames[m.frameIndex].GetSelector()
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
},
|
||||
)
|
||||
if err == nil && bytes.Equal(
|
||||
frameInfo.ClockFrame.Output,
|
||||
m.frames[m.frameIndex].Output,
|
||||
) {
|
||||
m.committed = true
|
||||
m.frame = frameInfo.ClockFrame
|
||||
} else {
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
Selector: selector.FillBytes(make([]byte, 32)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
m.frame = frameInfo.ClockFrame
|
||||
}
|
||||
}
|
||||
}
|
||||
case "enter", " ":
|
||||
m.errorMsg = ""
|
||||
m.frame = nil
|
||||
m.committed = false
|
||||
if m.conn.GetState() == connectivity.Ready {
|
||||
if m.selectedFilter != m.filters[m.cursor] {
|
||||
m.selectedFilter = m.filters[m.cursor]
|
||||
m.frames = []*protobufs.ClockFrame{}
|
||||
}
|
||||
|
||||
min := uint64(1)
|
||||
if len(m.frames) != 0 {
|
||||
min = m.frames[len(m.frames)-1].FrameNumber + 1
|
||||
}
|
||||
|
||||
max := min + 16
|
||||
filter, _ := hex.DecodeString(m.selectedFilter)
|
||||
frames, err := m.client.GetFrames(
|
||||
context.Background(),
|
||||
&protobufs.GetFramesRequest{
|
||||
Filter: filter,
|
||||
FromFrameNumber: min,
|
||||
ToFrameNumber: max,
|
||||
IncludeCandidates: true,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.selectedFilter = ""
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
if frames.TruncatedClockFrames != nil {
|
||||
m.frames = frames.TruncatedClockFrames
|
||||
m.frameIndex = 0
|
||||
selector, err := m.frames[m.frameIndex].GetSelector()
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
},
|
||||
)
|
||||
if err == nil && bytes.Equal(
|
||||
frameInfo.ClockFrame.Output,
|
||||
m.frames[m.frameIndex].Output,
|
||||
) {
|
||||
m.committed = true
|
||||
m.frame = frameInfo.ClockFrame
|
||||
} else {
|
||||
frameInfo, err := m.client.GetFrameInfo(
|
||||
context.Background(),
|
||||
&protobufs.GetFrameInfoRequest{
|
||||
Filter: filter,
|
||||
FrameNumber: m.frames[m.frameIndex].FrameNumber,
|
||||
Selector: selector.FillBytes(make([]byte, 32)),
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
m.errorMsg = err.Error()
|
||||
break
|
||||
}
|
||||
m.frame = frameInfo.ClockFrame
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m.errorMsg = "Not currently connected to node, cannot query."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m model) View() string {
|
||||
physicalWidth, physicalHeight, _ := term.GetSize(int(os.Stdout.Fd()))
|
||||
doc := strings.Builder{}
|
||||
|
||||
window := lipgloss.NewStyle().
|
||||
Border(border, true).
|
||||
BorderForeground(primaryColor).
|
||||
Padding(0, 1)
|
||||
|
||||
list := []string{}
|
||||
for i, item := range m.filters {
|
||||
str := item[0:12] + ".." + item[52:]
|
||||
if m.selectedFilter == item {
|
||||
list = append(list, selectedListStyle.Render(str))
|
||||
} else if i == m.cursor {
|
||||
list = append(list, navigatedListStyle.Render(str))
|
||||
} else {
|
||||
list = append(list, unselectedListStyle.Render(str))
|
||||
}
|
||||
}
|
||||
|
||||
w := lipgloss.Width
|
||||
|
||||
statusKey := statusItemStyle.Render("STATUS")
|
||||
info := statusStyle.Render("(Press Ctrl-C or Q to quit)")
|
||||
onlineStatus := "gRPC Not Enabled, Please Configure"
|
||||
if !m.grpcWarn {
|
||||
switch m.conn.GetState() {
|
||||
case connectivity.Connecting:
|
||||
onlineStatus = "CONNECTING"
|
||||
case connectivity.Idle:
|
||||
onlineStatus = "IDLE"
|
||||
case connectivity.Shutdown:
|
||||
onlineStatus = "SHUTDOWN"
|
||||
case connectivity.TransientFailure:
|
||||
onlineStatus = "DISCONNECTED"
|
||||
default:
|
||||
onlineStatus = "CONNECTED"
|
||||
}
|
||||
}
|
||||
|
||||
peerIdVal := statusItemStyle.Render(m.peerId)
|
||||
statusVal := statusBarStyle.Copy().
|
||||
Width(physicalWidth-w(statusKey)-w(info)-w(peerIdVal)).
|
||||
Padding(0, 1).
|
||||
Render(onlineStatus)
|
||||
|
||||
bar := lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
statusKey,
|
||||
statusVal,
|
||||
info,
|
||||
peerIdVal,
|
||||
)
|
||||
|
||||
explorerContent := ""
|
||||
|
||||
if m.errorMsg != "" {
|
||||
explorerContent = m.errorMsg
|
||||
} else if m.frame != nil {
|
||||
selector, err := m.frame.GetSelector()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
committed := "Unconfirmed"
|
||||
if m.committed {
|
||||
committed = "Confirmed"
|
||||
}
|
||||
explorerContent = fmt.Sprintf(
|
||||
"Frame %d (Selector: %x, %s):\n\tParent: %x\n\tVDF Proof: %x\n",
|
||||
m.frame.FrameNumber,
|
||||
selector.Bytes(),
|
||||
committed,
|
||||
m.frame.ParentSelector,
|
||||
m.frame.Input[:516],
|
||||
)
|
||||
|
||||
for i := 0; i < len(m.frame.Input[516:])/74; i++ {
|
||||
commit := m.frame.Input[516+(i*74) : 516+((i+1)*74)]
|
||||
explorerContent += fmt.Sprintf(
|
||||
"\tCommitment %+x\n",
|
||||
commit,
|
||||
)
|
||||
explorerContent += fmt.Sprintf(
|
||||
"\t\tType: %s\n",
|
||||
m.frame.AggregateProofs[i].InclusionCommitments[0].TypeUrl,
|
||||
)
|
||||
switch m.frame.AggregateProofs[i].InclusionCommitments[0].TypeUrl {
|
||||
case protobufs.IntrinsicExecutionOutputType:
|
||||
explorerContent += "Application: Ceremony\n"
|
||||
app, err := application.MaterializeApplicationFromFrame(m.frame)
|
||||
if err != nil {
|
||||
explorerContent += "Error: " + err.Error() + "\n"
|
||||
continue
|
||||
}
|
||||
|
||||
total := new(big.Int)
|
||||
if app.RewardTrie.Root == nil ||
|
||||
(app.RewardTrie.Root.External == nil &&
|
||||
app.RewardTrie.Root.Internal == nil) {
|
||||
explorerContent += "Total Rewards: 0 QUIL\n"
|
||||
continue
|
||||
}
|
||||
|
||||
limbs := []*tries.RewardInternalNode{}
|
||||
if app.RewardTrie.Root.Internal != nil {
|
||||
limbs = append(limbs, app.RewardTrie.Root.Internal)
|
||||
} else {
|
||||
total = total.Add(
|
||||
total,
|
||||
new(big.Int).SetUint64(app.RewardTrie.Root.External.Total),
|
||||
)
|
||||
}
|
||||
|
||||
for len(limbs) != 0 {
|
||||
nextLimbs := []*tries.RewardInternalNode{}
|
||||
for _, limb := range limbs {
|
||||
for _, child := range limb.Child {
|
||||
child := child
|
||||
if child.Internal != nil {
|
||||
nextLimbs = append(nextLimbs, child.Internal)
|
||||
} else {
|
||||
total = total.Add(
|
||||
total,
|
||||
new(big.Int).SetUint64(child.External.Total),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
limbs = nextLimbs
|
||||
}
|
||||
|
||||
explorerContent += "Total Rewards: " + total.String() + " QUIL\n"
|
||||
|
||||
state := app.LobbyState.String()
|
||||
explorerContent += "Round State: " + state + "\n"
|
||||
|
||||
switch app.LobbyState {
|
||||
case application.CEREMONY_APPLICATION_STATE_OPEN:
|
||||
explorerContent += "Joins: \n"
|
||||
|
||||
for _, join := range app.LobbyJoins {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
join.PublicKeySignatureEd448.PublicKey.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Preferred Next Round Participants: \n"
|
||||
|
||||
for _, next := range app.NextRoundPreferredParticipants {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
next.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += fmt.Sprintf(
|
||||
"State Transition Counter: %d\n",
|
||||
app.StateCount,
|
||||
)
|
||||
case application.CEREMONY_APPLICATION_STATE_IN_PROGRESS:
|
||||
explorerContent += fmt.Sprintf("Sub-Round: %d\n", app.RoundCount)
|
||||
explorerContent += "Participants: \n"
|
||||
|
||||
for _, active := range app.ActiveParticipants {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
active.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Latest Seen: \n"
|
||||
|
||||
for _, latest := range app.LatestSeenProverAttestations {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
latest.SeenProverKey.KeyValue,
|
||||
) + " seen by " + base64.StdEncoding.EncodeToString(
|
||||
latest.ProverSignature.PublicKey.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Dropped: \n"
|
||||
|
||||
for _, dropped := range app.DroppedParticipantAttestations {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
dropped.DroppedProverKey.KeyValue,
|
||||
) + " confirmed by " + base64.StdEncoding.EncodeToString(
|
||||
dropped.ProverSignature.PublicKey.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Preferred Next Round Participants: \n"
|
||||
|
||||
for _, next := range app.NextRoundPreferredParticipants {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
next.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
case application.CEREMONY_APPLICATION_STATE_FINALIZING:
|
||||
explorerContent += fmt.Sprintf(
|
||||
"Confirmed Shares: %d\n",
|
||||
len(app.TranscriptShares),
|
||||
)
|
||||
explorerContent += "Participants: \n"
|
||||
|
||||
for _, active := range app.ActiveParticipants {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
active.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Latest Seen: \n"
|
||||
|
||||
for _, latest := range app.LatestSeenProverAttestations {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
latest.SeenProverKey.KeyValue,
|
||||
) + " seen by " + base64.StdEncoding.EncodeToString(
|
||||
latest.ProverSignature.PublicKey.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Dropped: \n"
|
||||
|
||||
for _, dropped := range app.DroppedParticipantAttestations {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
dropped.DroppedProverKey.KeyValue,
|
||||
) + " confirmed by " + base64.StdEncoding.EncodeToString(
|
||||
dropped.ProverSignature.PublicKey.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
|
||||
explorerContent += "Preferred Next Round Participants: \n"
|
||||
|
||||
for _, next := range app.NextRoundPreferredParticipants {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
next.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
case application.CEREMONY_APPLICATION_STATE_VALIDATING:
|
||||
explorerContent += "Preferred Next Round Participants: \n"
|
||||
|
||||
for _, next := range app.NextRoundPreferredParticipants {
|
||||
explorerContent += "\t" + base64.StdEncoding.EncodeToString(
|
||||
next.KeyValue,
|
||||
) + "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
explorerContent = logoVersion(physicalWidth - 34)
|
||||
}
|
||||
|
||||
doc.WriteString(
|
||||
lipgloss.JoinVertical(
|
||||
lipgloss.Left,
|
||||
lipgloss.JoinHorizontal(
|
||||
lipgloss.Top,
|
||||
lipgloss.JoinVertical(
|
||||
lipgloss.Left,
|
||||
windowHeader.Render("Filters (Up/Down, Enter)"),
|
||||
window.Width(30).Height(physicalHeight-4).Render(lipgloss.JoinVertical(lipgloss.Left, list...)),
|
||||
),
|
||||
lipgloss.JoinVertical(
|
||||
lipgloss.Left,
|
||||
windowHeader.Render("Explorer (Left/Right)"),
|
||||
window.Width(physicalWidth-34).Height(physicalHeight-4).Render(explorerContent),
|
||||
),
|
||||
),
|
||||
statusBarStyle.Width(physicalWidth).Render(bar),
|
||||
),
|
||||
)
|
||||
|
||||
if physicalWidth > 0 {
|
||||
docStyle = docStyle.MaxWidth(physicalWidth)
|
||||
docStyle = docStyle.MaxHeight(physicalHeight)
|
||||
}
|
||||
|
||||
return docStyle.Render(doc.String())
|
||||
}
|
||||
|
||||
func consoleModel(
|
||||
conn *grpc.ClientConn,
|
||||
nodeConfig *config.Config,
|
||||
grpcWarn bool,
|
||||
) model {
|
||||
peerPrivKey, err := hex.DecodeString(nodeConfig.P2P.PeerPrivKey)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "error unmarshaling peerkey"))
|
||||
}
|
||||
|
||||
privKey, err := crypto.UnmarshalEd448PrivateKey(peerPrivKey)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "error unmarshaling peerkey"))
|
||||
}
|
||||
|
||||
pub := privKey.GetPublic()
|
||||
id, err := peer.IDFromPublicKey(pub)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "error getting peer id"))
|
||||
}
|
||||
|
||||
return model{
|
||||
filters: []string{
|
||||
hex.EncodeToString([]byte{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
}),
|
||||
hex.EncodeToString(application.CEREMONY_ADDRESS),
|
||||
},
|
||||
cursor: 0,
|
||||
conn: conn,
|
||||
client: protobufs.NewNodeServiceClient(conn),
|
||||
peerId: id.String(),
|
||||
grpcWarn: grpcWarn,
|
||||
}
|
||||
}
|
||||
|
||||
// Runs the DB console
|
||||
func (c *DBConsole) Run() {
|
||||
grpcWarn := true
|
||||
addr := "localhost:8337"
|
||||
if c.nodeConfig.ListenGRPCMultiaddr != "" {
|
||||
ma, err := multiaddr.NewMultiaddr(c.nodeConfig.ListenGRPCMultiaddr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
cmd := strings.Trim(s, "\n")
|
||||
switch cmd {
|
||||
case "quit":
|
||||
return
|
||||
case "show master frames":
|
||||
earliestFrame, err := c.clockStore.GetEarliestMasterClockFrame([]byte{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
latestFrame, err := c.clockStore.GetLatestMasterClockFrame([]byte{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf(
|
||||
"earliest: %d, latest: %d\n",
|
||||
earliestFrame.FrameNumber,
|
||||
latestFrame.FrameNumber,
|
||||
)
|
||||
|
||||
fmt.Printf(
|
||||
"Genesis Frame:\n\tVDF Proof: %x\n",
|
||||
earliestFrame.Input[:516],
|
||||
)
|
||||
|
||||
iter, err := c.clockStore.RangeMasterClockFrames(
|
||||
[]byte{
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
},
|
||||
earliestFrame.FrameNumber,
|
||||
latestFrame.FrameNumber,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for iter.First(); iter.Valid(); iter.Next() {
|
||||
value, err := iter.Value()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
selector, err := value.GetSelector()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf(
|
||||
"Frame %d (Selector: %x):\n\tParent: %x\n\tVDF Proof: %x\n\n",
|
||||
value.FrameNumber,
|
||||
selector.Bytes(),
|
||||
value.ParentSelector,
|
||||
value.Input[:516],
|
||||
)
|
||||
}
|
||||
|
||||
if err := iter.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
case "show ceremony frames":
|
||||
earliestFrame, err := c.clockStore.GetEarliestDataClockFrame(
|
||||
application.CEREMONY_ADDRESS,
|
||||
)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "earliest"))
|
||||
}
|
||||
|
||||
latestFrame, err := c.clockStore.GetLatestDataClockFrame(
|
||||
application.CEREMONY_ADDRESS,
|
||||
nil,
|
||||
)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "latest"))
|
||||
}
|
||||
|
||||
fmt.Printf(
|
||||
"earliest: %d, latest: %d\n",
|
||||
earliestFrame.FrameNumber,
|
||||
latestFrame.FrameNumber,
|
||||
)
|
||||
|
||||
fmt.Printf(
|
||||
"Genesis Frame:\n\tVDF Proof: %x\n",
|
||||
earliestFrame.Input[:516],
|
||||
)
|
||||
|
||||
iter, err := c.clockStore.RangeDataClockFrames(
|
||||
application.CEREMONY_ADDRESS,
|
||||
earliestFrame.FrameNumber+1,
|
||||
latestFrame.FrameNumber,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for iter.First(); iter.Valid(); iter.Next() {
|
||||
value, err := iter.Value()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
selector, err := value.GetSelector()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf(
|
||||
"Frame %d (Selector: %x):\n\tParent: %x\n\tVDF Proof: %x\n",
|
||||
value.FrameNumber,
|
||||
selector.Bytes(),
|
||||
value.ParentSelector,
|
||||
value.Input[:516],
|
||||
)
|
||||
|
||||
for i := 0; i < len(value.Input[516:])/74; i++ {
|
||||
commit := value.Input[516+(i*74) : 516+((i+1)*74)]
|
||||
fmt.Printf(
|
||||
"\tCommitment %+x\n",
|
||||
commit,
|
||||
)
|
||||
fmt.Printf(
|
||||
"\t\tType: %s\n",
|
||||
value.AggregateProofs[i].InclusionCommitments[0].TypeUrl,
|
||||
)
|
||||
b, _ := proto.Marshal(value.AggregateProofs[i])
|
||||
hash := sha3.Sum256(b)
|
||||
fmt.Printf("\t\tAP Hash: %+x\n", hash)
|
||||
}
|
||||
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
if err := iter.Close(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
default:
|
||||
fmt.Printf("unknown command %s\n", cmd)
|
||||
_, addr, err = mn.DialArgs(ma)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
grpcWarn = false
|
||||
}
|
||||
|
||||
conn, err := grpc.Dial(
|
||||
addr,
|
||||
grpc.WithTransportCredentials(
|
||||
insecure.NewCredentials(),
|
||||
),
|
||||
grpc.WithDefaultCallOptions(
|
||||
grpc.MaxCallSendMsgSize(600*1024*1024),
|
||||
grpc.MaxCallRecvMsgSize(600*1024*1024),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer conn.Close()
|
||||
p := tea.NewProgram(consoleModel(conn, c.nodeConfig, grpcWarn))
|
||||
if _, err := p.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func logoVersion(width int) string {
|
||||
var out string
|
||||
|
||||
if width >= 83 {
|
||||
out = " %#########\n"
|
||||
out += " #############################\n"
|
||||
out += " ########################################&\n"
|
||||
out += " ###############################################\n"
|
||||
out += " &#####################% %######################\n"
|
||||
out += " ################# #################\n"
|
||||
out += " ############### ###############\n"
|
||||
out += " ############# ##############\n"
|
||||
out += " ############# ############&\n"
|
||||
out += " ############ ############\n"
|
||||
out += " ########### ########## &###########\n"
|
||||
out += " ########### ############## ###########\n"
|
||||
out += " ########### ############## ##########&\n"
|
||||
out += " ########## ############## ##########\n"
|
||||
out += "%########## ########## ##########\n"
|
||||
out += "##########& ##########\n"
|
||||
out += "########## &#########\n"
|
||||
out += "##########& ####### ####### ##########\n"
|
||||
out += " ########## &######################### ##########\n"
|
||||
out += " ########## ##############% ############## &##########\n"
|
||||
out += " %########## &############## ############### ##########\n"
|
||||
out += " ########### ############### ##############% ###########\n"
|
||||
out += " ###########& ########## ############### ########\n"
|
||||
out += " ############ ##### ##############% ####\n"
|
||||
out += " ############ ###############\n"
|
||||
out += " ############## ##############%\n"
|
||||
out += " ############### ###############\n"
|
||||
out += " #################& ##############%\n"
|
||||
out += " #########################&&&############# ###############\n"
|
||||
out += " ########################################% ############\n"
|
||||
out += " ####################################### ########\n"
|
||||
out += " ############################# ##\n"
|
||||
out += " \n"
|
||||
out += " Quilibrium Node - v1.1.7 – Dawn\n"
|
||||
out += " \n"
|
||||
out += " DB Console\n"
|
||||
} else {
|
||||
out = "Quilibrium Node - v1.1.7 – Dawn - DB Console\n"
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func NewNode(*config.Config) (*Node, error) {
|
||||
}
|
||||
|
||||
func NewDBConsole(*config.Config) (*DBConsole, error) {
|
||||
panic(wire.Build(loggerSet, storeSet, newDBConsole))
|
||||
panic(wire.Build(newDBConsole))
|
||||
}
|
||||
|
||||
func NewClockStore(*config.Config) (store.ClockStore, error) {
|
||||
|
@ -43,12 +43,7 @@ func NewNode(configConfig *config.Config) (*Node, error) {
|
||||
}
|
||||
|
||||
func NewDBConsole(configConfig *config.Config) (*DBConsole, error) {
|
||||
dbConfig := configConfig.DB
|
||||
db := store.NewPebbleDB(dbConfig)
|
||||
zapLogger := logger()
|
||||
pebbleClockStore := store.NewPebbleClockStore(db, zapLogger)
|
||||
pebbleDataProofStore := store.NewPebbleDataProofStore(db, zapLogger)
|
||||
dbConsole, err := newDBConsole(pebbleClockStore, pebbleDataProofStore)
|
||||
dbConsole, err := newDBConsole(configConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
15
node/go.mod
15
node/go.mod
@ -25,13 +25,17 @@ require (
|
||||
|
||||
require (
|
||||
github.com/DataDog/zstd v1.4.5 // indirect
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401 // indirect
|
||||
github.com/bwesterb/go-ristretto v1.2.3 // indirect
|
||||
github.com/charmbracelet/bubbletea v0.24.2 // indirect
|
||||
github.com/charmbracelet/lipgloss v0.9.1 // indirect
|
||||
github.com/cockroachdb/errors v1.8.1 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
|
||||
github.com/cockroachdb/redact v1.0.8 // indirect
|
||||
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
|
||||
github.com/consensys/gnark-crypto v0.5.3 // indirect
|
||||
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/golang/glog v1.1.0 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
@ -40,11 +44,20 @@ require (
|
||||
github.com/gtank/merlin v0.1.1 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
|
||||
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
|
||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||
github.com/muesli/reflow v0.3.0 // indirect
|
||||
github.com/muesli/termenv v0.15.2 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.11.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/quic-go/qtls-go1-19 v0.3.3 // indirect
|
||||
github.com/quic-go/qtls-go1-20 v0.2.3 // indirect
|
||||
github.com/rivo/uniseg v0.2.0 // indirect
|
||||
golang.org/x/term v0.14.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
|
||||
@ -153,7 +166,7 @@ require (
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.15.0 // indirect
|
||||
golang.org/x/sync v0.3.0
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/sys v0.14.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
|
||||
gonum.org/v1/gonum v0.11.0 // indirect
|
||||
|
33
node/go.sum
33
node/go.sum
@ -22,6 +22,8 @@ github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBA
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
@ -50,6 +52,10 @@ github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7N
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/charmbracelet/bubbletea v0.24.2 h1:uaQIKx9Ai6Gdh5zpTbGiWpytMU+CfsPp06RaW2cx/SY=
|
||||
github.com/charmbracelet/bubbletea v0.24.2/go.mod h1:XdrNrV4J8GiyshTtx3DNuYkR1FDaJmO3l2nejekbsgg=
|
||||
github.com/charmbracelet/lipgloss v0.9.1 h1:PNyd3jvaJbg4jRHKWXnCj1akQm4rh8dbEzN1p/u1KWg=
|
||||
github.com/charmbracelet/lipgloss v0.9.1/go.mod h1:1mPmG4cxScwUQALAAnacHaigiiHB9Pmr+v1VEawJl6I=
|
||||
github.com/cilium/ebpf v0.2.0/go.mod h1:To2CFviqOWL/M0gIMsvSMlqe7em/l1ALkX1PyjrX2Qs=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs=
|
||||
@ -75,6 +81,8 @@ github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaO
|
||||
github.com/containerd/cgroups v0.0.0-20201119153540-4cbc285b3327/go.mod h1:ZJeTFisyysqgcCdecO57Dj79RfL0LNeGiFUqLYQRYLE=
|
||||
github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM=
|
||||
github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw=
|
||||
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2wIvVRd/hEHD7lacgqrCPS+k8g1MndzfWY=
|
||||
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
@ -334,6 +342,8 @@ github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQsc
|
||||
github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU=
|
||||
github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ=
|
||||
github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
@ -346,6 +356,11 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||
@ -378,6 +393,14 @@ github.com/mr-tron/base58 v1.1.2/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjW
|
||||
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
|
||||
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
|
||||
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
|
||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
|
||||
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
|
||||
github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
|
||||
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
|
||||
github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0=
|
||||
@ -467,6 +490,9 @@ github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2Ep
|
||||
github.com/quic-go/webtransport-go v0.5.3/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU=
|
||||
github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk=
|
||||
github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||
@ -686,13 +712,20 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
|
||||
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=
|
||||
golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
|
10
node/main.go
10
node/main.go
@ -56,9 +56,11 @@ func main() {
|
||||
done := make(chan os.Signal, 1)
|
||||
signal.Notify(done, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
printLogo()
|
||||
printVersion()
|
||||
fmt.Println(" ")
|
||||
if !*dbConsole {
|
||||
printLogo()
|
||||
printVersion()
|
||||
fmt.Println(" ")
|
||||
}
|
||||
|
||||
nodeConfig, err := config.LoadConfig(*configDirectory, "")
|
||||
if err != nil {
|
||||
@ -231,5 +233,5 @@ func printLogo() {
|
||||
|
||||
func printVersion() {
|
||||
fmt.Println(" ")
|
||||
fmt.Println(" Quilibrium Node - v1.1.6 – Dawn")
|
||||
fmt.Println(" Quilibrium Node - v1.1.7 – Dawn")
|
||||
}
|
||||
|
@ -68,15 +68,19 @@ func generateBitSlices(
|
||||
// it assumes bitLength is a multiple of 32. If the filter size is not
|
||||
// conformant, this will generate biased indices.
|
||||
func getBloomFilterIndices(data []byte, bitLength int, k int) []byte {
|
||||
byteSize := bitLength / 256
|
||||
size := big.NewInt(int64(bitLength)).BitLen() - 1
|
||||
digest := sha3.Sum256(data)
|
||||
output := make([]byte, bitLength/8)
|
||||
outputBI := big.NewInt(0)
|
||||
digestBI := new(big.Int).SetBytes(digest[:])
|
||||
for i := 0; i < k; i++ {
|
||||
position := digest[i*byteSize : (i+1)*byteSize]
|
||||
if outputBI.Bit(int(new(big.Int).SetBytes(position).Int64())) != 1 {
|
||||
outputBI.SetBit(outputBI, int(new(big.Int).SetBytes(position).Int64()), 1)
|
||||
} else if k*byteSize <= 32 {
|
||||
position := uint(0)
|
||||
for j := size*(i+1) - 1; j >= size*i; j-- {
|
||||
position = position<<1 | (digestBI.Bit(j))
|
||||
}
|
||||
if outputBI.Bit(int(position)) != 1 {
|
||||
outputBI.SetBit(outputBI, int(position), 1)
|
||||
} else if k*size <= 32 {
|
||||
// we need to extend the search
|
||||
k++
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user