-
Notifications
You must be signed in to change notification settings - Fork 28
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
Introduce composite key to delegate features to each function key #101
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ import ( | |
|
||
"github.com/tendermint/tendermint/abci/example/code" | ||
"github.com/tendermint/tendermint/abci/types" | ||
"github.com/tendermint/tendermint/crypto/ed25519" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
) | ||
|
@@ -205,15 +204,20 @@ func (app *PersistentKVStoreApplication) execValidatorTx(tx []byte) types.Respon | |
} | ||
|
||
// update | ||
return app.updateValidator(types.Ed25519ValidatorUpdate(pubkey, power)) | ||
// TODO The type of public key to be restored should be kept its original type. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you have any plan to change the type of public key later? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed the relevant part, but since there is no |
||
return app.updateValidator(types.NewValidatorUpdate(tmtypes.ABCIPubKeyTypeComposite, pubkey, power)) | ||
} | ||
|
||
// add, update, or remove a validator | ||
func (app *PersistentKVStoreApplication) updateValidator(v types.ValidatorUpdate) types.ResponseDeliverTx { | ||
key := []byte("val:" + string(v.PubKey.Data)) | ||
|
||
pubkey := ed25519.PubKeyEd25519{} | ||
copy(pubkey[:], v.PubKey.Data) | ||
pubkey, err := tmtypes.PB2TM.PubKey(v.PubKey) | ||
if err != nil { | ||
return types.ResponseDeliverTx{ | ||
Code: code.CodeTypeEncodingError, | ||
Log: fmt.Sprintf("Error encoding validator: %v", err)} | ||
} | ||
|
||
if v.Power == 0 { | ||
// remove validator | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ import ( | |
"errors" | ||
"fmt" | ||
|
||
"github.com/tendermint/tendermint/crypto/composite" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
|
||
abcicli "github.com/tendermint/tendermint/abci/client" | ||
"github.com/tendermint/tendermint/abci/types" | ||
tmrand "github.com/tendermint/tendermint/libs/rand" | ||
|
@@ -14,9 +17,10 @@ func InitChain(client abcicli.Client) error { | |
total := 10 | ||
vals := make([]types.ValidatorUpdate, total) | ||
for i := 0; i < total; i++ { | ||
pubkey := tmrand.Bytes(33) | ||
pk := composite.GenPrivKey().PubKey() | ||
pubkey := tmtypes.TM2PB.PubKey(pk).Data | ||
power := tmrand.Int() | ||
vals[i] = types.Ed25519ValidatorUpdate(pubkey, int64(power)) | ||
vals[i] = types.NewValidatorUpdate("composite", pubkey, int64(power)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, I'll fix it. |
||
} | ||
_, err := client.InitChainSync(types.RequestInitChain{ | ||
Validators: vals, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ import ( | |
"fmt" | ||
"strings" | ||
|
||
"github.com/tendermint/tendermint/cmd/contract_tests/unmarshaler" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know why this import sorting is changed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do different versions of
|
||
|
||
"github.com/snikch/goodman/hooks" | ||
"github.com/snikch/goodman/transaction" | ||
|
||
"github.com/tendermint/tendermint/cmd/contract_tests/unmarshaler" | ||
) | ||
|
||
func main() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think choosing which key to use should be handled in one place. The same is true in codes for testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've defined another function that generates a private key for the example and tests.