mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2026-03-01 04:28:51 +00:00
Support modifying unsigned transaction by actor.Actor #1332
Labels
No labels
I1
I2
I3
I4
S1
S2
S3
S4
U0
U1
U2
U3
U3
U4
blocked
bug
bug
cli
compiler
config
config
consensus
dependencies
discussion
documentation
enhancement
epic
feature
go
good first issue
help wanted
neotest
network
oracle
performance
question
rpc
security
smartcontract
task
task
task
test
vm
wallet
windows
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neo-go#1332
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @cthulhu-rider on GitHub (Jul 15, 2024).
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:
as it turns out, this code leads to two problems:
1can be easily fixed by memcpy like here or with separated actor2, as more fundamental, can be fixed by manual tx formation similar to:nspcc-dev/neo-go@4ff2063539/pkg/rpcclient/rolemgmt/roles.go (L85). This requires having method name and having knowledge that https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.106.2/pkg/rpcclient/actor#Actor.CalculateNetworkFee should be done. While this is achievable, this is not very obvious and laconic as using actorsDescribe the solution you'd like
support tx modiier by https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.106.2/pkg/rpcclient/actor#Actor.MakeUnsignedCall. There is https://pkg.go.dev/github.com/nspcc-dev/neo-go@v0.106.2/pkg/rpcclient/actor#Options but:
seems like nothing stops methods creating unsigned txs to provide similar interceptor. For example, it can be called here
nspcc-dev/neo-go@4ff2063539/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/neo-go@v0.106.2/pkg/rpcclient/invoker#Invoker.Call, e.g. make reader:
@AnnaShaleva commented on GitHub (Jul 15, 2024):
We need to extend actor's documentation to describe this behaviour. It should be explicitly prohibited to modify the signers passed to Actor's constructor. But I don't think we need to copy signers inside Actor's constructor since it adds resources consumption overhead to the constructor, and signers slice modification is not a hot use-case among Actor usages.
After a conversation with Roman this statement should be adjusted: signed transactions should not be modified by users, and unsigned transactions may be modified if there's a need (but wrt the issue 1). But it seems to me that introducing custom CheckerModifier to
actor.MakeUnsignedCallandactor.MakeUnsignedRunslightly breaks actor's design because custom CheckerModifier supposed to be called only by those actor methods that sign transaction, i.e. by those methods that don't have other ways to customize transaction before signing. And if some further modification is needed, then user may useactor.MakeUnsignedUncheckedRunwith additional modification.So it seems to me that by design, it's supposed that it's a user responsibility to perform further modifications over unsigned transactions if it's needed. And existing API is sufficient for user's needs (consider using
actor.MakeUnsignedUncheckedRunwith further user'defined modification code) @roman-khimov, do we really need to introduce custom CheckerModifier foractor.MakeUnsigned*methods?@cthulhu-rider commented on GitHub (Jul 15, 2024):
me neither. I should have clarified that for this problem I meant memcpy by the caller (like this)
@cthulhu-rider commented on GitHub (Jul 15, 2024):
here is what can i do now:
well, it's not as huge as it could be tbh
i left one question in code ^. And im still requsting contract-specific helper (as in issue body)
is it possible to provide?
@AnnaShaleva commented on GitHub (Jul 16, 2024):
Random nonce is embedded into transaction constructor, I doubt we need to change it and it doesn't cost a lot anyway:
nspcc-dev/neo-go@c207b9b194/pkg/core/transaction/transaction.go (L96)May add an option to omit a call to
(a *Actor) CalculateValidUntilBlock()but then you can't use this actor for instant signing anymore since it will always use this option and omit VUB calculation which makes this actor kind of flawed. I'm not in favor of it.Which fields are you interested in besides these two? For NetworkFee it's supposed that you'll use the one calculated by Actor as a basis and add something to it if necessary.
Given these facts double-calculation doesn't seem to be a problem for me.
But don't we have contract-specific wrapper for native designation contract? Check it here:
nspcc-dev/neo-go@c207b9b194/pkg/rpcclient/rolemgmt/roles.go (L95-L100)@cthulhu-rider commented on GitHub (Jul 16, 2024):
not an option for my case, i have particular shared nonce
none
its not a problem if i code like this
it's used in the example code and conceptually not suitable for modifying a transaction. Im asking about a method that makes test invocation and returns
result.Invoke(wrapper over invoker)@roman-khimov commented on GitHub (Jul 16, 2024):
Unsigned transaction can be modified (well, with some limitations of course). What you really want is to change VUB and nonce and that's absolutely feasible with the current code. I don't really understand why you want to change the first signer, you can have an actor with a proper signer for this case easily.
@cthulhu-rider commented on GitHub (Jul 16, 2024):
i need actor to take my nonce and vub and not calc them himself. There is no way to do this
@AnnaShaleva commented on GitHub (Jul 16, 2024):
But you may just change the resulting unsigned transaction. Calculation overhead is insignificant.
@roman-khimov commented on GitHub (Jul 16, 2024):
Even modifiers we support for "signed" operations don't prevent actor from auto vub/nonce settings. They can override, but defaults are there anyway.
@cthulhu-rider commented on GitHub (Jul 16, 2024):
this is not visible to a user like me, but ok i believe u