Roman Khimov
38d14d4e3a
network: drop requests to discovery pool when it can't be handled
...
It happens from time to time in a four-node private network where there are
seeds (aka CNs) and not a lot of other nodes to connect to.
I don't know how to test for an infinite loop that has no side-effects, so no
test added here.
2021-06-18 10:55:29 +03:00
Roman Khimov
9d6439bbe6
network: don't attempt to connect to the same node twice
...
We can have multiple copies of the same address in the pool and we should only
proceed to connect once per attempt.
2021-06-18 10:50:01 +03:00
Roman Khimov
46a59e904a
network: don't register addresses before version handshake
...
1) It duplicates registration in `version` message handler and no valid
connection can work without version exchange.
2) On public networks we have seed nodes defined by names, so we register
connections to them using these names, but then if connection is dropped we
delist them by IP:PORT combinations which can lead to zero PeerCount() with
all seeds still being registered as connected in the discovery subsystem
and thus no reconnection attempts being made.
2021-06-18 10:49:42 +03:00
Roman Khimov
a46c93f6bb
rpc: fix getblocksystemfee call
...
It should return cumulative fee and it should be wrapped into a string.
2021-02-15 17:58:39 +03:00
Evgenii Stratonikov
ee45d7739f
network: fix requestTx()
...
2 bugs were here:
1. If amount of tx is small, no messages were sent.
2. Correctly cut byte slice if last message is small.
2020-12-31 13:00:50 +03:00
Roman Khimov
363c24d128
network: fix tx requests, we can't ask more than 500 txes at once
2020-12-31 13:00:00 +03:00
Evgenii Stratonikov
9756ed2b06
network: set timeout on write
...
Fix a bug occuring under high load when node
hangs during this write.
2020-12-31 12:58:00 +03:00
Evgenii Stratonikov
edf587bbf1
network: fix a bug in discovery with a peer connected twice
...
It could be the case that checks are performed simultaneosly and
peers connections goes down from 2 to 0. We must take such case into
account and register address as good in discovery.
2020-12-31 12:57:43 +03:00
Evgenii Stratonikov
0d2bc8f4a6
network: remove extra error check from Message.Encode()
...
Buffer write error is returned from `Encode()`.
2020-12-31 12:52:40 +03:00
Evgenii Stratonikov
d93ddfda10
network: retransmit stale transactions
2020-11-11 15:51:36 +03:00
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