Commit graph

124 commits

Author SHA1 Message Date
Evgenii Stratonikov
54e0b5a4a7 rpc: set MaxGasInvoke in config
Implement ability to restrict maximum amount of GAS
available for free RPC calls.
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
4718375db1 rpc: return amount of consumed GAS in invoke* 2020-01-22 14:31:57 +03:00
Roman Khimov
ea3b76ded1 network: make NewServer return an error, fix #612
It can return nil in two cases, so we're better return an error and handle
it.
2020-01-22 11:17:51 +03:00
Roman Khimov
32213b1454
Merge pull request #601 from nspcc-dev/refactoring/core
core: refactor out Block, BlockBase and Header, closes #597.
2020-01-20 16:19:20 +03:00
Roman Khimov
46b82b4fb5 keys: don't return error from PrivateKey.Sign
As it can't ever happen.
2020-01-17 17:00:30 +03:00
Evgenii Stratonikov
489b88afbb block: rename BlockBase to Base 2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
63c56cca5c core: refactor out Block, BlockBase and Header structs
See #597.
2020-01-16 10:16:24 +03:00
Roman Khimov
b5f234ddef rpc: make rpc request logging at Debug level
Makes no sense polluting logs with Info. It also affects benchmarking.
2020-01-13 17:33:29 +03:00
Evgenii Stratonikov
9dc5571327 core,rpc: close Blockchain in tests
If blockchain is not closed, logging in defer can occur
after test has finished, which will lead to a panic with
"Log in goroutine after Test* has completed".
2020-01-10 11:47:56 +03:00
Evgenii Stratonikov
45a4524054 rpc: remove EnableCORSWorkaround from Request 2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
289cb1c1d9 rpc: use zap.Logger 2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
aecdf470e7 cli,pkg: use zap.Logger 2020-01-10 11:14:27 +03:00
Roman Khimov
9145855d2c
Merge pull request #579 from nspcc-dev/refactor-crypto
This moves some functionality into micro-packages, improves testing,
unexports some code and fixes bugs along the way.
2019-12-25 18:12:50 +03:00
Roman Khimov
b246653f62 address: rename functions as per #579 comments
Make them more clear to understand.
2019-12-25 17:34:18 +03:00
Roman Khimov
e685e9bf9a address: move into its own package
Doesn't really belong to the crypto.
2019-12-25 15:22:02 +03:00
Vsevolod Brekelov
606616618f rpc: add ability to answer as C# with block as []byte 2019-12-25 01:44:37 +03:00
Evgenii Stratonikov
884779e501 *: goimports 2019-12-17 14:51:28 +03:00
Roman Khimov
54d888ba70 io: add type-specific read/write methods
This seriously improves the serialization/deserialization performance for
several reasons:
 * no time spent in `binary` reflection
 * no memory allocations being made on every read/write
 * uses fast ReadBytes everywhere it's appropriate

It also makes Fixed8 Serializable just for convenience.
2019-12-12 20:19:50 +03:00
Vsevolod Brekelov
2d42b14a1d core: renames entities-> state and removed State prefix 2019-12-11 13:14:18 +03:00
Vsevolod Brekelov
ec17654986 core: refactoring blockchain state and storage
add dao which takes care about all CRUD operations on storage
remove blockchain state since everything is stored on change
remove storage operations from structs(entities)
move structs to entities package
2019-12-11 13:05:31 +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
3898aadcec rpc: simplify uint160 handling
Use new Uint160DecodeStringLE() function.
2019-12-06 19:47:58 +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
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
bc5beb438f *: gofmt
Somehow these crept into the repository.
2019-12-02 10:10:50 +03:00
Roman Khimov
dccf440dca rpc: skip input/outputs mangling if no gas is attached to invocation 2019-11-29 18:00:08 +03:00
Roman Khimov
8a5ac12df8 rpc: make generic SignAndPushInvocationTx out of DeployContract
SignAndPushInvocationTx() is gonna be used for more than just deploying
contracts.
2019-11-29 17:59:07 +03:00
Roman Khimov
127f8418c8 rpc: refactor out runScriptInVM() from invokers 2019-11-28 19:13:58 +03:00
Roman Khimov
e216139108 rpc: implement server-side 'invoke' method, fix #346 2019-11-28 19:08:31 +03:00
Roman Khimov
d04bc0cbe3 rpc: add marshaler for StackParamType
Makes stack output look better, no one cares about numbers.
2019-11-27 13:00:11 +03:00
Roman Khimov
3843451ec4 rpc: fix potential getblock handling problem, add a test for it
It should only accept hex strings and numbers, anything else is wrong.
2019-11-27 13:00:11 +03:00
Roman Khimov
1c883cc819 rpc: add invokescript tests 2019-11-27 13:00:11 +03:00
Roman Khimov
cf39171485 rpc: implement invokefunction, fix #347
Param getters were redone to return errors because otherwise bad FuncParam
values could lead to panic. FuncParam itself might be not the most elegant
solution, but it works good enough for now.
2019-11-27 13:00:11 +03:00
Roman Khimov
ea9bc22510
Merge pull request #513 from nspcc-dev/feat/rpc_param
This PR does 3 things:

    adds array parameter unmarshalling
    extend Param with convenient methods
    refactor tests into using tables to make it easier add new tests

(part of #347 solution)
2019-11-22 18:47:59 +03:00
Evgenii Stratonikov
c9d5f8b89c rpc: cover stack_param with more tests
Use require/assert instead of builtin facilities.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 13:20:15 +03:00
Evgenii Stratonikov
0f9024d177 rpc: make client default values constants
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:10 +03:00
Evgenii Stratonikov
3afcd784f0 rpc: refactor tests
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:07 +03:00
Evgenii Stratonikov
d5fa31cecd rpc: trim spaces in tests once
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:57:03 +03:00
Evgenii Stratonikov
c8987eda32 rpc: add array param type and tests
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:56:58 +03:00
Evgenii Stratonikov
7331127556 rpc: make parameter type an enum
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2019-11-22 12:56:49 +03:00
Roman Khimov
aae3e217a8 rpc/cli: implement contract deployment, fix #474
It's used like this:
./bin/neo-go contract deploy -i 1-print.avm -c neo-go.yml -e http://localhost:20331 -w KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr -g 100
2019-11-20 16:12:40 +03:00
Roman Khimov
310104667d rpc: refactor out reusable parts of CreateRawContractTransaction()
Signing and inputs/outputs management is common for different transactions, so
make separate functions for them.
2019-11-20 16:12:40 +03:00
Roman Khimov
7d89ccdb6f rpc: implement YAML marshaling/unmarshaling for StackParamType 2019-11-20 16:12:40 +03:00
Roman Khimov
d93499cc6f rpc: implement CalculateInputs for RPC client
Using getunspents RPC call.
2019-11-20 16:12:40 +03:00
Roman Khimov
826a29cc98 rpc: implement client-side getunspents 2019-11-20 16:12:40 +03:00
Roman Khimov
29882b076c rpc: remove duplicating definition of UTXO
Port sorting methods to core.
2019-11-19 17:35:04 +03:00
Roman Khimov
5841d3931e rpc: implement getunspents method, fix #473 2019-11-18 11:30:09 +03:00