Roman Khimov
78773df6ec
network: try connecting to seeds indefinitely, use them with 0 pool
...
If the node is to start with seeds unavailable it will try connecting to each
of them three times, blacklist them and then sit forever waiting for
something. It's not a good behavior, it should always try connecting to seeds
if nothing else works.
2020-10-13 18:00:31 +03:00
Roman Khimov
b36371ed94
network: an address should either be good or bad, but not both
2020-10-13 14:16:06 +03:00
Roman Khimov
b310ac051b
core/rpc: add continue
flag to iterating functions
...
Most of the time we don't need to get all transfers from the DB and
deserialize them.
2020-09-08 15:38:33 +03:00
Roman Khimov
d8aac7c675
Merge pull request #1291 from nspcc-dev/stateroot-relaying-during-commit-2.x
...
Stateroot relaying during commit 2.x
2020-08-10 19:22:17 +03:00
Roman Khimov
92f8cee6cd
network: raise MPTRoot broadcast priority
...
It can affect consensus process.
2020-08-10 16:48:05 +03:00
Roman Khimov
ab7a69bfec
network: prevent useless getroots requests
...
At the height of A we only reliably have a state root for A-1, so there is no
point in requesting state root for A from our peers. Prevents tons of useless
traffic:
2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "getroots"}
2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "roots"}
2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "getroots"}
2020-08-10T00:02:35.537+0300 DEBUG got msg {"addr": "127.0.0.1:20333", "type": "roots"}
2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20335", "type": "getroots"}
2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20335", "type": "roots"}
2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "getroots"}
2020-08-10T00:02:35.539+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "roots"}
2020-08-10T00:02:35.540+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "getroots"}
2020-08-10T00:02:35.540+0300 DEBUG got msg {"addr": "127.0.0.1:20334", "type": "roots"}
2020-08-10T00:02:35.542+0300 DEBUG got msg {"addr": "127.0.0.1:20336", "type": "getroots"}
2020-08-10T00:02:35.542+0300 DEBUG got msg {"addr": "127.0.0.1:20336", "type": "roots"}
2020-08-10 16:48:05 +03:00
Anna Shaleva
4715efd531
core, rpc: invoke script with hashes for verifying
...
Closes #1275
2020-08-07 13:18:55 +03:00
Evgenii Stratonikov
7bd4488ff9
core: do not store NEP5 transfer log in memory
...
Traversing transfer log instead of accumulating and returning it
is faster and takes less memory.
2020-08-06 14:22:30 +03:00
Evgenii Stratonikov
022fb04077
rpc: implement getutxotransfers
RPC
2020-08-06 14:16:28 +03:00
Evgenii Stratonikov
e4fcd90b6d
state: make NEP5Transfer log more generic
2020-08-04 16:57:36 +03:00
Evgenii Stratonikov
7cd1bca1e1
core,dao: save contract metadata on migration
...
After contract is migrated there is no way to retrieve it's state.
This commit implements some metadata for NEP5 contracts, so that
values important for diplaying transfer log aren't lost.
2020-07-24 14:38:10 +03:00
Roman Khimov
692565c5a2
network: fix stateroot processing for StateRootEnableIndex != 0
...
We we missing stateroot for StateRootEnableIndex, starting only with
StateRootEnableIndex + 1.
2020-07-18 20:58:47 +03:00
Roman Khimov
4d0f4d3e51
network: copy peers for Shutdown iteration
...
We can't lock them (or there will be a deadlock), but we need to fix this:
fatal error: concurrent map iteration and map write
goroutine 1 [running]:
runtime.throw(0xdec086, 0x26)
/usr/lib64/go/1.12/src/runtime/panic.go:617 +0x72 fp=0xc02fec2bf8 sp=0xc02fec2bc8 pc=0x42d932
runtime.mapiternext(0xc02fec2d40)
/usr/lib64/go/1.12/src/runtime/map.go:860 +0x597 fp=0xc02fec2c80 sp=0xc02fec2bf8 pc=0x40efe7
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown(0xc0000fc160)
/home/rik/dev/neo-go2/pkg/network/server.go:194 +0x238 fp=0xc02fec2db0 sp=0xc02fec2c80 pc=0xa89da8
github.com/nspcc-dev/neo-go/cli/server.startServer(0xc0000fcc60, 0x0, 0x0)
/home/rik/dev/neo-go2/cli/server/server.go:399 +0x7a9 fp=0xc02fec3820 sp=0xc02fec2db0 pc=0xae2079
...
2020-07-16 11:43:34 +03:00
Evgenii Stratonikov
b5fb63d091
*: specify first state root index in config
2020-06-24 12:37:27 +03:00
Evgenii Stratonikov
d128b55dbf
*: add config flag for enabling state root feature
2020-06-24 12:37:27 +03:00
Evgenii Stratonikov
caf53740d3
network: do not process state roots below verified height
...
Implement fast path to skip state root retrieval and decoding.
2020-06-22 12:33:35 +03:00
Evgenii Stratonikov
e2e1bd09ae
network: request state roots if needed
2020-06-22 12:33:35 +03:00
Evgenii Stratonikov
f8051da0bd
core: extend Blockchainer interface with StateHeight()
...
Allow to query current verified state root height.
2020-06-22 10:53:13 +03:00
Evgenii Stratonikov
1fd7938fd8
network: process state roots properly
2020-06-08 17:31:59 +03:00
Evgenii Stratonikov
8cbbddddaf
rpc: implement getproof RPC
2020-06-08 17:31:58 +03:00
Evgenii Stratonikov
edcfdb3bde
network: add MPT-related P2P payloads
2020-06-03 13:33:44 +03:00
Evgenii Stratonikov
20f190ef69
core: update MPT during block processing
2020-06-03 13:33:44 +03:00
Roman Khimov
d686fe4e5d
network: get blocks directly from the chain for rebroadcasting
...
Simplify network<->consensus relations, also broadcast blocks received by
other means like RPC.
2020-05-12 17:42:34 +03:00
Roman Khimov
dd8bcfae47
consensus: remove OnNewBlock(), use Blockchain subscription
...
Get new blocks directly from the Blockchain. It may lead to some duplications
(as we'll also receive our own blocks), but at the same time it's more
correct, because technically we can also get blocks via other means besides
network server like RPC (submitblock call). And it simplifies network server
at the same time.
2020-05-12 17:41:23 +03:00
Roman Khimov
1ac4f8528d
core: add Blockchain event subscription mechanism
...
A deep internal part of #895 . Blockchainer interface is also extended for
various uses of these methods.
2020-05-12 17:41:15 +03:00
Roman Khimov
5f09381cf4
core: wrap cached dao properly, don't miss cached data
...
Fixes #817 where invoked contract missed updated account information because
it got it one layer below cachedDao used to process the block.
2020-04-03 10:15:11 +03:00
Roman Khimov
9b5dab57e8
Merge pull request #810 from nspcc-dev/refactor/config
...
config: move config.go out of config
2020-04-01 10:29:57 +03:00
Anna Shaleva
5a984fdf88
config: move config.go out of config/
...
closes #423
2020-03-31 17:55:59 +03:00
Evgenii Stratonikov
9abda40171
testserdes: implement helpers for encode/decode routines
...
Frequently one needs to check if struct serializes/deserializes
properly. This commit implements helpers for such cases including:
1. JSON
2. io.Serializable interface
2020-03-27 10:27:46 +03:00
Evgenii Stratonikov
df2598c8dc
core: store NEP5 balances separately
...
There is no need to take and unmarshal an account structure only
to get it's NEP5 balances.
2020-03-12 12:58:28 +03:00
Roman Khimov
5f1868af28
Merge pull request #743 from nspcc-dev/optimize-some-db-accesses
...
Optimize some db accesses
2020-03-11 17:33:36 +03:00
Roman Khimov
377fb382aa
core: move (un)SpentCoin structs into the state package
...
As they're all about the state.
2020-03-11 12:22:52 +03:00
Evgenii Stratonikov
b7dee156e2
network: fix a deadlock in DefaultDiscovery
...
Why a deadlock can occur:
1. (*DefaultDiscovery).run() has a for loop over requestCh channel.
2. (*DefaultDiscovery).RequestRemote() send to this channel while
holding a mutex.
3. (*DefaultDiscovery).RegisterBadAddr() tries to take mutex for write.
4. Second select-case can't take mutex for read because of (3).
2020-03-10 15:40:23 +03:00
Anna Shaleva
456a2d55fd
rpc: implement getvalidators
...
closes #714
2020-03-07 18:05:40 +03:00
Roman Khimov
fbdc60b731
Merge pull request #723 from nspcc-dev/feature/nep5
...
core,rpc: implement NEP5-related logic
2020-03-05 18:33:58 +03:00
Evgenii Stratonikov
95a8fa234f
rpc: implement getnep5transfers RPC
2020-03-05 18:22:40 +03:00
Roman Khimov
31948ee4a7
network: add a nil check in (*TCPTransport).Close, prevent panic
...
You have to try to trigger that, but in the event of server shutdown before it
actually started listening Close will easily panic like this:
2020-03-05T11:48:08.660+0300 INFO node started {"blockHeight": 6458, "headerHeight": 15605}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x9d5f0a]
goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Close(0xc000fd7050)
/home/rik/dev/neo-go/pkg/network/tcp_transport.go:78 +0x2a
github.com/nspcc-dev/neo-go/pkg/network.(*Server).Shutdown(0xc000182280)
/home/rik/dev/neo-go/pkg/network/server.go:190 +0x189
github.com/nspcc-dev/neo-go/cli/server.startServer(0xc000200160, 0x0, 0x0)
/home/rik/dev/neo-go/cli/server/server.go:367 +0x79e
github.com/urfave/cli.HandleAction(0xb84860, 0xccf240, 0xc000200160, 0xc0001c4500, 0x0)
/home/rik/dev/neo-go/vendor/github.com/urfave/cli/app.go:490 +0xc8
github.com/urfave/cli.Command.Run(0xc9a160, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0xca407f, 0x10, 0x0, ...)
/home/rik/dev/neo-go/vendor/github.com/urfave/cli/command.go:210 +0x996
github.com/urfave/cli.(*App).Run(0xc0001d64e0, 0xc0000ca000, 0x3, 0x3, 0x0, 0x0)
/home/rik/dev/neo-go/vendor/github.com/urfave/cli/app.go:255 +0x6af
main.main()
/home/rik/dev/neo-go/cli/main.go:25 +0x505
2020-03-05 11:53:26 +03:00
Roman Khimov
e41d434a49
*: move all packages from CityOfZion to nspcc-dev
2020-03-03 17:21:42 +03:00
Evgenii Stratonikov
7095ec6c51
core: implement (*Blockchain).CalculateClaimable
...
Calculating amount of GAS that can be claimed is required
for getclaimable RPC.
2020-03-02 18:00:00 +03:00
Roman Khimov
252a9f2f31
Merge pull request #690 from nspcc-dev/feature/getapplicationlog
...
rpc: implement getapplicationlog RPC
2020-03-02 17:41:32 +03:00
Anna Shaleva
ff4384d7ff
rpc: implement getapplicationlog RPC
...
Closes #500
2020-03-02 17:25:27 +03:00
Evgenii Stratonikov
a3dacd3b74
tests: replace t.Fatal with require where possible
...
This makes tests less verbose and unifies the style
they are written in.
2020-03-02 17:22:27 +03:00
Evgenii Stratonikov
0ef7a76e84
network: batch transactions on broadcast
2020-03-02 10:37:27 +03:00
Roman Khimov
36197056b1
Merge pull request #691 from nspcc-dev/network-conn-overflow-and-shutdown
...
Network conn overflow and shutdown
2020-02-28 18:16:29 +03:00
Roman Khimov
e213e69a33
network: rework shutdown sequence of Server
...
Close transport and disconnect peers right in the Shutdown(), so that no new
connections would be accepted and so that all the peers would be disconnected
correctly (avoiding the same deadlock as in e2116e4c3f
).
2020-02-28 16:22:04 +03:00
Roman Khimov
77624a8847
network: add Close() to discoverer, shut it down on exit
2020-02-28 16:22:04 +03:00
Roman Khimov
9f7018503a
core/transaction: use new transaction.InOut for References
...
We don't need a map here, use simpler structures.
2020-02-27 12:00:03 +03:00
Roman Khimov
e2116e4c3f
network: don't deadlock on connection overflow
...
(*Peer).Disconnect send an unregister signal to this goroutine, so invoking it
from here is not a good idea, run it asynchronously.
2020-02-24 15:56:49 +03:00
Roman Khimov
723b33e108
network: implement unconnected/bad peers getters
...
Which allows node to respond to `getpeers` RPC request correctly.
2020-02-21 15:12:03 +03:00
Roman Khimov
d92e193e63
rpc/network: refactor getpeers logic
...
Deduplicate and simplify code.
2020-02-21 15:12:03 +03:00