Roman Khimov
3c722a9498
keys: clean temporary data during key imports
...
Don't leak anything this way.
2022-09-02 14:44:32 +03:00
Roman Khimov
74bf4a8e3f
slice: add Clean microfunction
...
To be used for various cleaning purposes, one line is better than three lines.
2022-09-02 14:44:32 +03:00
Roman Khimov
58dc8d0c9b
*: always close the wallet after use
...
Fix #2631 .
2022-09-02 14:44:32 +03:00
Roman Khimov
ee5f8b6c21
consensus: update dbft, drop marshaling from private key
...
dbft doesn not need this and we must not leak the key in any way.
2022-09-02 14:44:18 +03:00
Roman Khimov
cad0d7f00d
wallet: add some warnings to Decrypt and PrivateKey docs
2022-09-02 14:44:18 +03:00
Roman Khimov
e164625a7f
wallet: provide (*Account).SignHashable API
...
Make PrivateKey() less used and less useful.
2022-09-02 14:44:01 +03:00
Roman Khimov
e569edc841
wallet: add ScriptHash() to Account
...
It allows to simplify a lot of code and avoid getting a PrivateKey in some
cases.
2022-09-02 14:43:34 +03:00
Roman Khimov
fd8da6fdb9
*: do not get private key from Account to check if it CanSign()
...
We have this API now to performs checks.
2022-09-02 14:43:34 +03:00
Roman Khimov
8d33206bb8
*: don't get private key from account if just public one is needed
...
Add PublicKey() API to the Account and use it as appropriate, avoid creating
additional references to the private key.
2022-09-02 14:43:28 +03:00
Roman Khimov
62be6f959c
keys/wallet: add Destroy/Close/Close
...
PrivateKey can be destroyed and Account/Wallet can be closed (destroying keys
in the process).
2022-09-01 17:07:00 +03:00
Roman Khimov
a30e73a0d7
wallet: drop publicKey from Account
...
It's not very useful and it's only available when we have a private key
anyway.
2022-09-01 17:07:00 +03:00
Roman Khimov
53edbd569f
wallet: don't allow to ConvertMultisig a locked account
...
This stretched the definition of Locked somewhat, but still makes sense to
me, locked accounts better not be touched.
2022-09-01 17:07:00 +03:00
Roman Khimov
0090577446
wallet: don't permanently store wif in the Account
...
It's useless and it's just another copy of the key. If really needed, it can
be derived from the key.
2022-09-01 17:07:00 +03:00
Roman Khimov
411ebdf51e
cli: add complete support for offline signing, fix #2662
...
See documentation update for an example. Some code is made generic as well,
GetCompleteTransaction can now be used directly on ParameterContext.
2022-09-01 15:30:34 +03:00
Roman Khimov
773bcc3a59
context: make error messages a bit less cryptic
...
Refs. #2664 .
2022-09-01 15:30:33 +03:00
Roman Khimov
58707c2b1e
context: handle the case when we have more sigs than needed
...
We can technically have more signatures in the file than we need and it's OK,
this case should be handled.
2022-09-01 15:30:33 +03:00
Roman Khimov
314cd3341b
Merge pull request #2667 from nspcc-dev/rpc-nep-token-info
...
Drop NEPXXTokenInfo from the RPC client
2022-08-30 14:41:30 +03:00
Roman Khimov
673c8954cc
Merge pull request #2665 from nspcc-dev/notary-rpcclient
...
Notary RPC client
2022-08-30 12:43:13 +03:00
Roman Khimov
07f3023e84
rpcclient: add notary.Actor for seamless notary experience
2022-08-30 11:47:56 +03:00
Roman Khimov
ed6ed61712
neptoken: add Info to replace old NEPXXTokenInfo methods
...
I'm still not sure it's good to have this exposed from neptoken at all, but
let's try it this way.
2022-08-29 22:52:27 +03:00
Roman Khimov
ac5c609063
core: add a bit more data into NVB errors
...
It's not always obvious what they mean and the NVB value is.
2022-08-29 15:08:37 +03:00
Roman Khimov
a95984febf
actor: allow providing default attributes/hooks to be used
...
Which expands Actor use cases greatly.
2022-08-29 15:08:37 +03:00
Roman Khimov
a3f32bf306
neptoken: move BalanceOf implementation to Base from nep11/nep17
...
It's the same, even though standards define parameter name in a bit different
way.
2022-08-26 21:52:19 +03:00
Roman Khimov
0d9158bd79
rpcclient: add enough of NNS into nns to deprecate NNS methods
2022-08-26 19:45:37 +03:00
Roman Khimov
fe50879bb7
wallet: add (*Account).CanSign API
2022-08-26 18:21:58 +03:00
Roman Khimov
8b132cba0c
wallet: respect user-locked accounts, don't sign with them
...
NEP-6 has a notion of locked acccounts and SignTx must respect this user's
choice. For some reason this setting was inappropriately used by our RPC
client tests (probably a different kind of lock was meant).
2022-08-26 18:21:58 +03:00
Roman Khimov
54c5fd61df
wallet: make SignTx more precise and accurate
...
* each account must have an appropriate signer, if there is no signer for
this account in the tx it's an error
* we can only safely append to Scripts when account belongs to the next
signer (we don't have appropriate verification scripts for other signers)
* when contract has one parameter, the signature shouldn't be appended to
other data
I think these rules allow to handle more cases and do that safer. We have more
complex scenarios though, like non-signature parameters or mixed-parameter
invocation scripts, but that's out of scope for now.
2022-08-26 18:21:58 +03:00
Roman Khimov
7a930a8e11
wallet: don't fail in SignTx when no contract provided
...
Unfortunately valid NEP-6 can have no contract inside of account, so this
should be accounted for.
2022-08-26 18:21:58 +03:00
Roman Khimov
2f8896f7a1
rpcclient: add notary subpackage with the notary contract wrapper
2022-08-26 18:21:58 +03:00
Roman Khimov
bf06b32278
Merge pull request #2658 from nspcc-dev/calculate-network-fee-fixes
...
calculatenetworkfee improvements
2022-08-24 10:24:53 +03:00
Roman Khimov
03cc9b2762
rpcsrv: execute all witnesses for calculatenetworkfee
...
Try to get as much data as possible, fix #2654 .
2022-08-23 15:34:18 +03:00
Roman Khimov
a2c4a7f611
rpcsrv: adjust for paid attritbutes in calculatenetworkfee
...
calculatenetworkfee MUST calculate complete proper network fee, if we have
some extensions enabled and some attributes should be paid for that they're a
part of the equation too.
2022-08-23 15:34:18 +03:00
Evgeniy Stratonikov
9712be78fd
vm: optimize refcounter
...
```
name old time/op new time/op delta
RefCounter_Add-8 9.47ns ± 4% 2.75ns ± 1% -70.92% (p=0.000 n=10+9)
RefCounter_AddRemove-8 88.9ns ±20% 5.5ns ± 4% -93.78% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
RefCounter_Add-8 0.00B 0.00B ~ (all equal)
RefCounter_AddRemove-8 48.0B ± 0% 0.0B -100.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
RefCounter_Add-8 0.00 0.00 ~ (all equal)
RefCounter_AddRemove-8 2.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10)
```
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-08-23 13:18:06 +03:00
Evgeniy Stratonikov
59fbc689e4
vm/bench: extend refcounter benchmarks
...
Adding an array multiple times leads to the fast update via `IncRC`.
This hides the allocation that is there on the first addition. In this
commit add another benchmark which measures Add/Remove together, to
ensure that `switch` in `refCounter.Add` is entered. Benchmark results
are meaningful, because `Add`/`Remove` have almost identical implementation.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-08-23 13:08:42 +03:00
Anna Shaleva
fb8a3973f1
smartcontract: remove empty method parameter handling
...
It's prohibited by the manifest validness checker, thus should not be
supported by bindings generator.
2022-08-22 15:01:38 +03:00
Anna Shaleva
15732580eb
smartcontract: improve manifest validness errors
...
It should be clear from error what's wrong with ABI
(specify bad method/event/parameter identifier).
2022-08-22 14:59:28 +03:00
Roman Khimov
f3d83c90b1
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.
2022-08-22 14:55:45 +03:00
Roman Khimov
98dfe66466
rpcsrv: simplify calculatenetworkfee
...
We're dealing with a transaction here and it can't be decoded successfully
unless it has an appropriate number of witness scripts (matching the number of
signers) with appropriate hashes (matching signers). So this iterations make
no sense at all, we know exactly where to look for the
verification/invocation scripts.
2022-08-22 14:47:30 +03:00
Roman Khimov
9916832e2e
core: set Tx for interop.Context when verifying witnesses
...
Notary contract uses it in the verification context and it's not harmful to
have it always be there when it's there.
2022-08-22 13:38:43 +03:00
Roman Khimov
606597b9a1
Merge pull request #2652 from nspcc-dev/shutdown-fixes
...
Shutdown sequence fixes
2022-08-22 10:22:54 +03:00
Roman Khimov
779a5c070f
network: wait for exit in discoverer
...
And synchronize other threads with channels instead of mutexes. Overall this
scheme is more reliable.
2022-08-19 22:23:47 +03:00
Roman Khimov
eeeb0f6f0e
core: accept two-side channels for sub/unsub, read on unsub
...
Blockchain's notificationDispatcher sends events to channels and these
channels must be read from. Unfortunately, regular service shutdown procedure
does unsubscription first (outside of the read loop) and only then drains the
channel. While it waits for unsubscription request to be accepted
notificationDispatcher can try pushing more data into the same channel which
will lead to a deadlock. Reading in the same method solves this, any number of
events can be pushed until unsub channel accepts the data.
2022-08-19 22:08:40 +03:00
Roman Khimov
dea75a4211
network: wait for the relayer thread to finish on shutdown
...
Unsubscribe and drain first, then return from the Shutdown method. It's
important wrt to subsequent chain shutdown process (normally it's closed right
after the network server).
2022-08-19 22:08:40 +03:00
Roman Khimov
3402b870c8
fixedn: add a test for empty string
...
Ensure it fails.
2022-08-19 21:52:43 +03:00
Roman Khimov
b2524a3ba9
actor: add Sender helper method
2022-08-19 21:52:43 +03:00
Roman Khimov
c034f94a94
nep17: provide out of the box multitransfer capability
...
It can't replicate the old multitransfer methods in ability to transfer
multiple tokens, but it at the same time can do multiple senders.
2022-08-19 21:52:43 +03:00
Roman Khimov
155089f4e5
network: drop cleanup from TestVerifyNotaryRequest
...
It never runs the server, so 746644a4eb
was a
bit wrong with this.
2022-08-19 20:54:06 +03:00
Roman Khimov
194933a5cc
rpcclient: provide nep11 package for NEP-11 tokens
...
Unfortunately Go doesn't allow to easily reuse readers in full packages, still
we can have this wrapper with a little overhead (the alternative is to move
specific methods into types of their own, but I'm not sure how it's going to
be accepted user-side).
2022-08-19 10:37:22 +03:00
Roman Khimov
d0702c2cf9
unwrap: provide ArrayOfUint160
...
It's a popular type as well.
2022-08-19 10:36:44 +03:00
Roman Khimov
8cd4948e06
Merge pull request #2650 from nspcc-dev/neo-wrapper
...
NEO RPC wrapper
2022-08-19 10:34:41 +03:00