Commit graph

88 commits

Author SHA1 Message Date
Anna Shaleva
e2ef904901 config: use http for oracle nodes
Otherwise the following error occurs:
```
first path segment in URL cannot contain colon
```
2021-11-26 17:17:10 +03:00
Roman Khimov
6de6415a53 oracle: unify filtering and add log for error case
Just to simplify debugging.
2021-11-23 18:43:15 +03:00
AnnaShaleva
2d196b3f35 rpc: refactor calculatenetworkfee handler
Use (Blockchainer).VerifyWitness() to calculate network fee for
contract-based witnesses.
2021-10-25 19:07:25 +03:00
Anna Shaleva
807fa4a720 services: allow non-empty inv scripts for contract-based notary witness 2021-10-25 17:23:29 +03:00
Anna Shaleva
75d7891ca1 services: add ability to combine notary signers
Notes for witnesses:
* [N sig + M multisig + K contract] combination is possible where N, M, K >=0.
* Each verification script should be properly filled in.
* Each invocation script should either be empty or contain exactly one
signature.
2021-10-25 12:22:13 +03:00
Anna Shaleva
fcc7f7349d services: refactor the logic of notary signatures counting
Maintain the number of signatures left to collect instead of maintaining
the number of already collected signatures and overall number of
signatures.
2021-10-22 17:06:46 +03:00
Anna Shaleva
07cbe4d253 core: add finalizer functions to interop context
These functions are aimed to free the resources occupied by storage
iterator by the end of script execution or whenever Finilize is called.
2021-10-21 10:05:12 +03:00
Anna Shaleva
dfc0b25cfe gomod: use nspcc-dev's fork of go-ordered-json
Escape non-ASCII characters while JSON encoding.
2021-09-15 15:01:01 +03:00
Evgeniy Stratonikov
e2f2addf95 notary: fix possible deadlock in UpdateNotaryNodes
`UpdateNotaryNodes` takes account then request mutex, and `PostPersist` takes
them in a different order. Because they are executed concurrently a deadlock
can appear.

