Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
fa6dd8ba
Commit
fa6dd8ba
authored
2 years ago
by
Richard T. Carback III
Browse files
Options
Downloads
Patches
Plain Diff
Refactor dumpRounds
parent
08b2f22b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!510
Release
,
!304
pickup subcommand
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/dumpRounds.go
+104
-84
104 additions, 84 deletions
cmd/dumpRounds.go
with
104 additions
and
84 deletions
cmd/dumpRounds.go
+
104
−
84
View file @
fa6dd8ba
...
@@ -11,16 +11,19 @@ package cmd
...
@@ -11,16 +11,19 @@ package cmd
import
(
import
(
"encoding/base64"
"encoding/base64"
"fmt"
"fmt"
"github.com/spf13/viper"
"strconv"
"strconv"
"time"
"time"
"github.com/spf13/viper"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
jww
"github.com/spf13/jwalterweatherman"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/xxdk"
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/comms/signature"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/crypto/signature/ec"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/ndf"
)
)
// dumpRoundsCmd allows the user to view network information about a specific
// dumpRoundsCmd allows the user to view network information about a specific
...
@@ -48,91 +51,13 @@ var dumpRoundsCmd = &cobra.Command{
...
@@ -48,91 +51,13 @@ var dumpRoundsCmd = &cobra.Command{
})
})
waitUntilConnected
(
connected
)
waitUntilConnected
(
connected
)
numRequests
:=
len
(
roundIDs
)
roundInfos
:=
dumpRounds
(
roundIDs
,
user
)
requestCh
:=
make
(
chan
bool
,
numRequests
)
registration
:=
user
.
GetStorage
()
.
GetNDF
()
.
Registration
ndf
:=
user
.
GetStorage
()
.
GetNDF
()
ecp
:=
registration
.
EllipticPubKey
pubkey
,
err
:=
ec
.
LoadPublicKey
(
ecp
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
fmt
.
Printf
(
"registration pubkey: %s
\n\n
"
,
pubkey
.
MarshalText
())
rcb
:=
func
(
round
rounds
.
Round
,
success
bool
)
{
if
!
success
{
fmt
.
Printf
(
"round %v lookup failed"
,
round
.
ID
)
}
fmt
.
Printf
(
"Round %v:"
,
round
.
ID
)
fmt
.
Printf
(
"
\n\t
Batch size: %v, State: %v"
,
round
.
BatchSize
,
round
.
State
)
fmt
.
Printf
(
"
\n\t
UpdateID: %v, AddrSpaceSize: %v"
,
round
.
UpdateID
,
round
.
AddressSpaceSize
)
fmt
.
Printf
(
"
\n\t
Topology: "
)
for
i
,
nodeId
:=
range
round
.
Raw
.
Topology
{
nidStr
:=
base64
.
StdEncoding
.
EncodeToString
(
nodeId
)
fmt
.
Printf
(
"
\n\t\t
%d
\t
-
\t
%s"
,
i
,
nidStr
)
}
fmt
.
Printf
(
"
\n\t
Timestamps: "
)
for
state
,
ts
:=
range
round
.
Timestamps
{
fmt
.
Printf
(
"
\n\t\t
%v
\t
-
\t
%v"
,
state
,
ts
)
}
fmt
.
Printf
(
"
\n\t
Errors (%d): "
,
len
(
round
.
Raw
.
Errors
))
for
i
,
err
:=
range
round
.
Raw
.
Errors
{
fmt
.
Printf
(
"
\n\t\t
%d - %v"
,
i
,
err
)
}
fmt
.
Printf
(
"
\n\t
ClientErrors (%d): "
,
len
(
round
.
Raw
.
ClientErrors
))
for
_
,
ce
:=
range
round
.
Raw
.
ClientErrors
{
fmt
.
Printf
(
"
\n\t\t
%s - %v, Src: %v"
,
base64
.
StdEncoding
.
EncodeToString
(
ce
.
ClientId
),
ce
.
Error
,
base64
.
StdEncoding
.
EncodeToString
(
ce
.
Source
))
}
ri
:=
round
.
Raw
err
=
signature
.
VerifyEddsa
(
ri
,
pubkey
)
if
err
!=
nil
{
fmt
.
Printf
(
"
\n\t
ECC signature failed: %v"
,
err
)
fmt
.
Printf
(
"
\n\t
use trace logging for sig details"
)
}
else
{
fmt
.
Printf
(
"
\n\t
ECC signature succeeded!
\n\n
"
)
}
// fmt.Printf("Round Info RAW: %v\n\n", round)
// rsapubkey, _ := rsa.LoadPublicKeyFromPem([]byte(
// registration.TlsCertificate))
// signature.VerifyRsa(ri, rsapubkey)
// if err != nil {
// fmt.Printf("RSA signature failed: %v", err)
// fmt.Printf("use trace logging for sig details")
// } else {
// fmt.Printf("RSA signature succeeded!")
// }
requestCh
<-
success
}
for
i
:=
range
roundIDs
{
rid
:=
roundIDs
[
i
]
err
:=
user
.
GetCmix
()
.
LookupHistoricalRound
(
rid
,
rcb
)
if
err
!=
nil
{
fmt
.
Printf
(
"error on %v: %v"
,
rid
,
err
)
}
}
for
done
:=
0
;
done
<
numRequests
;
done
++
{
for
i
:=
range
roundInfos
{
res
:=
<-
requestCh
printRoundInfo
(
roundInfos
[
i
])
fmt
.
Printf
(
"request complete: %v"
,
res
)
printAndVerifyRoundSig
(
roundInfos
[
i
],
ndf
)
}
}
},
},
}
}
...
@@ -141,6 +66,101 @@ func init() {
...
@@ -141,6 +66,101 @@ func init() {
rootCmd
.
AddCommand
(
dumpRoundsCmd
)
rootCmd
.
AddCommand
(
dumpRoundsCmd
)
}
}
func
printRoundInfo
(
round
rounds
.
Round
)
{
fmt
.
Printf
(
"Round %v:"
,
round
.
ID
)
fmt
.
Printf
(
"
\n\t
Batch size: %v, State: %v"
,
round
.
BatchSize
,
round
.
State
)
fmt
.
Printf
(
"
\n\t
UpdateID: %v, AddrSpaceSize: %v"
,
round
.
UpdateID
,
round
.
AddressSpaceSize
)
fmt
.
Printf
(
"
\n\t
Topology: "
)
for
i
,
nodeId
:=
range
round
.
Raw
.
Topology
{
nidStr
:=
base64
.
StdEncoding
.
EncodeToString
(
nodeId
)
fmt
.
Printf
(
"
\n\t\t
%d
\t
-
\t
%s"
,
i
,
nidStr
)
}
fmt
.
Printf
(
"
\n\t
Timestamps: "
)
for
state
,
ts
:=
range
round
.
Timestamps
{
fmt
.
Printf
(
"
\n\t\t
%v
\t
-
\t
%v"
,
state
,
ts
)
}
fmt
.
Printf
(
"
\n\t
Errors (%d): "
,
len
(
round
.
Raw
.
Errors
))
for
i
,
err
:=
range
round
.
Raw
.
Errors
{
fmt
.
Printf
(
"
\n\t\t
%d - %v"
,
i
,
err
)
}
fmt
.
Printf
(
"
\n\t
ClientErrors (%d): "
,
len
(
round
.
Raw
.
ClientErrors
))
for
_
,
ce
:=
range
round
.
Raw
.
ClientErrors
{
fmt
.
Printf
(
"
\n\t\t
%s - %v, Src: %v"
,
base64
.
StdEncoding
.
EncodeToString
(
ce
.
ClientId
),
ce
.
Error
,
base64
.
StdEncoding
.
EncodeToString
(
ce
.
Source
))
}
}
func
printAndVerifyRoundSig
(
round
rounds
.
Round
,
ndf
*
ndf
.
NetworkDefinition
)
{
registration
:=
ndf
.
Registration
ecp
:=
registration
.
EllipticPubKey
pubkey
,
err
:=
ec
.
LoadPublicKey
(
ecp
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
}
fmt
.
Printf
(
"registration pubkey: %s
\n\n
"
,
pubkey
.
MarshalText
())
ri
:=
round
.
Raw
err
=
signature
.
VerifyEddsa
(
ri
,
pubkey
)
if
err
!=
nil
{
fmt
.
Printf
(
"
\n\t
ECC signature failed: %v"
,
err
)
fmt
.
Printf
(
"
\n\t
use trace logging for sig details"
)
}
else
{
fmt
.
Printf
(
"
\n\t
ECC signature succeeded!
\n\n
"
)
}
// fmt.Printf("Round Info RAW: %v\n\n", round)
// rsapubkey, _ := rsa.LoadPublicKeyFromPem([]byte(
// registration.TlsCertificate))
// signature.VerifyRsa(ri, rsapubkey)
// if err != nil {
// fmt.Printf("RSA signature failed: %v", err)
// fmt.Printf("use trace logging for sig details")
// } else {
// fmt.Printf("RSA signature succeeded!")
// }
}
func
dumpRounds
(
roundIDs
[]
id
.
Round
,
user
*
xxdk
.
E2e
)
[]
rounds
.
Round
{
numRequests
:=
len
(
roundIDs
)
requestCh
:=
make
(
chan
rounds
.
Round
,
numRequests
)
rcb
:=
func
(
round
rounds
.
Round
,
success
bool
)
{
if
!
success
{
fmt
.
Printf
(
"round %v lookup failed"
,
round
.
ID
)
}
requestCh
<-
round
}
for
i
:=
range
roundIDs
{
rid
:=
roundIDs
[
i
]
err
:=
user
.
GetCmix
()
.
LookupHistoricalRound
(
rid
,
rcb
)
if
err
!=
nil
{
fmt
.
Printf
(
"error on %v: %v"
,
rid
,
err
)
}
}
roundInfos
:=
make
([]
rounds
.
Round
,
0
)
for
done
:=
0
;
done
<
numRequests
;
done
++
{
res
:=
<-
requestCh
roundInfos
=
append
(
roundInfos
,
res
)
fmt
.
Printf
(
"request complete: %v"
,
res
)
}
return
roundInfos
}
func
parseRoundIDs
(
roundStrs
[]
string
)
[]
id
.
Round
{
func
parseRoundIDs
(
roundStrs
[]
string
)
[]
id
.
Round
{
var
roundIDs
[]
id
.
Round
var
roundIDs
[]
id
.
Round
for
_
,
r
:=
range
roundStrs
{
for
_
,
r
:=
range
roundStrs
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment