network: forbid Notary contract to be a sender of main transaction
This prevents the possible attack on notary request sender when malicious partie is allowed to send notary request with main transaction being someone else's fallback. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
e7a83cbef9
commit
966111f4a8
2 changed files with 14 additions and 1 deletions
|
@ -1036,7 +1036,10 @@ func TestVerifyNotaryRequest(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
newNotaryRequest := func() *payload.P2PNotaryRequest {
|
||||
return &payload.P2PNotaryRequest{
|
||||
MainTransaction: &transaction.Transaction{Script: []byte{0, 1, 2}},
|
||||
MainTransaction: &transaction.Transaction{
|
||||
Script: []byte{0, 1, 2},
|
||||
Signers: []transaction.Signer{{Account: random.Uint160()}},
|
||||
},
|
||||
FallbackTransaction: &transaction.Transaction{
|
||||
ValidUntilBlock: 321,
|
||||
Signers: []transaction.Signer{{Account: bc.NotaryContractScriptHash}, {Account: random.Uint160()}},
|
||||
|
@ -1057,6 +1060,13 @@ func TestVerifyNotaryRequest(t *testing.T) {
|
|||
require.Error(t, s.verifyNotaryRequest(nil, r))
|
||||
})
|
||||
|
||||
t.Run("bad main sender", func(t *testing.T) {
|
||||
bc.VerifyWitnessF = func() (int64, error) { return 0, nil }
|
||||
r := newNotaryRequest()
|
||||
r.MainTransaction.Signers[0] = transaction.Signer{Account: bc.NotaryContractScriptHash}
|
||||
require.Error(t, s.verifyNotaryRequest(nil, r))
|
||||
})
|
||||
|
||||
t.Run("expired deposit", func(t *testing.T) {
|
||||
r := newNotaryRequest()
|
||||
bc.NotaryDepositExpiration = r.FallbackTransaction.ValidUntilBlock
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue