[#196] nns: remove duplicate records in _deploy

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-02-02 11:29:13 +03:00 committed by Alex Vanin
parent d48709fcbb
commit 74e4bbb6b9

View file

@ -93,47 +93,35 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int))
if runtime.GetNetwork() == 0x572dfa5 {
// Some of the domains in mainnet have duplicate SOA records.
// One is stored by key with id 0, and the other with id []byte{0, 0, 0}.
// Delete the latter. Subnet contract is not affected.
ctx := storage.GetContext()
committee := common.CommitteeAddress()
it := storage.Find(ctx, []byte{prefixRoot}, storage.KeysOnly|storage.RemovePrefix)
for iterator.Next(it) {
name := iterator.Value(it).(string)
if name != "neofs" {
continue
for _, name := range []string{
"alphabet0.neofs",
"alphabet1.neofs",
"alphabet2.neofs",
"alphabet3.neofs",
"alphabet4.neofs",
"alphabet5.neofs",
"alphabet6.neofs",
"container.neofs",
"reputation.neofs",
"neofsid.neofs",
"balance.neofs",
"netmap.neofs",
"audit.neofs",
} {
tokenID := []byte(tokenIDFromName(name))
recordsKey := getRecordsKeyByType(tokenID, name, SOA)
oldKey := append(recordsKey, 0, 0, 0)
data := storage.Get(ctx, oldKey)
if data == nil {
panic("unexpected")
}
ns := NameState{
Owner: committee,
Name: name,
Expiration: runtime.GetTime() + millisecondsInYear,
storage.Delete(ctx, oldKey)
}
tokenKey := getTokenKey([]byte(name))
putNameStateWithKey(ctx, tokenKey, ns)
putSoaRecord(ctx, name, "ops@nspcc.ru",
3600 /* 1 hour */, 600, /* 10 min */
604800 /* 1 week */, 3600 /* 1 hour */)
}
r := GetRecords("container.neofs", TXT)
owner := shBEFromLEHex(r[0])
it = storage.Find(ctx, []byte{prefixRoot}, storage.KeysOnly|storage.RemovePrefix)
for iterator.Next(it) {
name := iterator.Value(it).(string)
if name == "neofs" {
continue
}
ns := NameState{
Owner: owner,
Name: name,
Expiration: runtime.GetTime() + millisecondsInYear,
}
tokenKey := getTokenKey([]byte(name))
putNameStateWithKey(ctx, tokenKey, ns)
putSoaRecord(ctx, name, "ops@nspcc.ru",
3600 /* 1 hour */, 600, /* 10 min */
604800 /* 1 week */, 3600 /* 1 hour */)
}
return
}