-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #710 from oasisprotocol/ptrus/feature/parameters-c…
…hange-json api/proposals: decode parameters_change for proposals
- Loading branch information
Showing
25 changed files
with
162 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
api/proposals: json encode `parameters_change` instead of cbor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
|
||
"github.com/oasisprotocol/oasis-core/go/common/cbor" | ||
|
||
governanceV22 "github.com/oasisprotocol/nexus/coreapi/v22.2.11/governance/api" | ||
registryV22 "github.com/oasisprotocol/nexus/coreapi/v22.2.11/registry/api" | ||
roothashV22 "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" | ||
schedulerV22 "github.com/oasisprotocol/nexus/coreapi/v22.2.11/scheduler/api" | ||
stakingV22 "github.com/oasisprotocol/nexus/coreapi/v22.2.11/staking/api" | ||
governanceEden "github.com/oasisprotocol/nexus/coreapi/v24.0/governance/api" | ||
keymanagerEden "github.com/oasisprotocol/nexus/coreapi/v24.0/keymanager/api" | ||
keymanagerSecretsEden "github.com/oasisprotocol/nexus/coreapi/v24.0/keymanager/secrets" | ||
registryEden "github.com/oasisprotocol/nexus/coreapi/v24.0/registry/api" | ||
roothashEden "github.com/oasisprotocol/nexus/coreapi/v24.0/roothash/api" | ||
schedulerEden "github.com/oasisprotocol/nexus/coreapi/v24.0/scheduler/api" | ||
stakingEden "github.com/oasisprotocol/nexus/coreapi/v24.0/staking/api" | ||
vaultEden "github.com/oasisprotocol/nexus/coreapi/v24.0/vault/api" | ||
) | ||
|
||
func extractProposalParametersChange(raw cbor.RawMessage, module string) (interface{}, error) { | ||
switch module { | ||
case governanceEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
governanceEden.ConsensusParameterChanges{}, | ||
governanceV22.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown governance consensus parameter changes") | ||
case keymanagerEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
// No keymanager consensus parameter changes in V22. | ||
keymanagerSecretsEden.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown keymanager consensus parameter changes") | ||
case registryEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
registryEden.ConsensusParameterChanges{}, | ||
registryV22.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown registry consensus parameter changes") | ||
case roothashEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
roothashEden.ConsensusParameterChanges{}, | ||
roothashV22.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown roothash consensus parameter changes") | ||
case schedulerEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
schedulerEden.ConsensusParameterChanges{}, | ||
schedulerV22.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown scheduler consensus parameter changes") | ||
case stakingEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
stakingEden.ConsensusParameterChanges{}, | ||
stakingV22.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown staking consensus parameter changes") | ||
case vaultEden.ModuleName: | ||
for _, changesType := range []interface{}{ | ||
// No vault in v22. | ||
vaultEden.ConsensusParameterChanges{}, | ||
} { | ||
v := reflect.New(reflect.TypeOf(changesType)).Interface() | ||
if err := cbor.Unmarshal(raw, v); err != nil { | ||
continue | ||
} | ||
return v, nil | ||
} | ||
return nil, fmt.Errorf("CBOR unmarshal: unknown staking consensus parameter changes") | ||
default: | ||
return nil, fmt.Errorf("unhandled module: %s", module) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
Binary file modified
BIN
+0 Bytes
(100%)
tests/e2e_regression/damask/rpc-cache/consensus/00000-1.psg.pmt
Binary file not shown.
Binary file not shown.
Git LFS file not shown
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
tests/e2e_regression/damask/rpc-cache/https_sourcify_dev_server/main.pix
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
Binary file modified
BIN
+0 Bytes
(100%)
tests/e2e_regression/eden/rpc-cache/consensus/00000-1.psg.pmt
Binary file not shown.
Binary file not shown.
Git LFS file not shown
4 changes: 2 additions & 2 deletions
4
tests/e2e_regression/edenfast/rpc-cache/consensus/00000-1.psg
Git LFS file not shown
Binary file modified
BIN
+0 Bytes
(100%)
tests/e2e_regression/edenfast/rpc-cache/consensus/00000-1.psg.pmt
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
tests/e2e_regression/edenfast/rpc-cache/consensus/index.pmt
Binary file not shown.
Git LFS file not shown