Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Go Client SDK to 0.7.0, Core to 23.0.1 #145

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version: "1.21.x"
cache: false
- name: Install gitlint
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20.x"
go-version: "1.21.x"
- name: Cache Go dependencies
uses: actions/cache@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version: "1.21.x"
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
Expand Down
94 changes: 20 additions & 74 deletions cmd/paratime/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@ import (
"github.com/olekukonko/tablewriter"
"github.com/spf13/cobra"

"github.com/oasisprotocol/oasis-core/go/common/cbor"
"github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
"github.com/oasisprotocol/oasis-core/go/common/node"
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
"github.com/oasisprotocol/oasis-core/go/consensus/api/transaction"
roothash "github.com/oasisprotocol/oasis-core/go/roothash/api"
"github.com/oasisprotocol/oasis-core/go/roothash/api/block"
"github.com/oasisprotocol/oasis-core/go/roothash/api/commitment"
scheduler "github.com/oasisprotocol/oasis-core/go/scheduler/api"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/connection"
"github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"
Expand Down Expand Up @@ -69,24 +66,19 @@ type entityStats struct {
// Rounds entity node was a proposer.
roundsProposer uint64

// How many times entity node proposed a timeout.
proposedTimeout uint64

// How many good blocks committed while being primary worker.
committeedGoodBlocksPrimary uint64
committedGoodBlocksPrimary uint64
// How many bad blocs committed while being primary worker.
committeedBadBlocksPrimary uint64
committedBadBlocksPrimary uint64
// How many good blocks committed while being backup worker.
committeedGoodBlocksBackup uint64
committedGoodBlocksBackup uint64
// How many bad blocks committed while being backup worker.
committeedBadBlocksBackup uint64
committedBadBlocksBackup uint64

// How many rounds missed committing a block while being a primary worker.
missedPrimary uint64
// How many rounds missed committing a block while being a backup worker (and discrepancy detection was invoked).
missedBackup uint64
// How many rounds proposer timeout was triggered while being the proposer.
missedProposer uint64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something not relevant in 23.0 anymore?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, the way backup proposers work has been totally changed. See oasisprotocol/oasis-core#5354 for details.

}

var statsCmd = &cobra.Command{
Expand Down Expand Up @@ -229,43 +221,6 @@ var statsCmd = &cobra.Command{
evs, err = roothashConn.GetEvents(ctx, height)
cobra.CheckErr(err)

var proposerTimeout bool
if currentRound != blk.Header.Round && currentCommittee != nil {
// If new round, check for proposer timeout.
// Need to look at submitted transactions if round failure was caused by a proposer timeout.
var rsp *consensus.TransactionsWithResults
rsp, err = consensusConn.GetTransactionsWithResults(ctx, height)
cobra.CheckErr(err)
for i := 0; i < len(rsp.Transactions); i++ {
// Ignore failed txs.
if !rsp.Results[i].IsSuccess() {
continue
}
var sigTx transaction.SignedTransaction
err = cbor.Unmarshal(rsp.Transactions[i], &sigTx)
cobra.CheckErr(err)
var tx transaction.Transaction
err = sigTx.Open(&tx)
cobra.CheckErr(err)
// Ignore non proposer timeout txs.
if tx.Method != roothash.MethodExecutorProposerTimeout {
continue
}
var xc roothash.ExecutorProposerTimeoutRequest
err = cbor.Unmarshal(tx.Body, &xc)
cobra.CheckErr(err)
// Ignore txs of other runtimes.
if xc.ID != runtimeID {
continue
}
// Proposer timeout triggered the round failure, update stats.
stats.entities[nodeToEntity(sigTx.Signature.PublicKey)].proposedTimeout++
stats.entities[nodeToEntity(currentScheduler.PublicKey)].missedProposer++
proposerTimeout = true
break
}
}

// Go over events before updating potential new round committee info.
// Even if round transition happened at this height, all events emitted
// at this height belong to the previous round.
Expand Down Expand Up @@ -302,10 +257,6 @@ var statsCmd = &cobra.Command{
if blk.Header.HeaderType == block.EpochTransition || blk.Header.HeaderType == block.Suspended {
continue
}
// Skip if proposer timeout.
if proposerTimeout {
continue
}

// Update stats.
OUTER:
Expand All @@ -328,11 +279,11 @@ var statsCmd = &cobra.Command{
}
switch member.Role {
case scheduler.RoleWorker:
stats.entities[entity].committeedGoodBlocksPrimary++
stats.entities[entity].committedGoodBlocksPrimary++
continue OUTER
case scheduler.RoleBackupWorker:
if roundDiscrepancy {
stats.entities[entity].committeedGoodBlocksBackup++
stats.entities[entity].committedGoodBlocksBackup++
continue OUTER
}
case scheduler.RoleInvalid:
Expand All @@ -346,11 +297,11 @@ var statsCmd = &cobra.Command{
}
switch member.Role {
case scheduler.RoleWorker:
stats.entities[entity].committeedBadBlocksPrimary++
stats.entities[entity].committedBadBlocksPrimary++
continue OUTER
case scheduler.RoleBackupWorker:
if roundDiscrepancy {
stats.entities[entity].committeedBadBlocksBackup++
stats.entities[entity].committedBadBlocksBackup++
continue OUTER
}
case scheduler.RoleInvalid:
Expand Down Expand Up @@ -379,11 +330,7 @@ var statsCmd = &cobra.Command{
case block.EpochTransition:
stats.epochTransitionRounds++
case block.RoundFailed:
if proposerTimeout {
stats.proposerTimeoutedRounds++
} else {
stats.failedRounds++
}
stats.failedRounds++
case block.Suspended:
stats.suspendedRounds++
currentCommittee = nil
Expand All @@ -401,17 +348,20 @@ var statsCmd = &cobra.Command{
var state *roothash.RuntimeState
state, err = roothashConn.GetRuntimeState(ctx, rtRequest)
cobra.CheckErr(err)
if state.ExecutorPool == nil {
if state.Committee == nil || state.CommitmentPool == nil {
// No committee - election failed(?)
fmt.Printf("\nWarning: unexpected or missing committee for runtime: height: %d\n", height)
currentCommittee = nil
currentScheduler = nil
continue
}
// Set committee info.
currentCommittee = state.ExecutorPool.Committee
currentScheduler, err = commitment.GetTransactionScheduler(currentCommittee, currentRound)
cobra.CheckErr(err)
var ok bool
currentCommittee = state.Committee
currentScheduler, ok = currentCommittee.Scheduler(currentRound, 0)
if !ok {
cobra.CheckErr("failed to query primary scheduler, no workers in committee")
}
roundDiscrepancy = false

// Update election stats.
Expand Down Expand Up @@ -491,8 +441,6 @@ func (s *runtimeStats) prepareEntitiesOutput(
"Bckp Bad commit",
"Primary missed",
"Bckp missed",
"Proposer missed",
"Proposed timeout",
}

addrToName := func(addr types.Address) string {
Expand All @@ -517,15 +465,13 @@ func (s *runtimeStats) prepareEntitiesOutput(
strconv.FormatUint(stats.roundsBackup, 10),
strconv.FormatUint(stats.roundsProposer, 10),
strconv.FormatUint(stats.roundsPrimaryRequired, 10),
strconv.FormatUint(stats.committeedGoodBlocksPrimary, 10),
strconv.FormatUint(stats.committeedBadBlocksPrimary, 10),
strconv.FormatUint(stats.committedGoodBlocksPrimary, 10),
strconv.FormatUint(stats.committedBadBlocksPrimary, 10),
strconv.FormatUint(stats.roundsBackupRequired, 10),
strconv.FormatUint(stats.committeedGoodBlocksBackup, 10),
strconv.FormatUint(stats.committeedBadBlocksBackup, 10),
strconv.FormatUint(stats.committedGoodBlocksBackup, 10),
strconv.FormatUint(stats.committedBadBlocksBackup, 10),
strconv.FormatUint(stats.missedPrimary, 10),
strconv.FormatUint(stats.missedBackup, 10),
strconv.FormatUint(stats.missedProposer, 10),
strconv.FormatUint(stats.proposedTimeout, 10),
)
s.entitiesOutput = append(s.entitiesOutput, line)
}
Expand Down
34 changes: 32 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,46 @@ func (cfg *Config) Save() error {
return cfg.viper.WriteConfig()
}

// Migrate migrates the given wallet config entry to the latest version and returns true, if any changes were needed.
// Migrate migrates the given wallet config entry to the latest version and returns true, if any
// changes were needed.
func (cfg *Config) Migrate() (bool, error) {
changes, err := cfg.Wallet.Migrate()
var changes bool

// Networks.
changes = changes || cfg.migrateNetworks()

// Wallets.
walletChanges, err := cfg.Wallet.Migrate()
if err != nil {
return false, fmt.Errorf("failed to migrate wallet configuration: %w", err)
}
changes = changes || walletChanges

return changes, nil
}

func (cfg *Config) migrateNetworks() bool {
var changes bool
for name, net := range cfg.Networks.All {
defaultCfg, knownDefault := Default.Networks.All[name]
oldChainContexts, knownOld := OldNetworks[name]
if !knownDefault || !knownOld {
continue
}

for _, oldChainContext := range oldChainContexts {
if net.ChainContext == oldChainContext {
// If old chain context is known, replace with default.
net.ChainContext = defaultCfg.ChainContext
changes = true
break
}
}
}

return changes
}

// Validate performs config validation.
func (cfg *Config) Validate() error {
if err := cfg.Networks.Validate(); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ import (
var Default = Config{
Networks: config.DefaultNetworks,
}

// OldNetworks contains information about old versions (e.g. chain contexts) of known networks so
// they can be automatically migrated.
var OldNetworks = map[string][]string{
// Testnet.
"testnet": {
"50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a", // 2022-03-03
},
}
2 changes: 1 addition & 1 deletion examples/network-set-rpc/00-list.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME CHAIN CONTEXT RPC
mainnet (*) b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 grpc.oasis.dev:443
mainnet_local b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 unix:/serverdir_mainnet/internal.sock
testnet 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet.grpc.oasis.dev:443
testnet 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 testnet.grpc.oasis.dev:443
testnet_alt 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet2.grpc.oasis.dev:443
2 changes: 1 addition & 1 deletion examples/network-set-rpc/02-list.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME CHAIN CONTEXT RPC
mainnet (*) b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 grpc.oasis.dev:443
mainnet_local b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 unix:/serverdir_mainnet/internal.sock
testnet 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet.grpc.oasis.dev:443
testnet 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 testnet.grpc.oasis.dev:443
testnet_alt 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet3.grpc.oasis.dev:443
2 changes: 1 addition & 1 deletion examples/network/00-list.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME CHAIN CONTEXT RPC
mainnet (*) b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 grpc.oasis.dev:443
mainnet_local b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 unix:/serverdir_mainnet/internal.sock
testnet 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet.grpc.oasis.dev:443
testnet 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 testnet.grpc.oasis.dev:443
testnet_alt 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet2.grpc.oasis.dev:443
2 changes: 1 addition & 1 deletion examples/network/02-list.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME CHAIN CONTEXT RPC
mainnet (*) b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 grpc.oasis.dev:443
mainnet_local b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 unix:/serverdir_mainnet/internal.sock
testnet 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet.grpc.oasis.dev:443
testnet 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 testnet.grpc.oasis.dev:443
2 changes: 1 addition & 1 deletion examples/network/04-list.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
NAME CHAIN CONTEXT RPC
mainnet b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 grpc.oasis.dev:443
mainnet_local (*) b11b369e0da5bb230b220127f5e7b242d385ef8c6f54906243f30af63c815535 unix:/serverdir_mainnet/internal.sock
testnet 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet.grpc.oasis.dev:443
testnet 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 testnet.grpc.oasis.dev:443
2 changes: 1 addition & 1 deletion examples/network/add-tcpip.in.static
Original file line number Diff line number Diff line change
@@ -1 +1 @@
oasis network add testnet_alt 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a testnet2.grpc.oasis.dev:443
oasis network add testnet_alt 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 testnet2.grpc.oasis.dev:443
2 changes: 1 addition & 1 deletion examples/network/add-unix.in.static
Original file line number Diff line number Diff line change
@@ -1 +1 @@
oasis network add testnet_local 50304f98ddb656620ea817cc1446c401752a05a249b36c9b90dba4616829977a unix:/serverdir_testnet/internal.sock
oasis network add testnet_local 0b91b8e4e44b2003a7c5e23ddadb5e14ef5345c0ebcb3ddcae07fa2f244cab76 unix:/serverdir_testnet/internal.sock
4 changes: 2 additions & 2 deletions examples/transaction/show-invalid.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Hash: bd312d0faf8b7399b8b92b07cb6b40b418995875551341fa8540503322c5b70a
Hash: c996e9d17d652d5dc64589d10806c244a5ef0f650cc2ec8c810b28a85fef5705
Signer: NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
(signature: k51gq/PyDHCjm2vEMMpePnnTOaFUddRadfrP8UmgzMz1G0JDr+1lRH9lsg04+2krpmMYs7TOgX55+RVJ5a+LDw==)
(signature: ph5Sj29JFG8p0rCqAXjHm+yLwiXHybxah9C1cVTI01SDeJlyXT8dbp4BfI1hFxBomgi1hOrevTpShX0f9puTCQ==)
[INVALID SIGNATURE]
Content:
Method: staking.Transfer
Expand Down
4 changes: 2 additions & 2 deletions examples/transaction/show-paratime-tx.out
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Hash: 3013be1ba6e1ef17921382f01b53f519174b2f35753d1fc37ad11bfc382f51f5
Hash: 1558a5d6254a1b216a0885fa16114899e35b27622fd5af7c8b2eee7284dcad2e
Signer(s):
1. NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
(signature: mxOARaaRkHrHiUObGO2KbUXZhmbIS2h3hsRM+3Y/DzvMtbVdwcZm2EZ7oP7dR5XHKkrQnjMwZnkT0mdZUsLIBw==)
(signature: u71xOVJhRrUth5rNTAa2HuARYCsGLmvOCRE05fCbaQiSoQhXtKPVP9feoQSXmLVxISCHr/0aNnRLEoifJLMzBQ==)
Content:
Format: plain
Method: accounts.Transfer
Expand Down
4 changes: 2 additions & 2 deletions examples/transaction/show.out
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Hash: bd312d0faf8b7399b8b92b07cb6b40b418995875551341fa8540503322c5b70a
Hash: c996e9d17d652d5dc64589d10806c244a5ef0f650cc2ec8c810b28a85fef5705
Signer: NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=
(signature: k51gq/PyDHCjm2vEMMpePnnTOaFUddRadfrP8UmgzMz1G0JDr+1lRH9lsg04+2krpmMYs7TOgX55+RVJ5a+LDw==)
(signature: ph5Sj29JFG8p0rCqAXjHm+yLwiXHybxah9C1cVTI01SDeJlyXT8dbp4BfI1hFxBomgi1hOrevTpShX0f9puTCQ==)
Content:
Method: staking.Transfer
Body:
Expand Down
2 changes: 1 addition & 1 deletion examples/transaction/sign.y.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Method: staking.Transfer
Body:
To: oasis1qrydpazemvuwtnp3efm7vmfvg3tde044qg6cxwzx
Amount: 1.0 TEST
Nonce: 41
Nonce: 42
Fee:
Amount: 0.0 TEST
Gas limit: 1265
Expand Down
4 changes: 2 additions & 2 deletions examples/transaction/testtx.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"untrusted_raw_value": "pGNmZWWiY2dhcwFmYW1vdW50QGRib2R5omJ0b1UAyND0Wds45cwxynfmbSxEVty+tQJmYW1vdW50RDuaygBlbm9uY2UBZm1ldGhvZHBzdGFraW5nLlRyYW5zZmVy",
"signature": {
"public_key": "NcPzNW3YU2T+ugNUtUWtoQnRvbOL9dYSaBfbjHLP1pE=",
"signature": "k51gq/PyDHCjm2vEMMpePnnTOaFUddRadfrP8UmgzMz1G0JDr+1lRH9lsg04+2krpmMYs7TOgX55+RVJ5a+LDw=="
"signature": "ph5Sj29JFG8p0rCqAXjHm+yLwiXHybxah9C1cVTI01SDeJlyXT8dbp4BfI1hFxBomgi1hOrevTpShX0f9puTCQ=="
}
}
}
4 changes: 2 additions & 2 deletions examples/transaction/testtx2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Body": "o2F2AWJhaaJic2mBomVub25jZQFsYWRkcmVzc19zcGVjoWlzaWduYXR1cmWhZ2VkMjU1MTlYIDXD8zVt2FNk/roDVLVFraEJ0b2zi/XWEmgX24xyz9aRY2ZlZaJjZ2FzAWZhbW91bnSCQEBkY2FsbKJkYm9keaJidG9VAMjQ9FnbOOXMMcp35m0sRFbcvrUCZmFtb3VudIJIDeC2s6dkAABAZm1ldGhvZHFhY2NvdW50cy5UcmFuc2Zlcg==",
"AuthProofs": [
{
"signature": "mxOARaaRkHrHiUObGO2KbUXZhmbIS2h3hsRM+3Y/DzvMtbVdwcZm2EZ7oP7dR5XHKkrQnjMwZnkT0mdZUsLIBw=="
"signature": "u71xOVJhRrUth5rNTAa2HuARYCsGLmvOCRE05fCbaQiSoQhXtKPVP9feoQSXmLVxISCHr/0aNnRLEoifJLMzBQ=="
}
]
}
}
Loading