[#184] *: Remove method prefix in panic messages

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-11-29 13:51:57 +03:00 committed by Alex Vanin
parent 4961e9b436
commit ac89694eeb
12 changed files with 144 additions and 144 deletions

View file

@ -28,7 +28,7 @@ const (
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
caller := runtime.GetCallingScriptHash()
if !common.BytesEqual(caller, []byte(gas.Hash)) && !common.BytesEqual(caller, []byte(neo.Hash)) {
panic("onNEP17Payment: alphabet contract accepts GAS and NEO only")
panic("alphabet contract accepts GAS and NEO only")
}
}

View file

@ -54,7 +54,7 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext()
if len(addrNetmap) != 20 {
panic("init: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
storage.Put(ctx, netmapContractKey, addrNetmap)
@ -112,7 +112,7 @@ func Put(rawAuditResult []byte) {
}
if !runtime.CheckWitness(hdr.from) || !presented {
panic("audit: put access denied")
panic("put access denied")
}
storage.Put(ctx, hdr.ID(), rawAuditResult)

View file

@ -71,7 +71,7 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext()
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
panic("init: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
storage.Put(ctx, netmapContractKey, addrNetmap)
@ -156,7 +156,7 @@ func TransferX(from, to interop.Hash160, amount int, details []byte) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("transferX: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
indirectCall = common.FromKnownContract(
@ -167,7 +167,7 @@ func TransferX(from, to interop.Hash160, amount int, details []byte) {
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("transferX: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
}
@ -185,10 +185,10 @@ func TransferX(from, to interop.Hash160, amount int, details []byte) {
result := token.transfer(ctx, from, to, amount, true, details)
if !result {
panic("transferX: fail")
panic("can't transfer assets")
}
runtime.Log("transferX: success")
runtime.Log("successfully transferred assets")
}
// Lock is a method that transfers assets from user account to lock account
@ -212,12 +212,12 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("lock: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("lock: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
}
@ -246,7 +246,7 @@ func Lock(txDetails []byte, from, to interop.Hash160, amount, until int) {
result := token.transfer(ctx, from, to, amount, true, details)
if !result {
// consider using `return false` to remove votes
panic("lock: can't lock funds")
panic("can't lock funds")
}
runtime.Log("lock: created lock account")
@ -269,12 +269,12 @@ func NewEpoch(epochNum int) {
netmapContractKey,
)
if !indirectCall {
panic("newEpoch: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("newEpoch: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
}
@ -320,12 +320,12 @@ func Mint(to interop.Hash160, amount int, txDetails []byte) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("mint: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("mint: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
}
@ -345,7 +345,7 @@ func Mint(to interop.Hash160, amount int, txDetails []byte) {
ok := token.transfer(ctx, nil, to, amount, true, details)
if !ok {
panic("mint: can't transfer assets")
panic("can't transfer assets")
}
supply := token.getSupply(ctx)
@ -379,12 +379,12 @@ func Burn(from interop.Hash160, amount int, txDetails []byte) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("burn: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("burn: this method must be invoked from inner ring")
panic("this method must be invoked from inner ring")
}
}
@ -404,12 +404,12 @@ func Burn(from interop.Hash160, amount int, txDetails []byte) {
ok := token.transfer(ctx, from, nil, amount, true, details)
if !ok {
panic("burn: can't transfer assets")
panic("can't transfer assets")
}
supply := token.getSupply(ctx)
if supply < amount {
panic("panic, negative supply after burn")
panic("negative supply after burn")
}
supply = supply - amount

View file

@ -227,7 +227,7 @@ func PutNamed(container []byte, signature interop.Signature,
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("put: alphabet witness check failed")
panic("alphabet witness check failed")
}
}
// todo: check if new container with unique container id
@ -334,7 +334,7 @@ func Delete(containerID []byte, signature interop.Signature, token []byte) {
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("delete: alphabet witness check failed")
panic("alphabet witness check failed")
}
}
@ -446,7 +446,7 @@ func SetEACL(eACL []byte, signature interop.Signature, publicKey interop.PublicK
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("setEACL: alphabet witness check failed")
panic("alphabet witness check failed")
}
}
@ -497,7 +497,7 @@ func PutContainerSize(epoch int, cid []byte, usedSize int, pubKey interop.Public
}
if !isStorageNode(ctx, pubKey) {
panic("putContainerSize method must be invoked by storage node from network map")
panic("method must be invoked by storage node from network map")
}
key := estimationKey(epoch, cid, pubKey)
@ -576,12 +576,12 @@ func NewEpoch(epochNum int) {
netmapContractKey,
)
if !indirectCall {
panic("newEpoch method must be invoked by inner ring")
panic("method must be invoked by inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("newEpoch method must be invoked by inner ring")
panic("method must be invoked by inner ring")
}
}
@ -606,12 +606,12 @@ func StartContainerEstimation(epoch int) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("startContainerEstimation method must be invoked by inner ring")
panic("method must be invoked by inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("startContainerEstimation method must be invoked by inner ring")
panic("method must be invoked by inner ring")
}
}
@ -646,12 +646,12 @@ func StopContainerEstimation(epoch int) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("stopContainerEstimation method must be invoked by inner ring")
panic("method must be invoked by inner ring")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("stopContainerEstimation method must be invoked by inner ring")
panic("method must be invoked by inner ring")
}
}

View file

@ -62,17 +62,17 @@ func _deploy(data interface{}, isUpdate bool) {
var irList []common.IRNode
if len(keys) == 0 {
panic("neofs: at least one alphabet key must be provided")
panic("at least one alphabet key must be provided")
}
if len(addrProc) != 20 {
panic("neofs: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
for i := 0; i < len(keys); i++ {
pub := keys[i]
if len(pub) != publicKeySize {
panic("neofs: incorrect public key length")
panic("incorrect public key length")
}
irList = append(irList, common.IRNode{PublicKey: pub})
}
@ -92,7 +92,7 @@ func _deploy(data interface{}, isUpdate bool) {
ln := len(config)
if ln%2 != 0 {
panic("init: bad configuration")
panic("bad configuration")
}
for i := 0; i < ln/2; i++ {
@ -162,12 +162,12 @@ func InnerRingCandidateRemove(key interop.PublicKey) {
alphabet = getNodes(ctx, alphabetKey)
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("irCandidateRemove: this method must be invoked by candidate or alphabet")
panic("this method must be invoked by candidate or alphabet")
}
} else {
multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("irCandidateRemove: this method must be invoked by candidate or alphabet")
panic("this method must be invoked by candidate or alphabet")
}
}
}
@ -209,7 +209,7 @@ func InnerRingCandidateAdd(key interop.PublicKey) {
ctx := storage.GetContext()
if !runtime.CheckWitness(key) {
panic("irCandidateAdd: this method must be invoked by candidate")
panic("this method must be invoked by candidate")
}
c := common.IRNode{PublicKey: key}
@ -217,7 +217,7 @@ func InnerRingCandidateAdd(key interop.PublicKey) {
list, ok := addNode(candidates, c)
if !ok {
panic("irCandidateAdd: candidate already in the list")
panic("candidate already in the list")
}
from := contract.CreateStandardAccount(key)
@ -226,7 +226,7 @@ func InnerRingCandidateAdd(key interop.PublicKey) {
transferred := gas.Transfer(from, to, fee, []byte(ignoreDepositNotification))
if !transferred {
panic("irCandidateAdd: failed to transfer funds, aborting")
panic("failed to transfer funds, aborting")
}
runtime.Log("irCandidateAdd: candidate has been added")
@ -244,14 +244,14 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
}
if amount <= 0 {
panic("onNEP17Payment: amount must be positive")
panic("amount must be positive")
} else if maxBalanceAmountGAS < amount {
panic("onNEP17Payment: out of max amount limit")
panic("out of max amount limit")
}
caller := runtime.GetCallingScriptHash()
if !common.BytesEqual(caller, interop.Hash160(gas.Hash)) {
panic("onNEP17Payment: only GAS can be accepted for deposit")
panic("only GAS can be accepted for deposit")
}
switch len(rcv) {
@ -259,7 +259,7 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
case 0:
rcv = from
default:
panic("onNEP17Payment: invalid data argument, expected Hash160")
panic("invalid data argument, expected Hash160")
}
runtime.Log("onNEP17Payment: funds have been transferred")
@ -277,15 +277,15 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
// Fee value specified in NeoFS network config with the key WithdrawFee.
func Withdraw(user interop.Hash160, amount int) {
if !runtime.CheckWitness(user) {
panic("withdraw: you should be the owner of the wallet")
panic("you should be the owner of the wallet")
}
if amount < 0 {
panic("withdraw: non positive amount number")
panic("non positive amount number")
}
if amount > maxBalanceAmount {
panic("withdraw: out of max amount limit")
panic("out of max amount limit")
}
ctx := storage.GetContext()
@ -301,7 +301,7 @@ func Withdraw(user interop.Hash160, amount int) {
transferred := gas.Transfer(user, processingAddr, fee, []byte{})
if !transferred {
panic("withdraw: failed to transfer withdraw fee, aborting")
panic("failed to transfer withdraw fee, aborting")
}
}
} else {
@ -309,7 +309,7 @@ func Withdraw(user interop.Hash160, amount int) {
transferred := gas.Transfer(user, processingAddr, fee, []byte{})
if !transferred {
panic("withdraw: failed to transfer withdraw fee, aborting")
panic("failed to transfer withdraw fee, aborting")
}
}
@ -338,12 +338,12 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
alphabet = getNodes(ctx, alphabetKey)
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("cheque: this method must be invoked by alphabet")
panic("this method must be invoked by alphabet")
}
} else {
multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("cheque: this method must be invoked by alphabet")
panic("this method must be invoked by alphabet")
}
}
@ -362,7 +362,7 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
transferred := gas.Transfer(from, user, amount, nil)
if !transferred {
panic("cheque: failed to transfer funds, aborting")
panic("failed to transfer funds, aborting")
}
runtime.Log("cheque: funds have been transferred")
@ -376,13 +376,13 @@ func Cheque(id []byte, user interop.Hash160, amount int, lockAcc []byte) {
// 33 byte long. User argument must be valid 20 byte script hash.
func Bind(user []byte, keys []interop.PublicKey) {
if !runtime.CheckWitness(user) {
panic("binding: you should be the owner of the wallet")
panic("you should be the owner of the wallet")
}
for i := 0; i < len(keys); i++ {
pubKey := keys[i]
if len(pubKey) != publicKeySize {
panic("binding: incorrect public key size")
panic("incorrect public key size")
}
}
@ -396,13 +396,13 @@ func Bind(user []byte, keys []interop.PublicKey) {
// 33 byte long. User argument must be valid 20 byte script hash.
func Unbind(user []byte, keys []interop.PublicKey) {
if !runtime.CheckWitness(user) {
panic("unbinding: you should be the owner of the wallet")
panic("you should be the owner of the wallet")
}
for i := 0; i < len(keys); i++ {
pubKey := keys[i]
if len(pubKey) != publicKeySize {
panic("unbinding: incorrect public key size")
panic("incorrect public key size")
}
}
@ -419,7 +419,7 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) {
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
if len(args) == 0 {
panic("alphabetUpdate: bad arguments")
panic("bad arguments")
}
var ( // for invocation collection without notary
@ -431,12 +431,12 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) {
alphabet = getNodes(ctx, alphabetKey)
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("alphabetUpdate: this method must be invoked by alphabet")
panic("this method must be invoked by alphabet")
}
} else {
multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("alphabetUpdate: this method must be invoked by alphabet")
panic("this method must be invoked by alphabet")
}
}
@ -445,7 +445,7 @@ func AlphabetUpdate(id []byte, args []interop.PublicKey) {
for i := 0; i < len(args); i++ {
pubKey := args[i]
if len(pubKey) != publicKeySize {
panic("alphabetUpdate: invalid public key in alphabet list")
panic("invalid public key in alphabet list")
}
newAlphabet = append(newAlphabet, common.IRNode{
@ -492,12 +492,12 @@ func SetConfig(id, key, val []byte) {
alphabet = getNodes(ctx, alphabetKey)
nodeKey = common.InnerRingInvoker(alphabet)
if len(key) == 0 {
panic("setConfig: this method must be invoked by alphabet")
panic("this method must be invoked by alphabet")
}
} else {
multiaddr := AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("setConfig: this method must be invoked by alphabet")
panic("this method must be invoked by alphabet")
}
}

View file

@ -51,7 +51,7 @@ func _deploy(data interface{}, isUpdate bool) {
addrContainer := args[2].(interop.Hash160)
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
panic("init: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
storage.Put(ctx, netmapContractKey, addrNetmap)
@ -87,7 +87,7 @@ func Update(script []byte, manifest []byte, data interface{}) {
func AddKey(owner []byte, keys []interop.PublicKey) {
// V2 format
if len(owner) != 25 {
panic("addKey: incorrect owner")
panic("incorrect owner")
}
ctx := storage.GetContext()
@ -103,7 +103,7 @@ func AddKey(owner []byte, keys []interop.PublicKey) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("addKey: invocation from non inner ring node")
panic("invocation from non inner ring node")
}
indirectCall = common.FromKnownContract(
@ -114,13 +114,13 @@ func AddKey(owner []byte, keys []interop.PublicKey) {
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("addKey: invocation from non inner ring node")
panic("invocation from non inner ring node")
}
}
for i := range keys {
if len(keys[i]) != 33 {
panic("addKey: incorrect public key")
panic("incorrect public key")
}
}
@ -153,7 +153,7 @@ func AddKey(owner []byte, keys []interop.PublicKey) {
func RemoveKey(owner []byte, keys []interop.PublicKey) {
// V2 format
if len(owner) != 25 {
panic("removeKey: incorrect owner")
panic("incorrect owner")
}
ctx := storage.GetContext()
@ -168,18 +168,18 @@ func RemoveKey(owner []byte, keys []interop.PublicKey) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("removeKey: invocation from non inner ring node")
panic("invocation from non inner ring node")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("removeKey: invocation from non inner ring node")
panic("invocation from non inner ring node")
}
}
for i := range keys {
if len(keys[i]) != 33 {
panic("addKey: incorrect public key")
panic("incorrect public key")
}
}
@ -208,7 +208,7 @@ func RemoveKey(owner []byte, keys []interop.PublicKey) {
func Key(owner []byte) [][]byte {
// V2 format
if len(owner) != 25 {
panic("key: incorrect owner")
panic("incorrect owner")
}
ctx := storage.GetReadOnlyContext()

View file

@ -71,7 +71,7 @@ func _deploy(data interface{}, isUpdate bool) {
ln := len(config)
if ln%2 != 0 {
panic("_deploy: bad configuration")
panic("bad configuration")
}
for i := 0; i < ln/2; i++ {
@ -86,7 +86,7 @@ func _deploy(data interface{}, isUpdate bool) {
}
if len(addrBalance) != 20 || len(addrContainer) != 20 {
panic("_deploy: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
// epoch number is a little endian int, it doesn't need to be serialized
@ -157,12 +157,12 @@ func UpdateInnerRing(keys []interop.PublicKey) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("updateInnerRing: this method must be invoked by alphabet nodes")
panic("this method must be invoked by alphabet nodes")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("updateInnerRing: this method must be invoked by alphabet nodes")
panic("this method must be invoked by alphabet nodes")
}
}
@ -219,7 +219,7 @@ func AddPeer(nodeInfo []byte) {
// V2 format
publicKey := nodeInfo[2:35] // offset:2, len:33
if !runtime.CheckWitness(publicKey) {
panic("addPeer: witness check failed")
panic("witness check failed")
}
runtime.Notify("AddPeer", nodeInfo)
return
@ -255,7 +255,7 @@ func AddPeer(nodeInfo []byte) {
// Method panics when invoked with unsupported states.
func UpdateState(state int, publicKey interop.PublicKey) {
if len(publicKey) != 33 {
panic("updateState: incorrect public key")
panic("incorrect public key")
}
ctx := storage.GetContext()
@ -271,7 +271,7 @@ func UpdateState(state int, publicKey interop.PublicKey) {
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
if !runtime.CheckWitness(publicKey) {
panic("updateState: witness check failed")
panic("witness check failed")
}
runtime.Notify("UpdateState", state, publicKey)
return
@ -289,10 +289,10 @@ func UpdateState(state int, publicKey interop.PublicKey) {
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(publicKey) {
panic("updateState: witness check failed")
panic("witness check failed")
}
if !runtime.CheckWitness(multiaddr) {
panic("updateState: alphabet witness check failed")
panic("alphabet witness check failed")
}
}
@ -301,7 +301,7 @@ func UpdateState(state int, publicKey interop.PublicKey) {
removeFromNetmap(ctx, publicKey)
runtime.Log("updateState: remove storage node from the network map")
default:
panic("updateState: unsupported state")
panic("unsupported state")
}
}
@ -327,12 +327,12 @@ func NewEpoch(epochNum int) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("newEpoch: this method must be invoked by inner ring nodes")
panic("this method must be invoked by inner ring nodes")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("newEpoch: this method must be invoked by inner ring nodes")
panic("this method must be invoked by inner ring nodes")
}
}
@ -417,7 +417,7 @@ func Snapshot(diff int) []storageNode {
case 1:
key = snapshot1Key
default:
panic("snapshot: incorrect diff")
panic("incorrect diff")
}
ctx := storage.GetReadOnlyContext()
@ -459,12 +459,12 @@ func SetConfig(id, key, val []byte) {
alphabet = common.AlphabetNodes()
nodeKey = common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
panic("setConfig: invoked by non inner ring node")
panic("invoked by non inner ring node")
}
} else {
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("setConfig: invoked by non inner ring node")
panic("invoked by non inner ring node")
}
}

View file

@ -22,7 +22,7 @@ const (
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
caller := runtime.GetCallingScriptHash()
if !common.BytesEqual(caller, []byte(gas.Hash)) {
panic("onNEP17Payment: processing contract accepts GAS only")
panic("processing contract accepts GAS only")
}
}
@ -37,7 +37,7 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext()
if len(addrNeoFS) != 20 {
panic("init: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
storage.Put(ctx, neofsContractKey, addrNeoFS)

View file

@ -19,7 +19,7 @@ const (
func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) {
caller := runtime.GetCallingScriptHash()
if !common.BytesEqual(caller, []byte(gas.Hash)) {
panic("onNEP17Payment: proxy contract accepts GAS only")
panic("proxy contract accepts GAS only")
}
}
@ -34,7 +34,7 @@ func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext()
if len(addrNetmap) != 20 {
panic("init: incorrect length of contract script hash")
panic("incorrect length of contract script hash")
}
storage.Put(ctx, netmapContractKey, addrNetmap)

View file

@ -86,16 +86,16 @@ func Update(script []byte, manifest []byte, data interface{}) {
func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
// V2 format
if len(id) != subnetIDSize {
panic("put: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
if len(ownerKey) != interop.PublicKeyCompressedLen {
panic("put: " + ErrInvalidOwner)
panic(ErrInvalidOwner)
}
ctx := storage.GetContext()
stKey := append([]byte{ownerPrefix}, id...)
if storage.Get(ctx, stKey) != nil {
panic("put: " + ErrAlreadyExists)
panic(ErrAlreadyExists)
}
notaryDisabled := storage.Get(ctx, notaryDisabledKey).(bool)
@ -104,7 +104,7 @@ func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
nodeKey := common.InnerRingInvoker(alphabet)
if len(nodeKey) == 0 {
if !runtime.CheckWitness(ownerKey) {
panic("put: witness check failed")
panic("witness check failed")
}
runtime.Notify("Put", id, ownerKey, info)
return
@ -120,12 +120,12 @@ func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
common.RemoveVotes(ctx, id)
} else {
if !runtime.CheckWitness(ownerKey) {
panic("put: " + errCheckWitnessFailed)
panic(errCheckWitnessFailed)
}
multiaddr := common.AlphabetAddress()
if !runtime.CheckWitness(multiaddr) {
panic("put: alphabet witness check failed")
panic("alphabet witness check failed")
}
}
@ -138,14 +138,14 @@ func Put(id []byte, ownerKey interop.PublicKey, info []byte) {
func Get(id []byte) []byte {
// V2 format
if len(id) != subnetIDSize {
panic("get: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
ctx := storage.GetReadOnlyContext()
key := append([]byte{infoPrefix}, id...)
raw := storage.Get(ctx, key)
if raw == nil {
panic("get: " + ErrNotExist)
panic(ErrNotExist)
}
return raw.([]byte)
}
@ -154,7 +154,7 @@ func Get(id []byte) []byte {
func Delete(id []byte) {
// V2 format
if len(id) != subnetIDSize {
panic("delete: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
ctx := storage.GetContext()
@ -166,7 +166,7 @@ func Delete(id []byte) {
owner := raw.([]byte)
if !runtime.CheckWitness(owner) {
panic("delete: " + errCheckWitnessFailed)
panic(errCheckWitnessFailed)
}
storage.Delete(ctx, key)
@ -193,11 +193,11 @@ func Delete(id []byte) {
func AddNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("addNodeAdmin: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
if len(adminKey) != interop.PublicKeyCompressedLen {
panic("addNodeAdmin: " + ErrInvalidAdmin)
panic(ErrInvalidAdmin)
}
ctx := storage.GetContext()
@ -206,12 +206,12 @@ func AddNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("addNodeAdmin: " + ErrNotExist)
panic(ErrNotExist)
}
owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) {
panic("addNodeAdmin: " + errCheckWitnessFailed)
panic(errCheckWitnessFailed)
}
stKey[0] = nodeAdminPrefix
@ -228,11 +228,11 @@ func AddNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
func RemoveNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("removeNodeAdmin: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
if len(adminKey) != interop.PublicKeyCompressedLen {
panic("removeNodeAdmin: " + ErrInvalidAdmin)
panic(ErrInvalidAdmin)
}
ctx := storage.GetContext()
@ -241,12 +241,12 @@ func RemoveNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("removeNodeAdmin: " + ErrNotExist)
panic(ErrNotExist)
}
owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) {
panic("removeNodeAdmin: " + errCheckWitnessFailed)
panic(errCheckWitnessFailed)
}
stKey[0] = nodeAdminPrefix
@ -264,11 +264,11 @@ func RemoveNodeAdmin(subnetID []byte, adminKey interop.PublicKey) {
func AddNode(subnetID []byte, node interop.PublicKey) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("addNode: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
if len(node) != interop.PublicKeyCompressedLen {
panic("addNode: " + ErrInvalidNode)
panic(ErrInvalidNode)
}
ctx := storage.GetContext()
@ -277,7 +277,7 @@ func AddNode(subnetID []byte, node interop.PublicKey) {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("addNode: " + ErrNotExist)
panic(ErrNotExist)
}
stKey[0] = nodeAdminPrefix
@ -285,7 +285,7 @@ func AddNode(subnetID []byte, node interop.PublicKey) {
owner := rawOwner.([]byte)
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
panic("addNode: " + ErrAccessDenied)
panic(ErrAccessDenied)
}
stKey[0] = nodePrefix
@ -303,11 +303,11 @@ func AddNode(subnetID []byte, node interop.PublicKey) {
func RemoveNode(subnetID []byte, node interop.PublicKey) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("removeNode: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
if len(node) != interop.PublicKeyCompressedLen {
panic("removeNode: " + ErrInvalidNode)
panic(ErrInvalidNode)
}
ctx := storage.GetContext()
@ -316,7 +316,7 @@ func RemoveNode(subnetID []byte, node interop.PublicKey) {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("removeNode: " + ErrNotExist)
panic(ErrNotExist)
}
stKey[0] = nodeAdminPrefix
@ -324,7 +324,7 @@ func RemoveNode(subnetID []byte, node interop.PublicKey) {
owner := rawOwner.([]byte)
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
panic("removeNode: " + ErrAccessDenied)
panic(ErrAccessDenied)
}
stKey[0] = nodePrefix
@ -343,11 +343,11 @@ func RemoveNode(subnetID []byte, node interop.PublicKey) {
func NodeAllowed(subnetID []byte, node interop.PublicKey) bool {
// V2 format
if len(subnetID) != subnetIDSize {
panic("nodeAllowed: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
if len(node) != interop.PublicKeyCompressedLen {
panic("nodeAllowed: " + ErrInvalidNode)
panic(ErrInvalidNode)
}
ctx := storage.GetReadOnlyContext()
@ -356,7 +356,7 @@ func NodeAllowed(subnetID []byte, node interop.PublicKey) bool {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("nodeAllowed: " + ErrNotExist)
panic(ErrNotExist)
}
stKey[0] = nodePrefix
@ -369,16 +369,16 @@ func NodeAllowed(subnetID []byte, node interop.PublicKey) bool {
func AddClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.PublicKey) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("addClientAdmin: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
// V2 format
if len(groupID) != groupIDSize {
panic("addClientAdmin: " + ErrInvalidGroupID)
panic(ErrInvalidGroupID)
}
if len(adminPublicKey) != interop.PublicKeyCompressedLen {
panic("addClientAdmin: " + ErrInvalidAdmin)
panic(ErrInvalidAdmin)
}
ctx := storage.GetContext()
@ -387,12 +387,12 @@ func AddClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.Publ
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("addClientAdmin: " + ErrNotExist)
panic(ErrNotExist)
}
owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) {
panic("addClientAdmin: " + errCheckWitnessFailed)
panic(errCheckWitnessFailed)
}
stKey[0] = clientAdminPrefix
@ -411,16 +411,16 @@ func AddClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.Publ
func RemoveClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.PublicKey) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("removeClientAdmin: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
// V2 format
if len(groupID) != groupIDSize {
panic("removeClientAdmin: " + ErrInvalidGroupID)
panic(ErrInvalidGroupID)
}
if len(adminPublicKey) != interop.PublicKeyCompressedLen {
panic("removeClientAdmin: " + ErrInvalidAdmin)
panic(ErrInvalidAdmin)
}
ctx := storage.GetContext()
@ -429,12 +429,12 @@ func RemoveClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.P
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("removeClientAdmin: " + ErrNotExist)
panic(ErrNotExist)
}
owner := rawOwner.([]byte)
if !runtime.CheckWitness(owner) {
panic("removeClientAdmin: " + errCheckWitnessFailed)
panic(errCheckWitnessFailed)
}
stKey[0] = clientAdminPrefix
@ -452,17 +452,17 @@ func RemoveClientAdmin(subnetID []byte, groupID []byte, adminPublicKey interop.P
func AddUser(subnetID []byte, groupID []byte, userID []byte) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("addUser: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
// V2 format
if len(userID) != userIDSize {
panic("addUser: " + ErrInvalidUser)
panic(ErrInvalidUser)
}
// V2 format
if len(groupID) != groupIDSize {
panic("addUser: " + ErrInvalidGroupID)
panic(ErrInvalidGroupID)
}
ctx := storage.GetContext()
@ -471,7 +471,7 @@ func AddUser(subnetID []byte, groupID []byte, userID []byte) {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("addUser: " + ErrNotExist)
panic(ErrNotExist)
}
stKey[0] = clientAdminPrefix
@ -480,7 +480,7 @@ func AddUser(subnetID []byte, groupID []byte, userID []byte) {
owner := rawOwner.([]byte)
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
panic("addUser: " + ErrAccessDenied)
panic(ErrAccessDenied)
}
stKey[0] = userPrefix
@ -497,17 +497,17 @@ func AddUser(subnetID []byte, groupID []byte, userID []byte) {
func RemoveUser(subnetID []byte, groupID []byte, userID []byte) {
// V2 format
if len(subnetID) != subnetIDSize {
panic("removeUser: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
// V2 format
if len(groupID) != groupIDSize {
panic("removeUser: " + ErrInvalidGroupID)
panic(ErrInvalidGroupID)
}
// V2 format
if len(userID) != userIDSize {
panic("addUser: " + ErrInvalidUser)
panic(ErrInvalidUser)
}
ctx := storage.GetContext()
@ -516,7 +516,7 @@ func RemoveUser(subnetID []byte, groupID []byte, userID []byte) {
rawOwner := storage.Get(ctx, stKey)
if rawOwner == nil {
panic("removeUser: " + ErrNotExist)
panic(ErrNotExist)
}
stKey[0] = clientAdminPrefix
@ -525,7 +525,7 @@ func RemoveUser(subnetID []byte, groupID []byte, userID []byte) {
owner := rawOwner.([]byte)
if !calledByOwnerOrAdmin(ctx, owner, stKey) {
panic("removeUser: " + ErrAccessDenied)
panic(ErrAccessDenied)
}
stKey[0] = userPrefix
@ -542,14 +542,14 @@ func RemoveUser(subnetID []byte, groupID []byte, userID []byte) {
func UserAllowed(subnetID []byte, user []byte) bool {
// V2 format
if len(subnetID) != subnetIDSize {
panic("userAllowed: " + ErrInvalidSubnetID)
panic(ErrInvalidSubnetID)
}
ctx := storage.GetContext()
stKey := append([]byte{ownerPrefix}, subnetID...)
if storage.Get(ctx, stKey) == nil {
panic("userAllowed: " + ErrNotExist)
panic(ErrNotExist)
}
stKey[0] = userPrefix

View file

@ -161,7 +161,7 @@ func TestContainerDelete(t *testing.T) {
c.Invoke(t, stackitem.Null{}, "put", cnt.value, cnt.sig, cnt.pub, cnt.token)
cAcc := c.WithSigners(acc)
cAcc.InvokeFail(t, "delete: alphabet witness check failed", "delete",
cAcc.InvokeFail(t, "alphabet witness check failed", "delete",
cnt.id[:], cnt.sig, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)

View file

@ -105,9 +105,9 @@ func TestUpdateState(t *testing.T) {
require.True(t, ok)
t.Run("missing witness", func(t *testing.T) {
cAcc.InvokeFail(t, "updateState: alphabet witness check failed",
cAcc.InvokeFail(t, "alphabet witness check failed",
"updateState", int64(2), pub)
e.InvokeFail(t, "updateState: witness check failed",
e.InvokeFail(t, "witness check failed",
"updateState", int64(2), pub)
})