Commit graph

415 commits

Author SHA1 Message Date
Roman Khimov
db027ad9c5 vm: zero GAS means no GAS, use fee data to properly limit execution
We were accepting transactions with zero system fee, but we shouldn't do
that. Also, transaction's verification execution has to be limited by network
fee.
2020-07-14 08:37:29 +03:00
Anna Shaleva
abe3c94b95 core: use big.Int to store NEP5 balances
closes #1133
2020-07-09 13:26:39 +03:00
Roman Khimov
540a20c1c9 rpc/request: decode bytearray as base64, fix #1151
It's encoded in base64 now.
2020-07-07 22:35:03 +03:00
Anna Shaleva
1755ce10ac rpc: make getapplicationlog error more deterministic 2020-07-06 15:04:28 +03:00
Anna Shaleva
7b90ad9337 rpc: fix cosigner scope in CreateNEP5TransferTx
It should be the same as transaction's cosigner scope.
2020-07-06 11:03:21 +03:00
Anna Shaleva
966ad8a0b1 rpc: fix adding extra network fee to tx 2020-07-06 11:02:57 +03:00
Anna Shaleva
1880e96844 cli: fix contract deploy&invoke
We should add cosigners to deplyment and invocation transactions.
2020-07-06 10:01:14 +03:00
Evgenii Stratonikov
27b3054df4 transaction: set feePerByte on tx construction 2020-07-03 17:52:13 +03:00
Roman Khimov
4f8e4628dc cli/rpc: hide parameter encoding details for Invoke* calls
The script is passed as a hex string, but no one should care. The hash is a
hex-encoded LE value, but no one should care either. Hex might change to
base64, LE to BE, no one outside these functions should care about that.
2020-07-02 16:41:34 +03:00
Roman Khimov
0819583413 cli/rpc: test-invoke deployment script to get the system fee value
Fix #1134.
2020-07-02 16:41:31 +03:00
Roman Khimov
17ea6411a2 rpc/client: ensure compatibility with preview2 C# node for invoke*
It won't work with proper cosigners and the client must be compatible both
with neo-go and C# node. See neo/neo-modules#260 also.
2020-07-02 16:40:32 +03:00
Roman Khimov
cc95d559cc rpc/client: unify invoke* functions 2020-07-02 16:40:32 +03:00
Anna Shaleva
0aaaf7f787 *: switch from fixed8 to int64 in (Blockchain).CalculateClaimable 2020-06-29 21:40:54 +03:00
Anna Shaleva
73b630db9b *: switch from fixed8 to int64
Follow C# implementation, we have to marshall JSON Fixed8 fields without
taking into account decimals.
2020-06-29 21:39:27 +03:00
Evgenii Stratonikov
d550e539ba rpc: convert null value to a defaultT
Right now we convert it is unmarshaler into a float64(0)
so an error is supressed.
2020-06-27 12:15:29 +03:00
Evgenii Stratonikov
bed08d3f89 rpc/server: unify boolean flag handling
Implement (*Param).GetBoolean() for converting parameter to bool value.
It is used for verbosity flag and is false iff it is either zero number
or empty sting.
2020-06-27 12:13:06 +03:00
Evgenii Stratonikov
35f952e44f rpc/server: simplify errors handling during parameter parsing
Forward-ported from 2.x with some updates.
2020-06-27 12:11:21 +03:00
alexvanin
cfa0c6e0ad cli: update hardcoded script hashes for neo and gas contracts
Use LittleEndian as preferred way to encode script-hashes
2020-06-26 16:22:02 +03:00
Roman Khimov
ef5848b303
Merge pull request #1113 from nspcc-dev/fix-test-failures
Fix test failures
2020-06-26 09:21:27 +03:00
Roman Khimov
a187336830 rpc/server: fix error reporting in Start
This error message makes no sense when shutting down the server:
2020-06-25T19:29:53.251+0300    ERROR   failed to start RPC server      {"error": "http: Server closed"}

And ListenAndServer is documented to always return non-nil error one of which
is http.ErrServerClosed. This should also fix the following test failure:

