@@ -14,6 +14,8 @@ import (
1414 ibcfeetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
1515 ibcswitchtypes "github.com/scrtlabs/SecretNetwork/x/emergencybutton/types"
1616
17+ cosmwasm_api "github.com/scrtlabs/SecretNetwork/go-cosmwasm/api"
18+
1719 "cosmossdk.io/client/v2/autocli"
1820 "cosmossdk.io/core/appmodule"
1921 circuittypes "cosmossdk.io/x/circuit/types"
@@ -67,6 +69,8 @@ import (
6769 v1_20 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.20"
6870 v1_21 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.21"
6971 v1_21_7 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.21.7"
72+ v1_22 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.22"
73+ v1_23 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.23"
7074 v1_4 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.4"
7175 v1_5 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.5"
7276 v1_6 "github.com/scrtlabs/SecretNetwork/app/upgrades/v1.6"
@@ -144,6 +148,8 @@ var (
144148 v1_20 .Upgrade ,
145149 v1_21 .Upgrade ,
146150 v1_21_7 .Upgrade ,
151+ v1_22 .Upgrade ,
152+ v1_23 .Upgrade ,
147153 }
148154)
149155
@@ -448,41 +454,57 @@ func (app *SecretNetworkApp) RotateStore() {
448454 }
449455}
450456
451- func (app * SecretNetworkApp ) UpdateOneKey (ctx sdk.Context , filePath string , keyID string ) {
452- keyB64 , err := os .ReadFile (filePath )
453- if err != nil {
454- return
455- }
456-
457- keyBz , err := base64 .StdEncoding .DecodeString (string (keyB64 ))
458- if err != nil {
457+ func (app * SecretNetworkApp ) UpdateOneKey (ctx sdk.Context , keyID string , value []byte ) {
458+ if len (value ) == 0 {
459459 return
460460 }
461461
462- keyNew := reg.MasterKey {Bytes : keyBz }
462+ keyNew := reg.MasterKey {Bytes : value }
463463 ctx2 := sdk .UnwrapSDKContext (ctx )
464464
465465 keyOld := app .AppKeepers .RegKeeper .GetMasterKey (ctx2 , keyID )
466466 if (keyOld == nil ) || ! bytes .Equal (keyOld .Bytes , keyNew .Bytes ) {
467467 app .AppKeepers .RegKeeper .SetMasterKey (ctx2 , keyNew , keyID )
468- fmt .Printf ("%s set to %s\n " , keyID , keyB64 )
468+
469+ value_b64 := base64 .StdEncoding .EncodeToString (value )
470+ fmt .Printf ("%s set to %s\n " , keyID , value_b64 )
469471 }
470472}
471473
472474func (app * SecretNetworkApp ) UpdateNetworkKeys () {
473475 ms := app .BaseApp .CommitMultiStore () // cms is the CommitMultiStore in Cosmos SDK apps
474476 ctx := sdk .NewContext (ms , cmtproto.Header {}, false , app .Logger ())
475477
476- app .UpdateOneKey (ctx , reg .NodeExchMasterKeyPath , reg .MasterNodeKeyId )
477- app .UpdateOneKey (ctx , reg .IoExchMasterKeyPath , reg .MasterIoKeyId )
478+ var node_pk , io_pk []byte
479+
480+ for i := 0 ; ; i ++ {
481+ {
482+ next_node_pk , next_io_pk := cosmwasm_api .GetNetworkPubkey (uint32 (i ))
483+
484+ // Stop when both buffers are empty
485+ if len (next_node_pk ) == 0 && len (next_io_pk ) == 0 {
486+ break
487+ }
488+
489+ node_pk = next_node_pk
490+ io_pk = next_io_pk
491+ }
492+
493+ // node_pk_b64 := base64.StdEncoding.EncodeToString(node_pk)
494+ // io_pk_b64 := base64.StdEncoding.EncodeToString(io_pk)
495+ // fmt.Printf("iSeed=%d, nodePK=%s, ioPK=%s\n", i, node_pk_b64, io_pk_b64)
496+ }
497+
498+ app .UpdateOneKey (ctx , reg .MasterNodeKeyId , node_pk )
499+ app .UpdateOneKey (ctx , reg .MasterIoKeyId , io_pk )
478500}
479501
480502func (app * SecretNetworkApp ) Initialize () {
481503 ms := app .BaseApp .CommitMultiStore () // cms is the CommitMultiStore in Cosmos SDK apps
482504
483505 ctx := sdk .NewContext (ms , cmtproto.Header {}, false , app .Logger ())
484506
485- _ = app .AppKeepers .ComputeKeeper .SetValidatorSetEvidence (ctx )
507+ _ = app .AppKeepers .ComputeKeeper .SetEnclaveColdEvidences (ctx )
486508 app .UpdateNetworkKeys ()
487509}
488510
0 commit comments