```
2021-07-23T11:06:58.3732405Z panic: test timed out after 10m0s
2021-07-23T11:06:58.3732642Z
2021-07-23T11:06:58.3742610Z goroutine 7351 [semacquire, 9 minutes]:
2021-07-23T11:06:58.3743140Z sync.runtime_SemacquireMutex(0xc00010e4dc, 0x1100000000, 0x1)
2021-07-23T11:06:58.3743747Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/runtime/sema.go:71 +0x47
2021-07-23T11:06:58.3744222Z sync.(*Mutex).lockSlow(0xc00010e4d8)
2021-07-23T11:06:58.3744742Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/sync/mutex.go:138 +0x1c1
2021-07-23T11:06:58.3745209Z sync.(*Mutex).Lock(0xc00010e4d8)
2021-07-23T11:06:58.3745692Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/sync/mutex.go:81 +0x7d
2021-07-23T11:06:58.3746162Z sync.(*RWMutex).Lock(0xc00010e4d8)
2021-07-23T11:06:58.3746764Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/sync/rwmutex.go:98 +0x4a
2021-07-23T11:06:58.3747699Z github.com/nspcc-dev/neo-go/pkg/services/notary.(*Notary).UpdateNotaryNodes(0xc00010e480, 0xc000105b90, 0x1, 0x1)
2021-07-23T11:06:58.3748621Z 	/home/runner/work/neo-go/neo-go/pkg/services/notary/node.go:44 +0x3ba
2021-07-23T11:06:58.3749367Z github.com/nspcc-dev/neo-go/pkg/core.TestNotary(0xc0003677a0)
2021-07-23T11:06:58.3750116Z 	/home/runner/work/neo-go/neo-go/pkg/core/notary_test.go:594 +0x2dba
2021-07-23T11:06:58.3750641Z testing.tRunner(0xc0003677a0, 0x16f3308)
2021-07-23T11:06:58.3751202Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/testing/testing.go:1050 +0x1ec
2021-07-23T11:06:58.3751696Z created by testing.(*T).Run
2021-07-23T11:06:58.3752225Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/testing/testing.go:1095 +0x538
2021-07-23T11:06:58.3752573Z
2021-07-23T11:06:58.3771319Z goroutine 7340 [semacquire, 9 minutes]:
2021-07-23T11:06:58.3772048Z sync.runtime_SemacquireMutex(0xc00010e504, 0x0, 0x0)
2021-07-23T11:06:58.3772889Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/runtime/sema.go:71 +0x47
2021-07-23T11:06:58.3773581Z sync.(*RWMutex).RLock(0xc00010e4f8)
2021-07-23T11:06:58.3774310Z 	/opt/hostedtoolcache/go/1.14.15/x64/src/sync/rwmutex.go:50 +0xa4
2021-07-23T11:06:58.3775449Z github.com/nspcc-dev/neo-go/pkg/services/notary.(*Notary).getAccount(0xc00010e480, 0x0)
2021-07-23T11:06:58.3776626Z 	/home/runner/work/neo-go/neo-go/pkg/services/notary/node.go:51 +0x51
2021-07-23T11:06:58.3778270Z github.com/nspcc-dev/neo-go/pkg/services/notary.(*Notary).finalize(0xc00010e480, 0xc0003b2630, 0xa97df1bc78dd5787, 0xcc8a4d69e7f5d62a, 0x1a4d7981bd86b087, 0xbafdb720c93480b3, 0x0, 0x0)
2021-07-23T11:06:58.3779845Z 	/home/runner/work/neo-go/neo-go/pkg/services/notary/notary.go:306 +0x54
2021-07-23T11:06:58.3781022Z github.com/nspcc-dev/neo-go/pkg/services/notary.(*Notary).PostPersist(0xc00010e480)
2021-07-23T11:06:58.3782232Z 	/home/runner/work/neo-go/neo-go/pkg/services/notary/notary.go:297 +0x662
2021-07-23T11:06:58.3782989Z github.com/nspcc-dev/neo-go/pkg/services/notary.(*Notary).Run(0xc00010e480)
2021-07-23T11:06:58.3783941Z 	/home/runner/work/neo-go/neo-go/pkg/services/notary/notary.go:148 +0x3cb
2021-07-23T11:06:58.3784702Z created by github.com/nspcc-dev/neo-go/pkg/core.TestNotary
2021-07-23T11:06:58.3785451Z 	/home/runner/work/neo-go/neo-go/pkg/core/notary_test.go:132 +0x6e0
```

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-23 14:48:00 +03:00
Evgeniy Stratonikov
3507f52c32 notary: process new transactions in a separate goroutine
Related #2063.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-23 14:48:00 +03:00
Roman Khimov
c88ebaede9
Merge pull request #2075 from nspcc-dev/small-refactoring
Array util refactoring and naming improvement
2021-07-20 11:29:59 +03:00
Roman Khimov
19717dd9a8 slice: introduce common Copy helper
It's a bit more convenient to use.
2021-07-19 22:57:55 +03:00
Roman Khimov
3a93977b7b oracle: only process new requests after initial sync
If an oracle node is resynchronized from the genesis the service receives all
requests from all blocks via AddRequests() invoked from the native
contract. Almost all of them are long obsolete and need to be removed, native
oracle contract will try to do that with RemoveRequests() calls, but they
won't change anything.

