[#74] Add notary disabled option to contracts

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-04-27 13:48:40 +03:00 committed by Alex Vanin
parent 7317388b4d
commit 622a83e014
8 changed files with 72 additions and 14 deletions

View file

@ -19,6 +19,8 @@ const (
totalKey = "threshold"
nameKey = "name"
notaryDisabledKey = "notary"
version = 1
)
@ -30,7 +32,7 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
}
}
func Init(owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name string, index, total int) {
func Init(notaryDisabled bool, owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name string, index, total int) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -48,6 +50,12 @@ func Init(owner interop.Hash160, addrNetmap, addrProxy interop.Hash160, name str
storage.Put(ctx, indexKey, index)
storage.Put(ctx, totalKey, total)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log(name + " contract initialized")
}

View file

@ -38,9 +38,11 @@ const (
version = 1
netmapContractKey = "netmapScriptHash"
notaryDisabledKey = "notary"
)
func Init(owner interop.Hash160, addrNetmap interop.Hash160) {
func Init(notaryDisabled bool, owner interop.Hash160, addrNetmap interop.Hash160) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -54,6 +56,9 @@ func Init(owner interop.Hash160, addrNetmap interop.Hash160) {
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapContractKey, addrNetmap)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
runtime.Log("audit contract initialized")
}

View file

@ -40,6 +40,7 @@ const (
netmapContractKey = "netmapScriptHash"
containerContractKey = "containerScriptHash"
notaryDisabledKey = "notary"
)
var (
@ -62,7 +63,7 @@ func init() {
token = CreateToken()
}
func Init(owner, addrNetmap, addrContainer interop.Hash160) {
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -77,6 +78,12 @@ func Init(owner, addrNetmap, addrContainer interop.Hash160) {
storage.Put(ctx, netmapContractKey, addrNetmap)
storage.Put(ctx, containerContractKey, addrContainer)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log("balance contract initialized")
}

View file

@ -41,7 +41,9 @@ const (
neofsIDContractKey = "identityScriptHash"
balanceContractKey = "balanceScriptHash"
netmapContractKey = "netmapScriptHash"
containerFeeKey = "ContainerFee"
notaryDisabledKey = "notary"
containerFeeKey = "ContainerFee"
containerIDSize = 32 // SHA256 size
@ -53,7 +55,7 @@ var (
eACLPrefix = []byte("eACL")
)
func Init(owner, addrNetmap, addrBalance, addrID interop.Hash160) {
func Init(notaryDisabled bool, owner, addrNetmap, addrBalance, addrID interop.Hash160) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -69,6 +71,12 @@ func Init(owner, addrNetmap, addrBalance, addrID interop.Hash160) {
storage.Put(ctx, balanceContractKey, addrBalance)
storage.Put(ctx, neofsIDContractKey, addrID)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log("container contract initialized")
}

View file

@ -57,8 +57,9 @@ const (
version = 3
alphabetKey = "alphabet"
candidatesKey = "candidates"
alphabetKey = "alphabet"
candidatesKey = "candidates"
notaryDisabledKey = "notary"
processingContractKey = "processingScriptHash"
@ -75,7 +76,7 @@ var (
)
// Init set up initial alphabet node keys.
func Init(owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
func Init(notaryDisabled bool, owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -107,6 +108,12 @@ func Init(owner, addrProc interop.Hash160, args []interop.PublicKey) bool {
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, processingContractKey, addrProc)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log("neofs: contract initialized")
return true

View file

@ -20,9 +20,10 @@ const (
netmapContractKey = "netmapScriptHash"
containerContractKey = "containerScriptHash"
notaryDisabledKey = "notary"
)
func Init(owner, addrNetmap, addrContainer interop.Hash160) {
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -37,6 +38,12 @@ func Init(owner, addrNetmap, addrContainer interop.Hash160) {
storage.Put(ctx, netmapContractKey, addrNetmap)
storage.Put(ctx, containerContractKey, addrContainer)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log("neofsid contract initialized")
}

View file

@ -32,8 +32,9 @@ type (
const (
version = 1
netmapKey = "netmap"
configuredKey = "initconfig"
netmapKey = "netmap"
configuredKey = "initconfig"
notaryDisabledKey = "notary"
snapshot0Key = "snapshotCurrent"
snapshot1Key = "snapshotPrevious"
@ -41,7 +42,8 @@ const (
containerContractKey = "containerScriptHash"
balanceContractKey = "balanceScriptHash"
cleanupEpochMethod = "newEpoch"
cleanupEpochMethod = "newEpoch"
)
const (
@ -56,7 +58,7 @@ var (
// Init function sets up initial list of inner ring public keys and should
// be invoked once at neofs infrastructure setup.
func Init(owner, addrBalance, addrContainer interop.Hash160) {
func Init(notaryDisabled bool, owner, addrBalance, addrContainer interop.Hash160) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -80,6 +82,12 @@ func Init(owner, addrBalance, addrContainer interop.Hash160) {
storage.Put(ctx, balanceContractKey, addrBalance)
storage.Put(ctx, containerContractKey, addrContainer)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log("netmap contract initialized")
}

View file

@ -11,10 +11,12 @@ import (
)
const (
notaryDisabledKey = "notary"
version = 1
)
func Init(owner interop.Hash160) {
func Init(notaryDisabled bool, owner interop.Hash160) {
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
@ -23,6 +25,12 @@ func Init(owner interop.Hash160) {
storage.Put(ctx, common.OwnerKey, owner)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
common.InitVote(ctx)
}
runtime.Log("reputation contract initialized")
}