forked from TrueCloudLab/neoneo-go
rpcsrv: allow invalid contract signatures in calculatenetworkfee
See #2805, it allows to cover more cases like Notary contract that can use CalculateNetworkFee now instead of AddNetworkFee RPC client API.
This commit is contained in:
parent
98dfe66466
commit
f3d83c90b1
2 changed files with 10 additions and 9 deletions
|
@ -918,17 +918,21 @@ func (c *Client) SignAndPushP2PNotaryRequest(mainTx *transaction.Transaction, fa
|
|||
}
|
||||
fallbackNetFee += extraNetFee
|
||||
|
||||
dummyAccount := &wallet.Account{Contract: &wallet.Contract{Deployed: false}} // don't call `verify` for Notary contract witness, because it will fail
|
||||
err = c.AddNetworkFee(fallbackTx, fallbackNetFee, dummyAccount, acc)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to add network fee: %w", err)
|
||||
}
|
||||
fallbackTx.Scripts = []transaction.Witness{
|
||||
{
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...),
|
||||
VerificationScript: []byte{},
|
||||
},
|
||||
{
|
||||
InvocationScript: []byte{},
|
||||
VerificationScript: acc.GetVerificationScript(),
|
||||
},
|
||||
}
|
||||
fallbackTx.NetworkFee, err = c.CalculateNetworkFee(fallbackTx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to add network fee: %w", err)
|
||||
}
|
||||
fallbackTx.NetworkFee += fallbackNetFee
|
||||
m, err := c.GetNetwork()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to sign fallback tx: %w", err)
|
||||
|
|
|
@ -765,10 +765,7 @@ func (s *Server) calculateNetworkFee(reqParams params.Params) (interface{}, *neo
|
|||
for i, signer := range tx.Signers {
|
||||
w := tx.Scripts[i]
|
||||
if len(w.VerificationScript) == 0 { // then it still might be a contract-based verification
|
||||
gasConsumed, err := s.chain.VerifyWitness(signer.Account, tx, &tx.Scripts[i], int64(s.config.MaxGasInvoke))
|
||||
if err != nil {
|
||||
return 0, neorpc.NewRPCError("Invalid signature", fmt.Sprintf("contract verification for signer #%d failed: %s", i, err))
|
||||
}
|
||||
gasConsumed, _ := s.chain.VerifyWitness(signer.Account, tx, &tx.Scripts[i], int64(s.config.MaxGasInvoke))
|
||||
netFee += gasConsumed
|
||||
size += io.GetVarSize([]byte{}) + // verification script is empty (contract-based witness)
|
||||
io.GetVarSize(tx.Scripts[i].InvocationScript) // invocation script might not be empty (args for `verify`)
|
||||
|
|
Loading…
Reference in a new issue