Roman Khimov
d2bdae99e4
Merge pull request #492 from nspcc-dev/feature/interop_neo_tests1
...
core: add unit tests for interops_neo
2019-11-18 19:39:05 +03:00
Vsevolod Brekelov
d57b6e1091
core: add unit tests for interops_neo
2019-11-18 19:31:27 +03:00
Roman Khimov
5841d3931e
rpc: implement getunspents method, fix #473
2019-11-18 11:30:09 +03:00
Roman Khimov
e4868cd429
core: implement EncodeBinary on value
...
Fixes panic:
panic: core.NotificationEvent does not have EncodeBinary(*BinWriter)
goroutine 97 [running]:
github.com/CityOfZion/neo-go/pkg/io.(*BinWriter).WriteArray(0xc004f7dda0, 0xabf820, 0xc004f7ddc0)
/home/rik/dev/neo-go/pkg/io/binaryWriter.go:45 +0x4b7
github.com/CityOfZion/neo-go/pkg/core.(*AppExecResult).EncodeBinary(0xc000635498, 0xc004f7dda0)
/home/rik/dev/neo-go/pkg/core/notification_event.go:73 +0x9c
github.com/CityOfZion/neo-go/pkg/core.putAppExecResultIntoStore(0xcf0020, 0xc001aafec0, 0xc000635498, 0xc004f81940, 0x40)
/home/rik/dev/neo-go/pkg/core/notification_event.go:33 +0xab
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).storeBlock(0xc000118000, 0xc006f89ea0, 0xc006f89ea0, 0x0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:534 +0x2539
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).AddBlock(0xc000118000, 0xc006f89ea0, 0xc004f368b0, 0x1)
/home/rik/dev/neo-go/pkg/core/blockchain.go:256 +0x91
github.com/CityOfZion/neo-go/pkg/network.(*blockQueue).run(0xc0048f4b80)
/home/rik/dev/neo-go/pkg/network/blockqueue.go:39 +0x14c
created by github.com/CityOfZion/neo-go/pkg/network.(*Server).Start
/home/rik/dev/neo-go/pkg/network/server.go:133 +0x272
2019-11-15 22:05:09 +03:00
Roman Khimov
1a5731e005
core: rework balance accounting
...
Store all unspents instead of balance values. Bump store version as this is an
incompatible change.
2019-11-15 22:05:09 +03:00
Roman Khimov
a16c2c3825
core: add NEP5 transfer tracking stub
...
See #498 .
2019-11-15 18:04:59 +03:00
Roman Khimov
01082a8988
core: fix nondeterministic txGetReferences() behavior
...
Ranging over map is nondeterministic and contracts may be unprepared for
that. Fixes #454 .
2019-11-15 18:04:59 +03:00
Roman Khimov
5e8122bfac
core: add contract hash into the error output for checkStorageContext()
...
Makes debugging things easier.
2019-11-15 18:04:59 +03:00
Roman Khimov
5ce269c035
core: change notify implementation to save notifications
...
Fixes #453 and makes it possible to refer to these notifications later.
2019-11-15 18:04:59 +03:00
Evgenii Stratonikov
1a08ad19aa
sc: implement io.Serializable for ParamType
2019-11-14 14:20:38 +03:00
Evgenii Stratonikov
2be18f91df
util: implement io.Serializable for Uint256
2019-11-14 14:20:38 +03:00
Evgenii Stratonikov
b16e56a47b
io: refactor BinReader.ReadArray()
...
Make it accept arbitrary slice pointer.
2019-11-14 14:19:58 +03:00
Evgenii Stratonikov
ad9091d13d
io: implement generic array (de-)serialization
...
It is done through reflection and panics
in every unexpected situation.
2019-11-13 17:27:23 +03:00
Roman Khimov
394346fc26
core: add proper claim transactions processing
2019-11-11 15:35:57 +03:00
Roman Khimov
b05754deac
core: add Close() to blockchainer, implement it to properly close chain
...
Before it the deferred function in Run() was actually never able to properly
close the Store, so we weren't synching the latest state to the disk.
2019-11-08 12:19:54 +03:00
Vsevolod
f686069f37
Merge pull request #481 from nspcc-dev/core-fix-init-corner-cases
...
Fix init corner cases
2019-11-06 18:36:40 +03:00
Roman Khimov
c567307748
core: fix potential issue with header list init
...
If we're to receive some 500 headers (less than `headerBatchCount`) and quit
before receiving more of them we end up with clean `bc.headerList` that will
be inited going backwards to the `targetHash`, but code path doesn't add add
the `targetHash` itself which it should do in this particular case, otherwise
we end with no genesis block hash in the list.
2019-11-06 18:13:45 +03:00
Roman Khimov
b5199625cd
core: init genesis block header if there are no other headers in DB
...
Fixes crash when restarted after the DB initialization and no blocks written
into the DB.
2019-11-06 17:58:19 +03:00
Roman Khimov
c16c2bf102
core: store current header reference on clean init
...
Missing it the following line could fail on subsequent restarts:
currHeaderHeight, currHeaderHash, err := storage.CurrentHeaderHeight(bc.store)
if the node was stopped before any headers had been received.
2019-11-06 17:56:06 +03:00
Vsevolod Brekelov
d799c98cfe
io: move common function and add unit tests for it
2019-11-06 17:12:33 +03:00
Roman Khimov
9f7625d699
core: don't do useless DB reads if nothing was persisted
2019-11-06 16:10:37 +03:00
Roman Khimov
90d4299f0b
core: gofmt blockchain.go
2019-11-06 16:09:45 +03:00
ed758458d5
vm: implement serialization interops in core package
2019-11-05 17:10:52 +03:00
Roman Khimov
2f6e678a19
Merge pull request #463 from nspcc-dev/smartcontract-fixes
...
Smartcontract RPC fixes
2019-10-29 20:54:46 +03:00
Vsevolod Brekelov
d374175170
monitoring: add prometheus monitoring
...
add init metrics service which uses prometheus;
add configuration for metrics service;
add monitoring metrics for blockchain,rpc,server;
2019-10-29 20:51:17 +03:00
Roman Khimov
ebc1ba4f38
rpc/core: implement invokescript method, fix #348
...
Extend Blockchainer with one more method to spawn a VM for test runs and use
it to run scripts. Gas consumption is not counted or limited in any way at the
moment (see #424 ).
2019-10-29 18:31:39 +03:00
Roman Khimov
a568740f56
core: deduplicate a part of VM setup into spawnVMWithInterops()
2019-10-29 17:10:50 +03:00
Roman Khimov
99bbad331d
core: add issue tx processing
...
Count available asset quantity, match C# code.
2019-10-25 17:20:12 +03:00
Roman Khimov
45cac07643
core: remove transactions from MemPool when they're stored in block
...
Extend MemPool with Remove() and use it. Fixes #446 .
2019-10-24 13:12:02 +03:00
Roman Khimov
184d8a0180
core: fix missing unlock in MemPool TryAdd()
...
Fixes deadlock on subsequent MemPool operations.
2019-10-24 13:12:01 +03:00
Roman Khimov
8d0ed9259c
transaction: fix invocation TX consistency in NewInvocationTX()
...
NewInvocationTX() returned a version number one transaction that actually
failed to pass that version down to the invocation data which lead to
serialization/deserialization inconsistency.
2019-10-23 14:50:24 +03:00
Roman Khimov
1250bf9579
Merge pull request #443 from nspcc-dev/spellcheck
...
spellcheck and comments fix
2019-10-22 18:01:40 +03:00
Vsevolod Brekelov
8ee421db14
fix spelling and godoc comments
2019-10-22 17:56:03 +03:00
Roman Khimov
3cbb699eb7
Merge pull request #426 from nspcc-dev/logger_247
...
Change fmt.Println to log, close #247 .
2019-10-22 14:41:30 +03:00
Vsevolod Brekelov
e2bfff8666
vm: removed mute mode and pushed logging to upper lvl
...
VM should be responsible for code execution and in case anyone interested in additional logging or errors they could handle them like we do it iin cli.
2019-10-22 13:44:14 +03:00
Roman Khimov
f1750d117b
Merge pull request #440 from nspcc-dev/db-dump-restore
...
DB dump and restore, fixes #436 .
2019-10-21 15:42:05 +03:00
Roman Khimov
07c2105aa5
core: log values from the store in persist()
...
We're about stored values here, so print those, which avoids blocking in
bc.HeaderHeight() and removes duplication between blockHeight and
persistedHeight. Fixes saving the blockchain on exit (deferred function in
Run() blocked in persist()).
Test modification was required because storeBlocks() doesn't actually save
headers and thus TestGetTransaction started to fail on persist().
2019-10-21 14:18:09 +03:00
Roman Khimov
70407f0c19
core: remove unused context parameter from persist()
2019-10-21 14:18:09 +03:00
Vsevolod Brekelov
063fe5be9d
unspentcoinstate: fix branch never executed
2019-10-21 12:40:11 +03:00
Roman Khimov
b533dfceba
core: don't panic on init when there are less than 2000 hashes
...
If you're to sync less than 2000 headers no batched header key-value is
gonna be written into the DB and init() would panic because
bc.headerList.Len() would return 0. Use genesis block as a target in this
case.
2019-10-21 08:37:01 +03:00
Vsevolod Brekelov
fe39c565b9
codestyle: redundant type conversion
2019-10-18 18:39:31 +03:00
Vsevolod Brekelov
1afdb895a1
codestyle: declare empty slice
...
https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices
2019-10-18 18:38:33 +03:00
Vsevolod Brekelov
ced2022273
storage: change println error for botldb to log
2019-10-17 18:23:49 +03:00
Roman Khimov
3fc2bf5452
*: fix some misspellings
...
Goreport:
neo-go/pkg/core/contract_state_test.go
Line 21: warning: "Contracto" is a misspelling of "Contraction" (misspell)
Line 64: warning: "Contracto" is a misspelling of "Contraction" (misspell)
neo-go/pkg/core/interop_neo.go
Line 420: warning: "succeedes" is a misspelling of "succeeds" (misspell)
neo-go/pkg/network/discovery.go
Line 118: warning: "succeded" is a misspelling of "succeeded" (misspell)
Line 128: warning: "successfuly" is a misspelling of "successfully" (misspell)
2019-10-17 12:30:24 +03:00
Roman Khimov
1b5ea67737
core: fix ineffassign suggestion
...
Goreport:
Line 467: warning: ineffectual assignment to persisted (ineffassign)
2019-10-17 12:27:15 +03:00
Roman Khimov
288000a8af
storage: drop useless nil assignment in leveldb code
...
golint suggests:
Line 24: warning: should drop = nil from declaration of var opts; it is the zero value (golint)
2019-10-17 12:18:16 +03:00
Roman Khimov
2245fedbb1
core: deduplicate state commit methods, use interim MemCachedStore
...
commit methods duplicated putSmthIntoStore functions, but have MemCachedStore
now that can easily substitute for a Batch, especially given that interop
needs something like that for its storage purposes anyway.
2019-10-16 17:33:45 +03:00
Roman Khimov
fc0031e5aa
core: move write caching layer into MemCacheStore
...
Simplify Blockchain and associated functions, deduplicate code, fix Get() and
Seek() implementations.
2019-10-16 17:33:45 +03:00
Roman Khimov
8926cbe368
core: fix potential data race in logging code
...
Spotted in CircleCI build with Go 1.12:
WARNING: DATA RACE
Write at 0x00c00011095c by goroutine 88:
sync/atomic.SwapInt32()
/usr/local/go/src/runtime/race_amd64.s:249 +0xb
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).persist()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:483 +0x172
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run.func2()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:191 +0x50
Previous read at 0x00c00011095c by goroutine 64:
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).persist()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:492 +0x4be
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run.func2()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:191 +0x50
Goroutine 88 (running) created at:
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:190 +0x264
Goroutine 64 (finished) created at:
github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).Run()
/go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:190 +0x264
2019-10-15 18:58:22 +03:00
Roman Khimov
a6610ba082
core: verify blocks, fix #12
...
This adds the following verifications:
* merkleroot check
* index check
* timestamp check
* witnesses verification
VerifyWitnesses is also renamed to verifyTxWitnesses here to not confuse it
with verifyBlockWitnesse and to hide it from external access (no users at the
moment).
2019-10-15 18:58:17 +03:00