==================
WARNING: DATA RACE
Read at 0x00c000254243 by goroutine 49:
  testing.(*common).logDepth()
      /usr/local/go/src/testing/testing.go:665 +0xa1
  testing.(*common).Logf()
      /usr/local/go/src/testing/testing.go:658 +0x8f
  testing.(*T).Logf()
      <autogenerated>:1 +0x75
  go.uber.org/zap/zaptest.testingWriter.Write()
      /go/pkg/mod/go.uber.org/zap@v1.10.0/zaptest/logger.go:130 +0x11f
  go.uber.org/zap/zaptest.(*testingWriter).Write()
      <autogenerated>:1 +0xa9
  go.uber.org/zap/zapcore.(*ioCore).Write()
      /go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/core.go:90 +0x1c3
  go.uber.org/zap/zapcore.(*CheckedEntry).Write()
      /go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/entry.go:215 +0x1e7
  go.uber.org/zap.(*Logger).Error()
      /go/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:203 +0x95
  github.com/nspcc-dev/neo-go/pkg/rpc/server.(*Server).Start()
      /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server.go:179 +0x5c5

Previous write at 0x00c000254243 by goroutine 44:
  testing.tRunner.func1()
      /usr/local/go/src/testing/testing.go:900 +0x353
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:913 +0x1bb

Goroutine 49 (running) created at:
  github.com/nspcc-dev/neo-go/pkg/rpc/server.initClearServerWithInMemoryChain()
      /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_helper_test.go:69 +0x305
  github.com/nspcc-dev/neo-go/pkg/rpc/server.initServerWithInMemoryChain()
      /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_helper_test.go:78 +0x3c
  github.com/nspcc-dev/neo-go/pkg/rpc/server.testRPCProtocol()
      /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:805 +0x53
  github.com/nspcc-dev/neo-go/pkg/rpc/server.TestRPC.func1()
      /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:793 +0x44
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:909 +0x199

Goroutine 44 (finished) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:960 +0x651
  github.com/nspcc-dev/neo-go/pkg/rpc/server.TestRPC()
      /go/src/github.com/nspcc-dev/neo-go/pkg/rpc/server/server_test.go:792 +0x5d
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:909 +0x199
==================
2020-06-25 19:35:27 +03:00
Evgenii Stratonikov
f66199c99f cli: hardcode NEO and GAS token info
Don't make extra network queries for already known contracts.
2020-06-25 17:21:26 +03:00
Evgenii Stratonikov
3e3781168d rpc/client: do not query contract for account if it is in the wallet 2020-06-25 17:21:26 +03:00
Roman Khimov
5251607fb7 transaction: s/txid/hash/ for JSON to match C# implementation
It uses `hash` for transactions now, but `txid` for application logs.
2020-06-24 10:43:58 +03:00
Roman Khimov
d81d826bfc core: fix Storage.Get to return Null when there is no value
Match C# implementation and fix state inconsistency at block 249920 of
preview2 testnet. Make our Go Storage.Get return nil and adapt
examples/tests.
2020-06-24 10:43:58 +03:00
Roman Khimov
e5f05790d5 core: cache standby validators in the Blockchain
They never change, so it makes no sense parsing the keys over and over
again. It also simplifies the interface a little.
2020-06-24 10:22:17 +03:00
Roman Khimov
c124d2bcdf core: fix gas generation coefficients to match Neo 3
Follow neo-project/neo#911. Fixes state differences at block 4528 of preview2
testnet compared to C# node.
2020-06-24 10:21:24 +03:00
Roman Khimov
2f8e7e4d33 native: fix getvalidators to match C# implementation
ValidatorsCount is not initialized at block 0 with C# node (the first voter
initializes it) and until that initialization happens the standby validators
list is being returned as is without sorting.

Fixes state mismatch for the key ffffffff0e00000000000000000000000000000001 in
the first blocks.

