Merge pull request #1869 from nspcc-dev/testnet-storage-fixes
core: RC1 states dumps compatibility fixes
This commit is contained in:
commit
1bd3ee299c
3 changed files with 36 additions and 3 deletions
|
@ -726,6 +726,28 @@ func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pub *keys.Public
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// we should put it in storage anyway as it affects dumps
|
||||||
|
err = ic.DAO.PutStorageItem(n.ID, key, si)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if pub != nil {
|
||||||
|
valKey := makeValidatorKey(pub)
|
||||||
|
valSi := ic.DAO.GetStorageItem(n.ID, valKey)
|
||||||
|
if valSi == nil {
|
||||||
|
return errors.New("unknown validator")
|
||||||
|
}
|
||||||
|
cd := new(candidate).FromBytes(valSi)
|
||||||
|
// we should put it in storage anyway as it affects dumps
|
||||||
|
err = ic.DAO.PutStorageItem(n.ID, valKey, valSi)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !cd.Registered {
|
||||||
|
return errors.New("validator must be registered")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (acc.VoteTo == nil) != (pub == nil) {
|
if (acc.VoteTo == nil) != (pub == nil) {
|
||||||
val := &acc.Balance
|
val := &acc.Balance
|
||||||
if pub == nil {
|
if pub == nil {
|
||||||
|
@ -765,8 +787,6 @@ func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *b
|
||||||
if ok {
|
if ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if !cd.Registered {
|
|
||||||
return errors.New("validator must be registered")
|
|
||||||
}
|
}
|
||||||
n.validators.Store(keys.PublicKeys(nil))
|
n.validators.Store(keys.PublicKeys(nil))
|
||||||
return d.PutStorageItem(n.ID, key, cd.Bytes())
|
return d.PutStorageItem(n.ID, key, cd.Bytes())
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ledgerContractID = -2
|
var ledgerContractID = -4
|
||||||
|
|
||||||
type dump []blockDump
|
type dump []blockDump
|
||||||
|
|
||||||
|
|
13
scripts/compare-dumps_test.go
Normal file
13
scripts/compare-dumps_test.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestCompatibility(t *testing.T) {
|
||||||
|
cs := native.NewContracts(false, map[string][]uint32{})
|
||||||
|
require.Equal(t, cs.Ledger.ID, int32(ledgerContractID))
|
||||||
|
}
|
Loading…
Reference in a new issue