diff --git a/api/keystore/service.go b/api/keystore/service.go index fe1b349..5575083 100644 --- a/api/keystore/service.go +++ b/api/keystore/service.go @@ -218,7 +218,7 @@ func (ks *Keystore) ExportUser(_ *http.Request, args *ExportUserArgs, reply *Exp return err } if !usr.CheckPassword(args.Password) { - return fmt.Errorf("incorrect password for %s", args.Username) + return fmt.Errorf("incorrect password for user %q", args.Username) } userDB := prefixdb.New([]byte(args.Username), ks.bcDB) @@ -274,6 +274,9 @@ func (ks *Keystore) ImportUser(r *http.Request, args *ImportUserArgs, reply *Imp if err := ks.codec.Unmarshal(args.User.Bytes, &userData); err != nil { return err } + if !userData.User.CheckPassword(args.Password) { + return fmt.Errorf("incorrect password for user %q", args.Username) + } usrBytes, err := ks.codec.Marshal(&userData.User) if err != nil { @@ -383,7 +386,7 @@ func (ks *Keystore) GetDatabase(bID ids.ID, username, password string) (database return nil, err } if !usr.CheckPassword(password) { - return nil, fmt.Errorf("incorrect password for user '%s'", username) + return nil, fmt.Errorf("incorrect password for user %q", username) } userDB := prefixdb.New([]byte(username), ks.bcDB) diff --git a/api/keystore/service_test.go b/api/keystore/service_test.go index 75b7166..b4c805d 100644 --- a/api/keystore/service_test.go +++ b/api/keystore/service_test.go @@ -255,6 +255,17 @@ func TestServiceExportImport(t *testing.T) { newKS := Keystore{} newKS.Initialize(logging.NoLog{}, memdb.New()) + { + reply := ImportUserReply{} + if err := newKS.ImportUser(nil, &ImportUserArgs{ + Username: "bob", + Password: "", + User: exportReply.User, + }, &reply); err == nil { + t.Fatal("Should have errored due to incorrect password") + } + } + { reply := ImportUserReply{} if err := newKS.ImportUser(nil, &ImportUserArgs{ diff --git a/networking/handshake_handlers.go b/networking/handshake_handlers.go index d82df74..554f4fb 100644 --- a/networking/handshake_handlers.go +++ b/networking/handshake_handlers.go @@ -515,7 +515,7 @@ func (nm *Handshake) disconnectedFromPeer(peer salticidae.PeerID) { nm.connections.Remove(peer, cert) nm.numPeers.Set(float64(nm.connections.Len())) - if nm.vdrs.Contains(cert) { + if !nm.enableStaking || nm.vdrs.Contains(cert) { nm.reconnectTimeout.Put(peerID, func() { nm.pending.Remove(peer, cert) nm.connections.Remove(peer, cert) diff --git a/vms/platformvm/atomic_block.go b/vms/platformvm/atomic_block.go index 20c2892..3293094 100644 --- a/vms/platformvm/atomic_block.go +++ b/vms/platformvm/atomic_block.go @@ -36,7 +36,7 @@ type AtomicTx interface { // AtomicBlock being accepted results in the transaction contained in the // block to be accepted and committed to the chain. type AtomicBlock struct { - SingleDecisionBlock `serialize:"true"` + CommonDecisionBlock `serialize:"true"` Tx AtomicTx `serialize:"true"` @@ -45,7 +45,7 @@ type AtomicBlock struct { // initialize this block func (ab *AtomicBlock) initialize(vm *VM, bytes []byte) error { - if err := ab.SingleDecisionBlock.initialize(vm, bytes); err != nil { + if err := ab.CommonDecisionBlock.initialize(vm, bytes); err != nil { return err } return ab.Tx.initialize(vm) @@ -123,9 +123,6 @@ func (ab *AtomicBlock) Accept() { ab.onAcceptFunc() } - parent := ab.parentBlock() - // remove this block and its parent from memory - parent.free() ab.free() } @@ -133,11 +130,9 @@ func (ab *AtomicBlock) Accept() { // decision block, has ID [parentID]. func (vm *VM) newAtomicBlock(parentID ids.ID, tx AtomicTx) (*AtomicBlock, error) { ab := &AtomicBlock{ - SingleDecisionBlock: SingleDecisionBlock{CommonDecisionBlock: CommonDecisionBlock{ - CommonBlock: CommonBlock{ - Block: core.NewBlock(parentID), - vm: vm, - }, + CommonDecisionBlock: CommonDecisionBlock{CommonBlock: CommonBlock{ + Block: core.NewBlock(parentID), + vm: vm, }}, Tx: tx, }