-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: move transaction sender to signers #1244
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think every check used in DecodeBinary
should also be added to UnmarshalJSON
, because if there are any assumptions we expect for Transaction
to hold (e.g. non-empty Signers
array), we should make corresponding checks everytime we parse some external input.
pkg/core/transaction/transaction.go
Outdated
for j := i + 1; j < len(t.Cosigners); j++ { | ||
if t.Cosigners[i].Account.Equals(t.Cosigners[j].Account) { | ||
for j := i + 1; j < len(t.Signers); j++ { | ||
if t.Signers[i].Account.Equals(t.Signers[j].Account) { | ||
br.Err = errors.New("transaction cosigners should be unique") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cosigners
-> signers
?
c6afaa0
to
fc02e41
Compare
pkg/rpc/server/subscription.go
Outdated
@@ -58,12 +58,12 @@ func (f *feed) Matches(r *response.Notification) bool { | |||
case response.TransactionEventID: | |||
filt := f.filter.(request.TxFilter) | |||
tx := r.Payload[0].(*transaction.Transaction) | |||
senderOK := filt.Sender == nil || tx.Sender.Equals(*filt.Sender) | |||
senderOK := filt.Sender == nil || tx.Sender().Equals(*filt.Sender) | |||
cosignerOK := true | |||
if filt.Cosigner != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be filt.Signer
now with the respective range tx.Signers
semantics. Client and documentation are to be updated too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean that we should remove filt.Sender
or just rename filt.Cosigner
and allow to use the sender as filt.Signer
?
Don't we want to distinguish sender and cosigners in subscriptions? I thought that it might be useful, because we don't have scopes in subscriptions and there's no need to subscribe to sender in filt.Signer when you can just subscribe to filt.Sender.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename filt.Cosigner and allow to use the sender as filt.Signer
Like this one.
Don't we want to distinguish sender and cosigners in subscriptions?
Well, I might be wrong but I see two main use cases --- either you care about some address being a sender or you care about some address being one of signers (including being sender). Filtering for signer address which is not a sender seems a bit suspicious. Maybe there is a use case for it too, but I can't see any at the moment.
if err != nil { | ||
return nil, response.ErrInvalidParams | ||
} | ||
tx.Cosigners = cosigners | ||
tx.Signers = signers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have to initialize tx.Signers
with some stub sender anyway, otherwise some code working with senders can fail.
cli/smartcontract/smart_contract.go
Outdated
arguments). | ||
arguments and signers (sender is not included by default). If no method is given | ||
"" is passed to the script, if no arguments are given, an empty array is | ||
passed, if no signers are given no array is passed. All of the given |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And when there are some signers, the first one of them is going to be the sender, it should be specified here too.
Signers represent a set of Uint160 hashes with witness scopes and are used | ||
to verify hashes in System.Runtime.CheckWitness syscall. To specify signers | ||
use signer[:scope] syntax where | ||
* 'signer' is hex-encoded 160 bit (20 byte) LE value of signer's address, | ||
which could have '0x' prefix. | ||
* 'scope' is a comma-separated set of cosigner's scopes, which could be: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're missing FeeOnly
scope here.
121fe9c
to
72a41a1
Compare
72a41a1
to
6141a4f
Compare
@roman-khimov please, look #1265 first. |
Codecov Report
@@ Coverage Diff @@
## master #1244 +/- ##
==========================================
- Coverage 67.76% 67.62% -0.14%
==========================================
Files 215 215
Lines 18297 18328 +31
==========================================
- Hits 12399 12395 -4
- Misses 5240 5267 +27
- Partials 658 666 +8
Continue to review full report at Codecov.
|
pkg/core/native_policy_test.go
Outdated
@@ -5,6 +5,8 @@ import ( | |||
"sort" | |||
"testing" | |||
|
|||
"github.com/stretchr/testify/require" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless change.
pkg/core/transaction/transaction.go
Outdated
// in the transaction's signers list. | ||
func (t *Transaction) Sender() util.Uint160 { | ||
if len(t.Signers) == 0 { | ||
panic("transaction do not have signers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does not
or has no
Closes #1184 Ported changes from neo-project/neo#1752
We should perform the same checks during UnmarshalJSON.
6141a4f
to
ba08a9b
Compare
closes #1184