Roman Khimov
5b6c5af704
*: implement EncodeBinary with pointer receivers where appropriate
...
Everywhere except ParamType (which is just a byte), reduce copying things
around for no real reason.
2019-12-09 18:25:15 +03:00
Roman Khimov
7e371588a7
core/tx: remove one layer of indirection for scripts and inouts
...
It reduces heap pressure a little for these elements as we don't have to
allocate/free them individually. And they're directly tied to transactions or
block, not being shared or anything like that, so it makes little sense for
them to be pointer-based. It only makes building transactions a little easier,
but that's obviously a minor usecase.
2019-12-09 17:14:10 +03:00
Roman Khimov
b542a5e7a0
io: add support for pointer receivers in WriteArray()
...
It's actually preferable to have pointer receivers for serializable types, so
this should be supported.
2019-12-09 16:57:25 +03:00
Roman Khimov
052ba1e94f
Merge pull request #545 from nspcc-dev/feat/optimizeio
...
Remove some reflection from the io package
2019-12-09 15:12:13 +03:00
Evgenii Stratonikov
0e1621a0da
go.mod: update dbft and tidy
2019-12-09 15:03:38 +03:00
Evgenii Stratonikov
fccb008594
io: implement ReadBytes()
2019-12-09 15:00:15 +03:00
Evgenii Stratonikov
838050f8b5
io: rename ReadBytes() to ReadVarBytes()
2019-12-09 15:00:15 +03:00
Evgenii Stratonikov
f01fc1cc29
io: optimize BinWriter.WriteArray()
...
Replace reflect.MethodByName with a simple interface cast.
2019-12-09 14:59:49 +03:00
Evgenii Stratonikov
1784a14148
io: optimize BinReader.ReadArray()
...
reflect.MethodByName is a rather expensive function especially when
called on hot path. This became obvious during profiling of db restore.
This commit replaces reflection with a cast to an interface.
2019-12-09 14:58:37 +03:00
Roman Khimov
1217c4f62a
Merge pull request #547 from nspcc-dev/rpc-uint160
...
rpc: simplify uint160 handling
2019-12-09 11:37:37 +03:00
Roman Khimov
3898aadcec
rpc: simplify uint160 handling
...
Use new Uint160DecodeStringLE() function.
2019-12-06 19:47:58 +03:00
Roman Khimov
e4d821f32d
Merge pull request #546 from nspcc-dev/write-optimizations
...
Write optimizations
2019-12-06 19:40:38 +03:00
Roman Khimov
9992a98007
core: optimize balance utxo removal
...
One of my samples had 8 (out of 30) seconds spent here, but values of 100ms
are more typical. After this change it becomes invisible.
2019-12-06 18:46:24 +03:00
Roman Khimov
844491d365
*: use more efficient WriteBytes where appropriate
...
Before this patch on block import we could easily be spending more than 6
seconds out of 30 in Uint256 encoding for UnspentBalance, now it's completely
off the radar.
2019-12-06 18:22:21 +03:00
Roman Khimov
e7687d620d
io: simplify WriteBytes()
...
Which speeds it up at least twofold for a typical 32-bytes write (and that's
for a very naïve test that allocates new BufBinWriter on every iteration):
pkg: github.com/CityOfZion/neo-go/pkg/io
BenchmarkWriteBytes-8 10000000 124 ns/op
BenchmarkWriteBytesOld-8 5000000 251 ns/op
2019-12-06 17:40:47 +03:00
Roman Khimov
86239dd668
Merge pull request #520 from nspcc-dev/fix/uint
...
util: refactor uint160/uint256 for endianness consistency
Closes #314 .
2019-12-06 15:52:00 +03:00
Evgenii Stratonikov
aa20a95181
util: add Uint256DecodeStringBE()
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
72fe884faa
util: add Uint160DecodeStringLE()
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
07e832f046
util: add Uint160DecodeBytesLE()
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
09b295d727
util: add Uint160.Reverse()
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
9e04e61533
util: make Uint160Size public
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
7179e4ba9f
util: add LE suffix to Uint256 methods
2019-12-06 12:16:55 +03:00
Evgenii Stratonikov
57efad912c
util: add LE suffix to Uint160 methods
2019-12-06 12:16:55 +03:00
Roman Khimov
5d2fb41991
Merge pull request #544 from nspcc-dev/fix/sign
...
consensus: sign and verify consensus payloads
2019-12-06 12:05:17 +03:00
Evgenii Stratonikov
138c94eda3
consensus: sign and verify consensus messages
2019-12-06 11:35:06 +03:00
Evgenii Stratonikov
765c354793
consensus: return signed messages from recovery.Get*
2019-12-06 11:33:32 +03:00
Roman Khimov
652ede03c8
Merge pull request #543 from nspcc-dev/force-neo-vm-tests-run
...
vm: force neo-vm tests presence
2019-12-05 12:42:57 +03:00
Roman Khimov
8beb135829
Merge pull request #542 from nspcc-dev/fix-storage-interop-reads
...
core: fix wrong data being read in interops (part of #501 )
2019-12-05 09:08:38 +03:00
Roman Khimov
f1e87f497b
circleci: get submodules on checkout, fix failing tests
2019-12-04 20:36:51 +03:00
Roman Khimov
becd4f2333
vm: force neo-vm tests presence
...
We succeeded this test without running anything real which is certainly not
good and I think we should always run this tests.
2019-12-04 20:30:27 +03:00
Roman Khimov
c034aae378
core: fix wrong data being read in interops (part of #501 )
...
When 74590551
introduced this code we had no proper caching layer, so there
were these strange fallbacks in the code. fc0031e5
should'd removed them, but
failed to do so, so do it now and fix processing of transactions that touch
storage for the same key (address) in the same block.
2019-12-04 19:51:57 +03:00
Vsevolod
ea350f524c
Merge pull request #541 from nspcc-dev/remove_mod_deps
...
mod: remove unused deps
2019-12-04 12:54:35 +03:00
Vsevolod Brekelov
8ce2ca93a9
mod: remove unused deps
2019-12-04 12:38:24 +03:00
Roman Khimov
e251889f7b
Merge pull request #540 from nspcc-dev/feature/triggerType_509
...
core: add trigger types as constants. Closes #509
2019-12-04 12:31:51 +03:00
Vsevolod Brekelov
ff15a0acfd
core: add trigger types as constants. Closes #509
2019-12-04 12:27:04 +03:00
Vsevolod
2b0ad6146d
Merge pull request #539 from nspcc-dev/wallet-password-read
...
cli/wallet: use more secure way to read passwords
2019-12-04 09:56:48 +03:00
Roman Khimov
c8aa061421
cli/wallet: use more secure way to read passwords
...
They were printed in plaintext, believe it or not. Also, `ssh/terminal` does
some proper magic to really read something from the terminal.
2019-12-03 20:04:52 +03:00
Roman Khimov
e002d7b40c
Merge pull request #538 from nspcc-dev/opcode-and-related
...
To use opcode definitions you have to import whole vm package that you might
not care about at all. So this moves opcodes to their own package under vm, fixes
and deduplicate related code and moves compiler package up one level.
2019-12-03 19:31:11 +03:00
Roman Khimov
852e6a335b
compiler: move it up from vm
...
It really deserves it, I think. Especially given that it doesn't have any
direct usage of `vm` package now.
2019-12-03 18:23:46 +03:00
Roman Khimov
31add423a8
core: replace open-coded PUSHBYTES64 with the one from opcode
2019-12-03 18:23:46 +03:00
Roman Khimov
141d27795e
rpc: remove hardcoded pushbytes64 constant
...
Using our new and shiny opcode package.
2019-12-03 18:23:46 +03:00
Roman Khimov
138e125646
*: remove duplicate functions producing verification script
...
Drop wif.GetVerificationScript(), drop
smartcontract.CreateSignatureRedeemScript(), add GetVerificationScript()
directly to the PublicKey and use it everywhere.
2019-12-03 18:23:46 +03:00
Roman Khimov
8d4dd2d2e1
vm: move opcodes into their own package
...
This allows easier reuse of opcodes and in some cases allows to eliminate
dependencies on the whole vm package, like in compiler that only needs opcodes
and doesn't care about VM for any other purpose.
And yes, they're opcodes because an instruction is a whole thing with
operands, that's what context.Next() returns.
2019-12-03 18:22:14 +03:00
Roman Khimov
bb5aba8f95
Merge pull request #537 from nspcc-dev/feature/unit_binaryWrite
...
io: add missing test
2019-12-03 17:40:29 +03:00
Vsevolod Brekelov
5a41da0e1a
io: add missing test
2019-12-03 16:20:06 +03:00
Roman Khimov
f48228ef7d
Merge pull request #467 from nspcc-dev/errcheck_297
...
This patchset closes #297 and #457 .
2019-12-03 15:06:11 +03:00
Vsevolod Brekelov
b08387efdb
vm: use BinWriter instead of Buffered version
...
In the future we could reuse emit interface without buf better
2019-12-03 13:50:23 +03:00
Vsevolod Brekelov
f5e2401984
vm: removed logging to fix #457
2019-12-03 13:49:49 +03:00
Vsevolod Brekelov
03ff2976ed
io: refactoring for using WriteVarBytes instead of WriteLE
...
goal is to be consistent with C# implementation.
For writing []byte WriteBytes used and for byte - WriteVarByte.
2019-12-03 13:49:33 +03:00
Roman Khimov
8e9cabe1eb
Merge pull request #535 from nspcc-dev/mempool-locking-fixes
...
Mempool locking fixes
2019-12-03 12:35:57 +03:00