forked from TrueCloudLab/frostfs-contract
[#74] Add notary disabled option to contracts
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
7317388b4d
commit
622a83e014
8 changed files with 72 additions and 14 deletions
|
@ -19,6 +19,8 @@ const (
|
||||||
totalKey = "threshold"
|
totalKey = "threshold"
|
||||||
nameKey = "name"
|
nameKey = "name"
|
||||||
|
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
|
|
||||||
version = 1
|
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()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
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, indexKey, index)
|
||||||
storage.Put(ctx, totalKey, total)
|
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")
|
runtime.Log(name + " contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,11 @@ const (
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
netmapContractKey = "netmapScriptHash"
|
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()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
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, common.OwnerKey, owner)
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
|
|
||||||
|
// initialize the way to collect signatures
|
||||||
|
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
|
||||||
|
|
||||||
runtime.Log("audit contract initialized")
|
runtime.Log("audit contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ const (
|
||||||
|
|
||||||
netmapContractKey = "netmapScriptHash"
|
netmapContractKey = "netmapScriptHash"
|
||||||
containerContractKey = "containerScriptHash"
|
containerContractKey = "containerScriptHash"
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -62,7 +63,7 @@ func init() {
|
||||||
token = CreateToken()
|
token = CreateToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
|
@ -77,6 +78,12 @@ func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
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")
|
runtime.Log("balance contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,8 @@ const (
|
||||||
neofsIDContractKey = "identityScriptHash"
|
neofsIDContractKey = "identityScriptHash"
|
||||||
balanceContractKey = "balanceScriptHash"
|
balanceContractKey = "balanceScriptHash"
|
||||||
netmapContractKey = "netmapScriptHash"
|
netmapContractKey = "netmapScriptHash"
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
|
|
||||||
containerFeeKey = "ContainerFee"
|
containerFeeKey = "ContainerFee"
|
||||||
|
|
||||||
containerIDSize = 32 // SHA256 size
|
containerIDSize = 32 // SHA256 size
|
||||||
|
@ -53,7 +55,7 @@ var (
|
||||||
eACLPrefix = []byte("eACL")
|
eACLPrefix = []byte("eACL")
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(owner, addrNetmap, addrBalance, addrID interop.Hash160) {
|
func Init(notaryDisabled bool, owner, addrNetmap, addrBalance, addrID interop.Hash160) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
|
@ -69,6 +71,12 @@ func Init(owner, addrNetmap, addrBalance, addrID interop.Hash160) {
|
||||||
storage.Put(ctx, balanceContractKey, addrBalance)
|
storage.Put(ctx, balanceContractKey, addrBalance)
|
||||||
storage.Put(ctx, neofsIDContractKey, addrID)
|
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")
|
runtime.Log("container contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ const (
|
||||||
|
|
||||||
alphabetKey = "alphabet"
|
alphabetKey = "alphabet"
|
||||||
candidatesKey = "candidates"
|
candidatesKey = "candidates"
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
|
|
||||||
processingContractKey = "processingScriptHash"
|
processingContractKey = "processingScriptHash"
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init set up initial alphabet node keys.
|
// 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()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
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, common.OwnerKey, owner)
|
||||||
storage.Put(ctx, processingContractKey, addrProc)
|
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")
|
runtime.Log("neofs: contract initialized")
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -20,9 +20,10 @@ const (
|
||||||
|
|
||||||
netmapContractKey = "netmapScriptHash"
|
netmapContractKey = "netmapScriptHash"
|
||||||
containerContractKey = "containerScriptHash"
|
containerContractKey = "containerScriptHash"
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
func Init(notaryDisabled bool, owner, addrNetmap, addrContainer interop.Hash160) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
|
@ -37,6 +38,12 @@ func Init(owner, addrNetmap, addrContainer interop.Hash160) {
|
||||||
storage.Put(ctx, netmapContractKey, addrNetmap)
|
storage.Put(ctx, netmapContractKey, addrNetmap)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
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")
|
runtime.Log("neofsid contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ const (
|
||||||
|
|
||||||
netmapKey = "netmap"
|
netmapKey = "netmap"
|
||||||
configuredKey = "initconfig"
|
configuredKey = "initconfig"
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
|
|
||||||
snapshot0Key = "snapshotCurrent"
|
snapshot0Key = "snapshotCurrent"
|
||||||
snapshot1Key = "snapshotPrevious"
|
snapshot1Key = "snapshotPrevious"
|
||||||
|
@ -41,6 +42,7 @@ const (
|
||||||
|
|
||||||
containerContractKey = "containerScriptHash"
|
containerContractKey = "containerScriptHash"
|
||||||
balanceContractKey = "balanceScriptHash"
|
balanceContractKey = "balanceScriptHash"
|
||||||
|
|
||||||
cleanupEpochMethod = "newEpoch"
|
cleanupEpochMethod = "newEpoch"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ var (
|
||||||
|
|
||||||
// Init function sets up initial list of inner ring public keys and should
|
// Init function sets up initial list of inner ring public keys and should
|
||||||
// be invoked once at neofs infrastructure setup.
|
// 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()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
|
@ -80,6 +82,12 @@ func Init(owner, addrBalance, addrContainer interop.Hash160) {
|
||||||
storage.Put(ctx, balanceContractKey, addrBalance)
|
storage.Put(ctx, balanceContractKey, addrBalance)
|
||||||
storage.Put(ctx, containerContractKey, addrContainer)
|
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")
|
runtime.Log("netmap contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
notaryDisabledKey = "notary"
|
||||||
|
|
||||||
version = 1
|
version = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init(owner interop.Hash160) {
|
func Init(notaryDisabled bool, owner interop.Hash160) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
|
@ -23,6 +25,12 @@ func Init(owner interop.Hash160) {
|
||||||
|
|
||||||
storage.Put(ctx, common.OwnerKey, owner)
|
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")
|
runtime.Log("reputation contract initialized")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue