neo-go icon indicating copy to clipboard operation
neo-go copied to clipboard

Support modifying unsigned transaction by `actor.Actor`

Open cthulhu-rider opened this issue 7 months ago • 10 comments

Is your feature request related to a problem? Please describe.

NeoFS chain deployment procedure uses actor to make unsigned transaction designating Notary role. The essential goal is to get transaction which has particular data:

  • first signer
  • nonce
  • ValidUntilBlock

as it turns out, this code leads to two problems:

  1. (coding) actor's underlying slice of signer is mutated
  2. (conceptual) txs prepared by actors should not be modified ((c) @AnnaShaleva)

1 can be easily fixed by memcpy like here or with separated actor

2, as more fundamental, can be fixed by manual tx formation similar to: https://github.com/nspcc-dev/neo-go/blob/4ff2063539430d18f499fea32c347f6396fadf38/pkg/rpcclient/rolemgmt/roles.go#L85. This requires having method name and having knowledge that https://pkg.go.dev/github.com/nspcc-dev/[email protected]/pkg/rpcclient/actor#Actor.CalculateNetworkFee should be done. While this is achievable, this is not very obvious and laconic as using actors

Describe the solution you'd like

support tx modiier by https://pkg.go.dev/github.com/nspcc-dev/[email protected]/pkg/rpcclient/actor#Actor.MakeUnsignedCall. There is https://pkg.go.dev/github.com/nspcc-dev/[email protected]/pkg/rpcclient/actor#Options but:

MakeUnsigned* methods do not run it.

seems like nothing stops methods creating unsigned txs to provide similar interceptor. For example, it can be called here https://github.com/nspcc-dev/neo-go/blob/4ff2063539430d18f499fea32c347f6396fadf38/pkg/rpcclient/actor/maker.go#L185 note that in this case method should not do useless work: if caller set its own ValidUntilBlock (with full responsibility), then there is no need to calculate it

Describe alternatives you've considered

more manual tx creation based on https://pkg.go.dev/github.com/nspcc-dev/[email protected]/pkg/rpcclient/invoker#Invoker.Call, e.g. make reader:

func (c *ContractReader) CallDesignateAsRole(role noderoles.Role, index uint32) (*result.Invoke, error)

cthulhu-rider avatar Jul 15 '24 08:07 cthulhu-rider