[#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:
Alex Vanin 2021-09-21 15:58:37 +03:00 committed by Alex Vanin
parent b555e200f4
commit edd4864e39
10 changed files with 20 additions and 50 deletions

View file

@ -75,18 +75,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("alphabet contract updated")
return true
}
// GAS returns amount of side chain GAS stored in contract account.

View file

@ -75,18 +75,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("audit contract updated")
return true
}
// Put method stores stable marshalled `DataAuditResult` structure. Can be

View file

@ -95,18 +95,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("balance contract updated")
return true
}
// Symbol is a NEP-17 standard method that returns NEOFS token symbol.

View file

@ -100,18 +100,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("container contract updated")
return true
}
// Put method creates new container if it was invoked by Alphabet nodes

View file

@ -111,18 +111,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("neofs contract updated")
return true
}
// AlphabetList returns array of alphabet node keys. Use in side chain notary

View file

@ -60,18 +60,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("neofsid contract updated")
return true
}
// AddKey binds list of provided public keys to OwnerID. Can be invoked only by

View file

@ -125,18 +125,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("netmap contract updated")
return true
}
// InnerRingList method returns slice of structures that contains public key of

View file

@ -51,18 +51,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("processing contract updated")
return true
}
// Verify method returns true if transaction contains valid multi signature of

View file

@ -50,18 +50,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("proxy contract updated")
return true
}
// Verify method returns true if transaction contains valid multi signature of

View file

@ -44,18 +44,15 @@ func _deploy(data interface{}, isUpdate bool) {
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
func Update(script []byte, manifest []byte, data interface{}) bool {
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
runtime.Log("only owner can update contract")
return false
panic("only owner can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
runtime.Log("reputation contract updated")
return true
}
// Put method saves DataAuditResult in contract storage. Can be invoked only by