So queue up all "initial" requests in special map and manage it directly
before the module is Run() which happens after synchronization
completion. Then process any requests that are still active and work with new
blocks as usual.
2021-07-19 22:52:59 +03:00
Roman Khimov
0bad413e23 oracle: ensure proper ValidUntilBlock for backup tx
See neo-project/neo-modules#608.
2021-07-19 21:58:10 +03:00
Evgeniy Stratonikov
e936e5e295 oracle: set request Content-Type
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-12 13:13:48 +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
a4c7b3d0cf jsonpath: add tests for null objects, fix #2039
Turns out, nothing should be changed in our implementation because
nil-check is done implicitly by type casts or type switches.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-07 12:27:10 +03:00
Anna Shaleva
472a44a464 *: regenerate test wallets with resources-friendly scrypt parameters 2021-06-11 15:22:32 +03:00
Anna Shaleva
50296975e2 crypto: allow to provide non-default scrypt parameters 2021-06-11 15:22:28 +03:00
Pavel Karpy
874c56c77b oracle/neofs: stop using deprecated types
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-06-10 14:16:07 +03:00
Pavel Karpy
c4f8c7a9b2 oracle/neofs: update neofs-api-go
Update neofs-api-go to `v1.27.1`.
Add `WithURIAddress` client option.
Stop using `V2` abstractions outside
of the `api-go` library.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2021-06-10 14:16:02 +03:00
Anna Shaleva
b8e96ac82b core: move mempool.Event to a separate package
And write a marshaller for EventType, it'll be reused by the Notification
subsystem.
2021-06-01 12:24:28 +03:00
Evgeniy Stratonikov
33e1e61343 config: make MaxValidUntilBlockIncrement configurable 2021-05-17 13:43:03 +03:00
Evgeniy Stratonikov
ea49c6b637 wallet: rename isdefault to isDefault
Follow neo-project/neo#2451 .
2021-05-14 10:31:31 +03:00
Roman Khimov
4131e208e5 jsonpath: drop unnecessary assignment, fix lint fail
pkg/services/oracle/jsonpath/jsonpath.go:354:8  ineffassign  ineffectual assignment to val
2021-05-13 17:26:38 +03:00
Roman Khimov
f2f9ec1a05
Merge pull request #1916 from nspcc-dev/fix/oraclefilter
oracle: make JSONPath compatible with C# implementation
2021-05-13 15:34:52 +03:00
Evgeniy Stratonikov
28a0d68c05 jsonpath: allow empty paths 2021-05-13 11:53:49 +03:00
Evgeniy Stratonikov
5fc81c787b jsonpath: use ordered map json unmarshaler 2021-05-13 11:53:49 +03:00
Evgeniy Stratonikov
6890688b8f oracle: add max nesting depth to JSONPath filter 2021-05-13 11:53:49 +03:00
Evgeniy Stratonikov
1c30d8c395 oracle: make JSONPath compatible with C# implementation
C# node uses simplified implementation which is easy to port.
2021-05-13 11:53:28 +03:00
Roman Khimov
c4e084b0d8 *: fix whitespace errors
leading/trailing newlines
2021-05-12 22:51:41 +03:00
Roman Khimov
92dbb3c4b9 *: fix all unused warnings
From golangci-lint.
2021-05-12 18:53:12 +03:00
Roman Khimov
cfc067dd24 *: remove dead code
Found by deadcode via golangci-lint.
2021-05-12 18:13:14 +03:00
Anna Shaleva
366e79b9b8 core: rename Neo.Crypto.CheckSig interop 2021-05-11 18:37:55 +03:00
Roman Khimov
3402a3ec30 oracle: send user-agent header with our requests, fix #1923 2021-05-07 16:40:45 +03:00
Roman Khimov
39571745cb stateroot: fix incompleteRoot leak
Drop old incomplete roots from the map.
2021-05-07 14:31:20 +03:00
Roman Khimov
3d49f7d99a stateroot: only send stateroot message once per validators count
Actually fix #1922.
2021-05-07 14:31:20 +03:00
Roman Khimov
4a45abe3e0 stateroot: make vote/root extensibles live less
These are arbitrary numbers, but that's what C# node uses. maxRetries could be
set lower because we have exponential backoff anyway, but this works too.
2021-05-07 14:31:20 +03:00
Roman Khimov
7c902669bf stateroot: implement exponential vote resends 2021-05-07 14:31:20 +03:00
Roman Khimov
d5c7a40db9 stateroot: try finalizing stateroot when adding our signature
And don't add/resend it multiple times.

1. We can be in a setup with one SV only and no AddSignature() called at all.
2. AddSignature() might add M-1 signatures and our signature should be the
   last one to complete MPTRoot, but we'll never do that.
2021-05-06 23:29:43 +03:00
Roman Khimov
847927af74 stateroot: s/onValidatedRoot/relayExtensible/
Makes more sense because it's not just roots that we're relaying.
2021-05-06 22:32:13 +03:00
Roman Khimov
222b4dc920 stateroot: simplify account locking, deduplicate code 2021-05-06 22:17:09 +03:00
Roman Khimov
fc800dcbc1 stateroot: protect incomplete root manipulations in signAndSend
We're modifying it here, so there can be a race between this method and
AddSignature().
2021-05-06 21:53:34 +03:00
Roman Khimov
7a1c1638e4 oracle: specify neofs timeout as timeout, set default if 0
There has to be some sane default and we'd like configuration to be consistent
with other timeout values.
2021-04-06 17:08:04 +03:00
Roman Khimov
f69fd34220 oracle: add logging, refactor request processing a bit
And return more appropriate errors in some cases.
2021-04-06 17:02:32 +03:00
Roman Khimov
d2f7f00997 oracle: change neofs URI scheme
Strip '//', see neo-project/neo-modules#518.
2021-04-06 16:56:19 +03:00
Roman Khimov
bd9a303e29 oracle: URI host validation is only relevant for https
NeoFS doesn't have hosts.
2021-04-06 16:53:32 +03:00
Roman Khimov
29b79db998 oracle: we only work with https, forget http 2021-04-06 16:53:18 +03:00
Roman Khimov
84b240cc9a services/consensus: add some logging on start 2021-04-02 13:13:26 +03:00
Roman Khimov
a01636a1b0 stateroot: set networking callback in a more straightforward way 2021-04-02 12:12:36 +03:00