It also affects tests as now the first validator is different and it receives
the network fees.
2020-06-24 10:21:24 +03:00
Roman Khimov
0fdeafb8f7
Merge pull request #1058 from nspcc-dev/neo3/smartcontract/policy
core: add native policy contract
2020-06-24 09:37:29 +03:00
Anna Shaleva
b88863948d rpc: add native policy API to RPC client
part of #904
2020-06-24 07:58:09 +03:00
Anna Shaleva
65c1ce4f6a rpc: add GetStorageByID RPC client method
Should be a part of #1077
2020-06-23 17:31:22 +03:00
Anna Shaleva
f1cdcbc99c core: store smartcontract items by id
closes #1037
2020-06-19 20:48:45 +03:00
Evgenii Stratonikov
3787a8895e rpc: marshal GasConsumed getapplicationlog as string
Also there is no more decimal point.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
3a0be5ce28 rpc: allow to invoke getapplicationlog with block hash
Support retrieving native contract persist results by block hash.
All necessary support is already here, just add test.
2020-06-19 11:38:56 +03:00
Evgenii Stratonikov
c0e482fe6c rpc: restructure getapplicationlog response
Move VM-related fields to top-level.
2020-06-19 11:38:56 +03:00
Roman Khimov
93b0011988
Merge pull request #1069 from nspcc-dev/addr-locking-and-other-fixes
Addr, locking and other fixes
2020-06-18 23:29:19 +03:00
Evgenii Stratonikov
5354352d63 core: remove transaction priority
There is no such thing as high/low priority transactions, as there are
no free transactions anymore and they are ordered by fees contained
in transaction itself.

Closes #1063.
2020-06-18 22:44:10 +03:00
Roman Khimov
1081791c68 core: fix contract manifest unpacking in System.Contract.Create
It's just JSON, io.Serializable is only used for DB storage where the length
should be obtained from the stream. Fixes:

2020-06-18T22:14:10.571+0300    WARN    contract invocation failed      {"tx": "1ffd475a9c246495d6206cb80a9a78e9d14a433ded60cd37aa87d897655606e1", "block": 25893, "error": "error encountered at instruction 3696 (SYSCALL): failed to invoke syscall: invalid character ':' after top-level value"}
2020-06-18 22:38:34 +03:00
Evgenii Stratonikov
8a0b2be285 core: process NEP5 transfers emitted by Native.onPersist
All GAS is minted/burnt during `onPersist` call.
2020-06-18 16:38:08 +03:00
Evgenii Stratonikov
c9df5d3aed rpc: fix typo in getnep5transfers rpc
Omit empty address for transfers in both directions.
2020-06-18 16:31:33 +03:00
Evgenii Stratonikov
295d8fc70e core: save application logs for native persist 2020-06-18 15:32:27 +03:00
Roman Khimov
b483c38593 block/transaction: add network magic into the hash
We make it explicit in the appropriate Block/Transaction structures, not via a
singleton as C# node does. I think this approach has a bit more potential and
allows better packages reuse for different purposes.
2020-06-18 12:39:50 +03:00
Roman Khimov
8fda6a3407 block: fix ConsensusData hashing
It's DoubleSha256 as with the rest of the structures.
2020-06-18 12:22:49 +03:00
Roman Khimov
5fe8287fbb rpc: use non-pointer Block and Transaction in results
Pointers can be nil and in some cases it's important to always have access to
Block or Transaction fields.
2020-06-18 12:13:35 +03:00
Roman Khimov
d22286cbbc client/cli: add network option to the RPC client
It doesn't affect anything yet, but it's going to be used in the future for
network-specific behavior. It also renames short '--timeout' form to '-s'
avoiding conlict with '-t' used for '--testnet'.
2020-06-18 12:11:13 +03:00
Roman Khimov
26f11a52d9 config: move NetMode into its own micropackage
It's going to be used a bit more and pulling whole config just for one type is
a bit wrong.
2020-06-18 12:09:57 +03:00
Roman Khimov
5f276de003
Merge pull request #1057 from nspcc-dev/fix/newaddress
Update addresses to NEO3 format
2020-06-17 16:25:32 +03:00
Evgenii Stratonikov
7b4ca57e33 *: change address to the new format
NEO3 uses new prefix for address (53 = 0x35), thus string representations as
well as encrypted WIFs should be changed.
2020-06-17 15:58:21 +03:00
Evgenii Stratonikov
a7d4fff897 vm: make (*VM).GasLimit public
VM is inherently single-threaded and replacing setter/getter methods
with public field simplifies code a bit.
2020-06-16 15:13:20 +03:00
Evgenii Stratonikov
ad2a75a500 core: move System.ExecutionEngine.* interops to System.Runtime.* 2020-06-16 12:30:55 +03:00
Anna Shaleva
3568ab3d6d core: add json marshaller for Cosigner's scopes
Following C# implementation, we should marshal Scopes as a set of
strings instead of single byte.
2020-06-15 13:48:15 +03:00