Skip to content

Commit

Permalink
nns: fix deployments with 0.38.1 adm
Browse files Browse the repository at this point in the history
I'm not yet sure we need it, but old adm (before nspcc-dev/neofs-node#2625)
creates a broken deploy script with actual data that has no fields inside.
Not a problem for updates, not a problem for newer adm, but still.

Signed-off-by: Roman Khimov <[email protected]>
  • Loading branch information
roman-khimov committed Nov 29, 2023
1 parent 05f0278 commit 59a7f7d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
42 changes: 25 additions & 17 deletions nns/nns_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,32 @@ func _deploy(data any, isUpdate bool) {
storage.Put(ctx, []byte{prefixTotalSupply}, 0)
storage.Put(ctx, []byte{prefixRegisterPrice}, defaultRegisterPrice)

if data != nil { // for backward compatibility
args := data.(struct {
tldSet []struct {
name string
email string
}
})

for i := range args.tldSet {
const (
refresh = 3600
retry = 600
expire = 10 * 365 * 24 * 60 * 60 // 10 years
ttl = 3600
)
saveCommitteeDomain(ctx, args.tldSet[i].name, args.tldSet[i].email, refresh, retry, expire, ttl)
runtime.Log("registered committee domain " + args.tldSet[i].name)
if data == nil { // TLDs are optional.
return
}

s := data.([]any)

if len(s) == 0 { // pre-0.39.0 neofs-adm happily pushes an empty slice into data
return
}

args := data.(struct {
tldSet []struct {
name string
email string
}
})

for i := range args.tldSet {
const (
refresh = 3600
retry = 600
expire = 10 * 365 * 24 * 60 * 60 // 10 years
ttl = 3600
)
saveCommitteeDomain(ctx, args.tldSet[i].name, args.tldSet[i].email, refresh, retry, expire, ttl)
runtime.Log("registered committee domain " + args.tldSet[i].name)
}
}

Expand Down
6 changes: 6 additions & 0 deletions tests/nns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func TestNNSGeneric(t *testing.T) {
c.Invoke(t, 0, "totalSupply")
}

func TestOldAdmDeploy(t *testing.T) {
e := newExecutor(t)
ctr := neotest.CompileFile(t, e.CommitteeHash, nnsPath, path.Join(nnsPath, "config.yml"))
e.DeployContract(t, ctr, []any{})
}

func TestNNSRegisterTLD(t *testing.T) {
c := newNNSInvoker(t, false)

Expand Down

0 comments on commit 59a7f7d

Please sign in to comment.