Commit graph

175 commits

Author SHA1 Message Date
Roman Khimov
892c9785ad transaction: don't allocate new buffer to calculate hash
We can write directly to hash.Hash.

name               old time/op    new time/op    delta
DecodeBinary-8       2.89µs ± 3%    2.82µs ± 5%     ~     (p=0.052 n=10+10)
DecodeJSON-8         13.0µs ± 1%    12.8µs ± 1%   -1.54%  (p=0.002 n=10+8)
DecodeFromBytes-8    2.37µs ± 1%    2.25µs ± 5%   -5.25%  (p=0.000 n=9+10)

name               old alloc/op   new alloc/op   delta
DecodeBinary-8       1.75kB ± 0%    1.53kB ± 0%  -12.79%  (p=0.000 n=10+10)
DecodeJSON-8         3.49kB ± 0%    3.26kB ± 0%   -6.42%  (p=0.000 n=10+10)
DecodeFromBytes-8    1.37kB ± 0%    1.14kB ± 0%  -16.37%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
DecodeBinary-8         26.0 ± 0%      23.0 ± 0%  -11.54%  (p=0.000 n=10+10)
DecodeJSON-8           58.0 ± 0%      55.0 ± 0%   -5.17%  (p=0.000 n=10+10)
DecodeFromBytes-8      18.0 ± 0%      15.0 ± 0%  -16.67%  (p=0.000 n=10+10)
2021-08-04 23:43:20 +03:00
Roman Khimov
6d10cdc2f6 transaction: avoid ReadArray()
Reflection adds some real cost to it:

name               old time/op    new time/op    delta
DecodeBinary-8       3.14µs ± 5%    2.89µs ± 3%   -8.19%  (p=0.000 n=10+10)
DecodeJSON-8         12.6µs ± 3%    13.0µs ± 1%   +3.77%  (p=0.000 n=10+10)
DecodeFromBytes-8    2.73µs ± 2%    2.37µs ± 1%  -13.12%  (p=0.000 n=9+9)

name               old alloc/op   new alloc/op   delta
DecodeBinary-8       1.82kB ± 0%    1.75kB ± 0%   -3.95%  (p=0.000 n=10+10)
DecodeJSON-8         3.49kB ± 0%    3.49kB ± 0%     ~     (all equal)
DecodeFromBytes-8    1.44kB ± 0%    1.37kB ± 0%   -5.00%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
DecodeBinary-8         29.0 ± 0%      26.0 ± 0%  -10.34%  (p=0.000 n=10+10)
DecodeJSON-8           58.0 ± 0%      58.0 ± 0%     ~     (all equal)
DecodeFromBytes-8      21.0 ± 0%      18.0 ± 0%  -14.29%  (p=0.000 n=10+10)
2021-08-04 23:34:57 +03:00
Roman Khimov
d2732a71d8 transaction: don't overwrite error and witnesses length check
ReadArray() can return some error and we shouldn't overwrite it. At the same
time limiting ReadArray() to the number of Signers can make it return wrong
error if the number of witnesses actually is bigger than the number of
signers, so use MaxAttributes.
2021-08-04 23:17:50 +03:00
Roman Khimov
d487b54612 transaction: don't recalculate size when decoding from buffer
name               old time/op    new time/op    delta
DecodeBinary-8       3.17µs ± 6%    3.14µs ± 5%     ~     (p=0.579 n=10+10)
DecodeJSON-8         12.8µs ± 3%    12.6µs ± 3%     ~     (p=0.105 n=10+10)
DecodeFromBytes-8    3.45µs ± 4%    2.73µs ± 2%  -20.70%  (p=0.000 n=10+9)

name               old alloc/op   new alloc/op   delta
DecodeBinary-8       1.82kB ± 0%    1.82kB ± 0%     ~     (all equal)
DecodeJSON-8         3.49kB ± 0%    3.49kB ± 0%     ~     (all equal)
DecodeFromBytes-8    1.82kB ± 0%    1.44kB ± 0%  -21.05%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
DecodeBinary-8         29.0 ± 0%      29.0 ± 0%     ~     (all equal)
DecodeJSON-8           58.0 ± 0%      58.0 ± 0%     ~     (all equal)
DecodeFromBytes-8      29.0 ± 0%      21.0 ± 0%  -27.59%  (p=0.000 n=10+10)
2021-08-04 23:13:58 +03:00
Evgeniy Stratonikov
8e9302f40b oracle: check response Content-Type
If not specified everything is allowed.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-12 13:13:48 +03:00
Evgeniy Stratonikov
33e1e61343 config: make MaxValidUntilBlockIncrement configurable 2021-05-17 13:43:03 +03:00
Roman Khimov
9d2712573f *: enable godot linter and fix all its warnings
It's important for NeoGo to have clean documentation. No functional changes.
2021-05-12 23:17:03 +03:00
Roman Khimov
bba22cb736 transaction: marshal oracle response codes as strings
C# node does it this way.
2021-04-06 22:50:42 +03:00
Roman Khimov
d314f82db3 transaction: drop Network from Transaction
We only need it when signing/verifying.
2021-03-26 13:45:18 +03:00
Roman Khimov
b56e028733 *: add more package-specific documentation
For the most important packages at least.
2021-03-19 16:18:45 +03:00
Anna Shaleva
e5cdecfa9f core: fix transaction hashes 2021-03-18 17:57:54 +03:00
Roman Khimov
4462a6a6b7 change block/tx/extensible signing process, fix #1741
Sign [magic, hash], see neo-project/neo#2314.
2021-03-12 11:27:50 +03:00
Anna Shaleva
a6d4a266b9 core: check transaction's scripts length during decoding 2021-02-17 13:19:23 +03:00
Evgeniy Stratonikov
b0fbd897ad Revert "rpc: marshal fees and GAS as Fixed8 decimal"
This reverts commit a79b12b4d4.
2021-02-09 11:16:52 +03:00
Anna Shaleva
840104461b config: update testnet netmode to preview5 magic 2021-02-05 18:57:54 +03:00
Roman Khimov
120ae4841f transactions: fix JSON unmarshalling of fees
Fixed8 is already marshalled as a string and stripping quotes from it just
leads to interpreting it as a float with all regular float problems (like
test transaction failing with `txid doesn't match transaction hash`).
2021-01-22 18:22:09 +03:00
Anna Shaleva
e0d76d873e core: add ProtocolNotSupported oracle response code 2020-12-18 13:01:45 +03:00
Evgenii Stratonikov
e4c3339c91 util: move Fixed8 to encoding/fixedn package 2020-12-09 11:18:18 +03:00
Evgenii Stratonikov
a79b12b4d4 rpc: marshal fees and GAS as Fixed8 decimal 2020-11-26 15:04:30 +03:00
Anna Shaleva
52cf328296 core: add NotaryAssisted transaction attribute 2020-11-25 18:37:29 +03:00
Anna Shaleva
31aa66a4a4 core: check the length of NotValidBefore attr while decoding
DecodeBinary throws panic otherwise.
2020-11-25 18:37:29 +03:00
Anna Shaleva
8548786444 core: do not rewrite binreader error for bad Conflicts attr
We should keep the original BinReader error untouched in case if
it is exists.
2020-11-25 18:37:24 +03:00
Evgenii Stratonikov
7d91a3a89e pkg: move internal/ package to the root directory
This way we can use it in scripts and cli.
2020-11-24 16:39:56 +03:00
Roman Khimov
a1ce3d2db2 transaction: add new oracle response codes
Follow neo-project/neo#2037.
2020-11-09 16:54:09 +03:00
Roman Khimov
b233158c9f transaction: lower MaxValidUntilBlockIncrement
Follow neo-project/neo#2042.
2020-11-06 13:41:46 +03:00
Roman Khimov
39a38dc5f5 transaction: raise max oracle response size
Follow neo-project/neo#1984.
2020-11-06 13:41:46 +03:00
Anna Shaleva
ec63d5c456 core: add conflicts attribute
Close #1491
2020-10-29 10:57:31 +03:00
Anna Shaleva
f259a614de core: add transaction.HasSigner method 2020-10-23 16:32:26 +03:00
Anna Shaleva
7947e99a1e core: add transaction.GetAttributes 2020-10-23 11:05:03 +03:00
Anna Shaleva
a6579a05ac core: refactor transaction.Attribute unmarshalling 2020-10-23 11:05:03 +03:00
Anna Shaleva
09b8b8de73 core: reserve attributes range for experimantal purposes 2020-10-23 11:04:59 +03:00
Anna Shaleva
368ff820b3 core: add NotValidBefore transaction attribute
Close #1490
2020-10-23 11:02:46 +03:00
Roman Khimov
705941a800 transaction: add script length limit
As it is implemented in C# code.
2020-10-07 18:23:10 +03:00
Roman Khimov
d029f5c0d8 transaction: fix witness script length limits
See neo-project/neo#1958.
2020-10-07 18:05:23 +03:00
Evgenii Stratonikov
fa09b9af7b transaction: rename FeeOnly to None
Follow missed change from neo-project/neo#1816 .
`None` may be used for any signer. Currently it is used
for sender to only pay fees, or to sign tx attributes.
2020-10-01 15:28:19 +03:00
Evgenii Stratonikov
1625689316 transaction: implement OracleResponse attribute 2020-09-16 14:50:31 +03:00
Evgenii Stratonikov
06b29e409c transaction: remove Attribute.Data field 2020-09-16 13:39:53 +03:00
Roman Khimov
19c69618c5 transaction: cache tx size, don't serialize it over and over again 2020-09-11 18:55:19 +03:00
Roman Khimov
53c014a0bb crypto/consensus: sign hashes and cache them for consensus payloads
Avoid serializing payload again and again for various purposes. To sign it, we
only need a hash.

Some 2.4% gain in TPS could be achieved with this.
2020-09-09 20:46:31 +03:00
Evgenii Stratonikov
7ee1ddff61 transaction: add tests for (*Transaction).isValid() 2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
2661ebd295 transaction: add HighPriority attribute
HighPriority attributes specifies that transaction was
signed by a committee.
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
04bff62d65 transaction: update binary test data 2020-08-18 15:09:30 +03:00
Roman Khimov
ec2a2f3fb9 transaction: fix ineffassign GoReportCard issue
s is not used purposefuly.
2020-08-14 12:08:16 +03:00
Roman Khimov
acc2265169 transaction: attribute type is now type, not usage 2020-08-11 21:10:50 +03:00
Roman Khimov
fb70c82157 transaction: there are no valid attributes defined for preview3 2020-08-11 21:10:12 +03:00
Anna Shaleva
ba08a9b6ad core: move all transaction.Decode checks to separate method
We should perform the same checks during UnmarshalJSON.
2020-08-04 17:34:06 +03:00
Anna Shaleva
90825efa16 core: move transaction's sender to cosigners
Closes #1184

Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Anna Shaleva
8697582b23 core: add FeeOnly witness scope 2020-08-04 15:08:59 +03:00
Anna Shaleva
75f1c2d6f2 core: add scopes check to cosigners in DecodeBinary 2020-08-04 15:08:59 +03:00
Roman Khimov
f46ed798f0
Merge pull request #1169 from nspcc-dev/neo3/rpc/fields_names_adjustment
rpc: adjust RPC calls JSON fields
2020-07-15 18:24:54 +03:00