forked from TrueCloudLab/frostfs-node
[#814] morph/event: Fix NotaryPreparator
parsing
Add checking for call flag in TX's script and do not pass it to parsers. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
1ed5323850
commit
b4059f652e
1 changed files with 11 additions and 3 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
"github.com/nspcc-dev/neo-go/pkg/network/payload"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
|
@ -28,7 +29,8 @@ var (
|
||||||
errIncorrectNotaryPlaceholder = errors.New("received main tx has incorrect Notary contract placeholder")
|
errIncorrectNotaryPlaceholder = errors.New("received main tx has incorrect Notary contract placeholder")
|
||||||
errIncorrectAttributesAmount = errors.New("received main tx has incorrect attributes amount")
|
errIncorrectAttributesAmount = errors.New("received main tx has incorrect attributes amount")
|
||||||
errIncorrectAttribute = errors.New("received main tx has incorrect attribute")
|
errIncorrectAttribute = errors.New("received main tx has incorrect attribute")
|
||||||
errUnexpectedOpcode = errors.New("received main tx has unexpected(not PUSHDATA) NeoVM opcodes")
|
errUnexpectedOpcode = errors.New("received main tx has unexpected(not PUSH) NeoVM opcodes")
|
||||||
|
errIncorrectCallFlag = errors.New("received main tx has unexpected call flag")
|
||||||
|
|
||||||
errIncorrectFBAttributesAmount = errors.New("received fallback tx has incorrect attributes amount")
|
errIncorrectFBAttributesAmount = errors.New("received fallback tx has incorrect attributes amount")
|
||||||
errIncorrectFBAttributes = errors.New("received fallback tx has incorrect attributes")
|
errIncorrectFBAttributes = errors.New("received fallback tx has incorrect attributes")
|
||||||
|
@ -183,7 +185,13 @@ func (p Preparator) Prepare(nr *payload.P2PNotaryRequest) (NotaryEvent, error) {
|
||||||
// retrieve contract's method
|
// retrieve contract's method
|
||||||
contractMethod := string(ops[opsLen-3].param)
|
contractMethod := string(ops[opsLen-3].param)
|
||||||
|
|
||||||
err = p.validateParameterOpcodes(ops[:opsLen-3])
|
// check if there is a call flag(must be in range [0:15))
|
||||||
|
callFlag := callflag.CallFlag(ops[opsLen-4].code - opcode.PUSH0)
|
||||||
|
if callFlag > callflag.All {
|
||||||
|
return nil, errIncorrectCallFlag
|
||||||
|
}
|
||||||
|
|
||||||
|
err = p.validateParameterOpcodes(ops[:opsLen-4])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -191,7 +199,7 @@ func (p Preparator) Prepare(nr *payload.P2PNotaryRequest) (NotaryEvent, error) {
|
||||||
return parsedNotaryEvent{
|
return parsedNotaryEvent{
|
||||||
hash: contractHash,
|
hash: contractHash,
|
||||||
notaryType: NotaryTypeFromString(contractMethod),
|
notaryType: NotaryTypeFromString(contractMethod),
|
||||||
params: ops[:opsLen-3],
|
params: ops[:opsLen-4],
|
||||||
raw: nr,
|
raw: nr,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue