Ekaterina Pavlova
df2a56908b
core: move transaction Attribute value to a designated interface
...
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-04-26 21:40:23 +05:30
Anna Shaleva
82cb2e718d
native: introduce attribute pricing
...
Port the https://github.com/neo-project/neo/pull/2916 .
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-21 13:42:56 +03:00
Anna Shaleva
90b01bcea6
core: move SignersToStackItem to transaction package
...
It will be reused from interops.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-20 14:46:27 +03:00
Anna Shaleva
1815bc8a32
*: update Stringers wrt fresh Stringer version
...
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-19 11:33:07 +03:00
Anna Shaleva
3aa858a69f
*: drop go 1.18 support in doc and build targets
...
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-10-12 17:59:42 +03:00
Anna Shaleva
0d17273476
core: fix formatted error on transaction verification
...
Witnesses are not yet created by the moment we return this error,
thus, it was always 0 as an actual number of witnesses in
ErrInvalidWitnessNum.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-21 13:50:20 +03:00
Anna Shaleva
8253025c90
core: do not use formatted error if not needed
...
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-20 10:33:50 +03:00
Anna Shaleva
9f69522ff5
neorpc: adjust SignerWithWitness scopes parsing
...
Ensure that Scopes can be properly parsed not only from the string
representation, but also from a single byte. transaction.Signer
is not affected (checked against the C# implementation), only
RPC-related signer scopes are allowed to be unmarshalled from byte.
Close #3059 .
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-07-20 10:33:48 +03:00
Roman Khimov
433275265f
*: use require.ErrorIs instead of require.True(t, error.Is())
...
This is just a much better way to do the same thing. Inspired by
nspcc-dev/neofs-sdk-go#407 .
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-05-04 17:03:47 +03:00
Anna Shaleva
6b21ad9922
*: replace interface{}
with any
keyword
...
Everywhere including examples, external interop APIs, bindings generators
code and in other valuable places. A couple of `interface{}` usages are
intentionally left in the CHANGELOG.md, documentation and tests.
2023-04-04 13:22:42 +03:00
Anna Shaleva
82221b0ca7
*: fix Neo and NeoGo misuses
2022-12-07 17:29:09 +03:00
Anna Shaleva
78cd2b4566
core: add example to VUB comment
2022-10-06 10:32:18 +03:00
Anna Shaleva
bb751535d3
*: bump minimum supported go version
...
Close #2497 .
2022-08-08 13:59:32 +03:00
Roman Khimov
99e2681d3a
interop/vm: use more robust CalledByEntry check
...
Directly check contexts.
2022-08-05 14:35:00 +03:00
Roman Khimov
7b88aedb27
transaction: add fuzz-test, refs. #2374
2022-06-09 13:43:22 +03:00
Roman Khimov
d70caf1da1
core: move GetScriptContainer to runtime
...
It also brings ToStackItem to Block and Transaction, previously this was
avoided to separate block and transaction packages from VM. But turns out
`transaction` depends on `stackitem` already, so this makes little sense (but
can be shuffled in another way if needed).
Context.Container is still a hash.Hashable because we have a number of
occasions (header or MPT root verification) where there is no ToStackItem
implementation possible. Maybe they can go with `nil` Container, but I don't
want to have this risk for now.
2022-06-08 18:12:41 +03:00
Anna Shaleva
3bec6657f5
core: adjust notary-related attributes encoding
2022-06-01 15:09:06 +03:00
Anna Shaleva
1b80215415
core: adjust types of NVB, Conflicts and NotaryAssisted attributes
2022-06-01 15:09:06 +03:00
Anna Shaleva
c5c5e4c208
core: do not panic if transaction with empty script is being serialized
...
See https://github.com/nspcc-dev/neo-go/pull/2485#discussion_r872695786 .
Allows to avoid panic:
```
(18:28:29)[sergio@transient:morph-control-load]% downloads/neofs-adm morph -c configuration/config.yaml init --contracts downloads/neofs-contract-v0.15.1
Stage 1: transfer GAS to alphabet nodes.
Waiting for transactions to persist...
Stage 2: set notary and alphabet nodes in designate contract.
Stage 2: already performed.
Stage 3: deploy NNS contract.
NNS contract is already deployed.
Stage 4: deploy NeoFS contracts.
Alphabet contract #0 is already deployed.
Alphabet contract #1 is already deployed.
Alphabet contract #2 is already deployed.
Alphabet contract #3 is already deployed.
audit contract is already deployed.
balance contract is already deployed.
container contract is already deployed.
neofsid contract is already deployed.
netmap contract is already deployed.
proxy contract is already deployed.
reputation contract is already deployed.
subnet contract is already deployed.
Waiting for transactions to persist...
Stage 4.1: Transfer GAS to proxy contract.
Stage 5: register candidates.
Stage 6: transfer NEO to alphabet contracts.
Stage 7: set addresses in NNS.
NNS: Set alphabet0.neofs -> 2efeb27866fa774ec6bfb43babaadcc7b28f9bb7
NNS: Set alphabet1.neofs -> 5606bc6598a538ac59ded3caa842247b9b26097a
NNS: Set alphabet2.neofs -> 2a8308cfd2706ddd5f67adfdf3954c6836806b5d
NNS: Set alphabet3.neofs -> 718d0459e6787f0f13f1e1898bf2ce6bc4bb452d
NNS: Set audit.neofs -> 54d516b36c3380efa2b2f26bda300b6c6302b8e7
NNS: Set balance.neofs -> 72b3255944524cb822788a7542c9d06cba208c0c
NNS: Set container.neofs -> 20a20f4352a49f161eccb7d5a806fd46dcab81ea
NNS: Set neofsid.neofs -> 04a3a71535689b820093cefe7ae188ed7591ad27
NNS: Set netmap.neofs -> 9a34c97b2ba6bd986fd9140a9c3d59059fa430f4
NNS: Set proxy.neofs -> 4eba34ec016f8709a511b02765a1195e31a921ea
NNS: Set reputation.neofs -> 77b5b2cf596957cc05ca3d57503ef08d72792301
NNS: Set subnet.neofs -> b0abe16bc7f56b2e7e0694ae2b36207c6aaa8636
panic: error serializing *transaction.Transaction: transaction has no script
goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/io.GetVarSize({0xbf6240, 0xc0003634a0})
github.com/nspcc-dev/neo-go@v0.98.2/pkg/io/size.go:68 +0x6fd
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).AddNetworkFee(0xc0004080c0, 0xc0003634a0, 0x0, {0xc00000e248, 0x1, 0x93})
github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/rpc.go:966 +0x6b
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).CreateTxFromScript(0x0, {0x0, 0x0, 0x0}, 0x1, 0x0, 0x0, {0xc0001c7990, 0x1, 0x1})
github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/nep17.go:128 +0x345
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).sendCommitteeTx(0xc00014a370, {0x0, 0x0, 0x0}, 0xc0016bcf30, 0x2)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:336 +0x131
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).updateNNSGroup(0xc0001c7c88, {0x13, 0xd3, 0x6b, 0x85, 0x3e, 0x86, 0xbe, 0x77, 0xb7, ...}, ...)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:89 +0x134
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).setNNS(0xc00014a370)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:74 +0x8c5
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.initializeSideChainCmd(0x12a00e0, {0xc22a22, 0x4, 0x4})
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:94 +0x2bc
github.com/spf13/cobra.(*Command).execute(0x12a00e0, {0xc00013a6c0, 0x4, 0x4})
github.com/spf13/cobra@v1.1.3/command.go:852 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x129c760)
github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.1.3/command.go:897
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules.Execute(...)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/root.go:48
main.main()
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/main.go:10 +0x25
zsh: exit 2 downloads/neofs-adm morph -c configuration/config.yaml init --contracts
```
2022-05-16 15:19:17 +03:00
Roman Khimov
75d06d18c9
Merge pull request #2466 from nspcc-dev/rules-fixes
...
Rules scope fixes
2022-05-06 11:09:39 +03:00
Roman Khimov
acb1151d71
transaction: fix maxSubitems handling in JSON scope unmarshaller
...
Notice that binary deserializer (readArrayOfConditions) does it correctly. Can
be checked with neo-project/neo#2720 case.
2022-05-06 10:20:55 +03:00
Roman Khimov
bd352daab4
transaction: fix Rules stringer, it's WitnessRules in C#
...
See neo-project/neo#2720 .
2022-05-06 10:08:09 +03:00
Elizaveta Chichindaeva
28908aa3cf
[ #2442 ] English Check
...
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Anna Shaleva
47d52bd9c5
core: add getTransactionSigners method to native Ledger
2022-04-29 11:18:58 +03:00
Anna Shaleva
35d930951c
core: consider Rules witness scope as valid
2022-04-27 12:48:33 +03:00
AnnaShaleva
92282c70cb
*: support customisable NotaryServiceFeePerKey value
...
* Add corresponding methods to Notary contract.
* Extend RPC Client API.
* Adjust tests.
2022-03-01 19:08:16 +03:00
Roman Khimov
ffeb3b8473
transaction: microoptimize Hash()
...
It doesn't cost much, but it's used _a lot_, so optimizing it makes sense.
name old time/op new time/op delta
TxHash-8 4.89ns ± 5% 0.54ns ± 2% -88.86% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
TxHash-8 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
TxHash-8 0.00 0.00 ~ (all equal)
2021-12-02 14:48:35 +03:00
Roman Khimov
9875799893
transaction: add new Rules witness scope
...
See neo-project/neo#2622 . The implementation is somewhat asymmetric (and not
very efficient) for binary/JSON encoding/decoding, but it should be
sufficient.
2021-11-12 15:29:28 +03:00
Roman Khimov
8a440a4016
transaction: fix ContentTypeNotSupported oracle code processing
...
Fix testnet block 311487 block processing and synchronization errors:
2021-09-14T15:18:53.611+0300 WARN peer disconnected {"addr": "20.198.226.132:20333", "reason": "invalid oracle response code", "peerCount": 10}
Fix 8e9302f40b
.
2021-09-14 15:18:38 +03:00
Roman Khimov
7808762ba0
transaction: avoid reencoding and reading what can't be read
...
name old time/op new time/op delta
DecodeFromBytes-8 1.79µs ± 2% 1.46µs ± 4% -18.44% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
DecodeFromBytes-8 800B ± 0% 624B ± 0% -22.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
DecodeFromBytes-8 10.0 ± 0% 8.0 ± 0% -20.00% (p=0.000 n=10+10)
2021-08-23 21:41:38 +03:00
Evgeniy Stratonikov
620295efe3
transaction: add benchmark for transaction serialization
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-09 12:01:38 +03:00
Evgeniy Stratonikov
291a29af1e
*: do not use WriteArray
for frequently used items
...
`WriteArray` involves reflection, it makes sense to optimize
serialization of transactions and application logs which are serialized
constantly. Adding case in a type switch in `WriteArray` is not an
option because we don't want new dependencies for `io` package.
```
name old time/op new time/op delta
AppExecResult_EncodeBinary-8 852ns ± 3% 656ns ± 2% -22.94% (p=0.000 n=10+9)
name old alloc/op new alloc/op delta
AppExecResult_EncodeBinary-8 448B ± 0% 376B ± 0% -16.07% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
AppExecResult_EncodeBinary-8 7.00 ± 0% 5.00 ± 0% -28.57% (p=0.000 n=10+10)
```
```
name old time/op new time/op delta
Transaction_Bytes-8 1.29µs ± 3% 0.76µs ± 5% -41.52% (p=0.000 n=9+10)
name old alloc/op new alloc/op delta
Transaction_Bytes-8 1.21kB ± 0% 1.01kB ± 0% -16.56% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
Transaction_Bytes-8 12.0 ± 0% 7.0 ± 0% -41.67% (p=0.000 n=10+10)
```
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-06 11:59:20 +03:00
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