forked from TrueCloudLab/frostfs-contract
[#130] Panic at contract update failures
There is no practical cases not to panic at contract update routine. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
b555e200f4
commit
edd4864e39
10 changed files with 20 additions and 50 deletions
|
@ -75,18 +75,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("alphabet contract updated")
|
runtime.Log("alphabet contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GAS returns amount of side chain GAS stored in contract account.
|
// GAS returns amount of side chain GAS stored in contract account.
|
||||||
|
|
|
@ -75,18 +75,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("audit contract updated")
|
runtime.Log("audit contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put method stores stable marshalled `DataAuditResult` structure. Can be
|
// Put method stores stable marshalled `DataAuditResult` structure. Can be
|
||||||
|
|
|
@ -95,18 +95,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("balance contract updated")
|
runtime.Log("balance contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Symbol is a NEP-17 standard method that returns NEOFS token symbol.
|
// Symbol is a NEP-17 standard method that returns NEOFS token symbol.
|
||||||
|
|
|
@ -100,18 +100,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("container contract updated")
|
runtime.Log("container contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put method creates new container if it was invoked by Alphabet nodes
|
// Put method creates new container if it was invoked by Alphabet nodes
|
||||||
|
|
|
@ -111,18 +111,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("neofs contract updated")
|
runtime.Log("neofs contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlphabetList returns array of alphabet node keys. Use in side chain notary
|
// AlphabetList returns array of alphabet node keys. Use in side chain notary
|
||||||
|
|
|
@ -60,18 +60,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("neofsid contract updated")
|
runtime.Log("neofsid contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddKey binds list of provided public keys to OwnerID. Can be invoked only by
|
// AddKey binds list of provided public keys to OwnerID. Can be invoked only by
|
||||||
|
|
|
@ -125,18 +125,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("netmap contract updated")
|
runtime.Log("netmap contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InnerRingList method returns slice of structures that contains public key of
|
// InnerRingList method returns slice of structures that contains public key of
|
||||||
|
|
|
@ -51,18 +51,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("processing contract updated")
|
runtime.Log("processing contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify method returns true if transaction contains valid multi signature of
|
// Verify method returns true if transaction contains valid multi signature of
|
||||||
|
|
|
@ -50,18 +50,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("proxy contract updated")
|
runtime.Log("proxy contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify method returns true if transaction contains valid multi signature of
|
// Verify method returns true if transaction contains valid multi signature of
|
||||||
|
|
|
@ -44,18 +44,15 @@ func _deploy(data interface{}, isUpdate bool) {
|
||||||
|
|
||||||
// Update method updates contract source code and manifest. Can be invoked
|
// Update method updates contract source code and manifest. Can be invoked
|
||||||
// only by contract owner.
|
// only by contract owner.
|
||||||
func Update(script []byte, manifest []byte, data interface{}) bool {
|
func Update(script []byte, manifest []byte, data interface{}) {
|
||||||
ctx := storage.GetReadOnlyContext()
|
ctx := storage.GetReadOnlyContext()
|
||||||
|
|
||||||
if !common.HasUpdateAccess(ctx) {
|
if !common.HasUpdateAccess(ctx) {
|
||||||
runtime.Log("only owner can update contract")
|
panic("only owner can update contract")
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
|
||||||
runtime.Log("reputation contract updated")
|
runtime.Log("reputation contract updated")
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put method saves DataAuditResult in contract storage. Can be invoked only by
|
// Put method saves DataAuditResult in contract storage. Can be invoked only by
|
||||||
|
|
Loading…
Reference in a new issue