Roman Khimov
52b002e079
Merge pull request #1332 from nspcc-dev/check-for-excessive-verification-results
...
core: verification script must return exactly one value
2020-08-18 12:15:10 +03:00
Evgenii Stratonikov
a080d24cf5
vm: fix debugger and add tests
...
1. `Run()` must be able to continue execution after a breakpoint.
2. VM must stop right before the breakpoint, not after.
3. Initial vm state is NONE, not HALT.
2020-08-18 11:26:27 +03:00
Evgenii Stratonikov
8659fd79e5
vm: add tests for ByteString enumerator/iterator
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
6bdaefcfa4
rpc/client: use CreateTxFromScript
where possible
...
There is substantial overlap between `CreateTxFromScript` and
`SignAndPushInvocationTx`. This commit refactors both of them
to reuse common code.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
16b10ab918
rpc/client: drop (*Client).wif
...
It isn't used internally and has no value.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
316666cc22
rpc/client: add tests for Ping
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
48f1502167
rpc/client: add tests for SignAndPushInvocationTx
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
2699508914
wallet: emit proper multisignature
...
In case when a signature needs to be added to multisig
we must first find corresponding signer, not append new witness.
2020-08-18 11:24:48 +03:00
Evgenii Stratonikov
8699a4c1a9
rpc/client: provide scripts in AddNetworkFee
...
To calculate network fee properly we must know type of every
signer (simple, multisig, contract). Providing scripts is the most
simple and flexible way to know this.
2020-08-18 11:24:48 +03:00
Anna Shaleva
591f639ad6
core: fix getOnPersistWrapper for native contracts
...
According to manifest, OnPersist.ReturnType is void, so we shouldn't
return anything from it. It's not so important, as we drop this value at
the end of OnPersist invocation.
2020-08-18 09:52:46 +03:00
Roman Khimov
d0c29f52c9
core: verification script must return exactly one value
...
C# node is quite picky as it expects there to be exactly one value returned,
but our testchain actually adds 4 signatures for multisig cases instead of 3
which makes it technically incompatible with C# node.
2020-08-17 22:02:15 +03:00
Roman Khimov
58af143f25
Merge pull request #1326 from nspcc-dev/fix-block-synchronization
...
Fix block synchronization
2020-08-15 20:19:59 +03:00
Roman Khimov
8e619cc671
Merge pull request #1318 from nspcc-dev/fix/verifytests
...
Add tests for `verifyTx` and `verifyHeader`
2020-08-14 17:24:03 +03:00
Roman Khimov
8d19f0e6f5
network: don't request block we already have
...
GetBlockByIndex handler starts sending blocks right from the start index and
if that index is s.chain.BlockHeight() then we're requesting and receiving a
block we already have.
2020-08-14 16:25:13 +03:00
Roman Khimov
c8cc91eeee
network: request blocks when there is a ping with bigger than ours height
...
Turns out, C# node no longer broadcasts an Inv when it's creating a block,
instead it sends a ping and if we're not paying attention to the height
specified there we're technically missing a new block. Of course we'll get it
later after ping timer expiration and regular ping/pong sequence, but that's
delaying it for no good reason.
2020-08-14 16:22:15 +03:00
Roman Khimov
92f37a5d36
Merge pull request #1324 from nspcc-dev/fix-goreportcard-issues
...
Fix goreportcard issues
2020-08-14 14:50:35 +03:00
Roman Khimov
40bcd4c0bc
Merge pull request #1231 from nspcc-dev/fix/printops
...
vm: pretty-print remaining opcodes
2020-08-14 14:43:29 +03:00
Evgenii Stratonikov
b2e53fedac
vm: pretty-print SYSCALL opcode
2020-08-14 14:22:46 +03:00
Evgenii Stratonikov
a796f2b61d
names: implement FromID
...
Allow to convert interop id to it's name.
2020-08-14 14:22:45 +03:00
Evgenii Stratonikov
7854dcfd8f
core: replace interop names with named constants
2020-08-14 14:21:54 +03:00
Evgenii Stratonikov
f3650e20b0
vm: move InteropNameToID to a separate package
2020-08-14 13:54:11 +03:00
Roman Khimov
e7d13e6db2
*: fix misspellings found in Go Report Card
2020-08-14 12:16:24 +03:00
Roman Khimov
f6a308f7f6
*: fix ineffassign where the value should really be used
...
Found with GoReportCard.
2020-08-14 12:08:57 +03:00
Roman Khimov
ec2a2f3fb9
transaction: fix ineffassign GoReportCard issue
...
s is not used purposefuly.
2020-08-14 12:08:16 +03:00
Roman Khimov
70cc8b89e8
Merge pull request #1323 from nspcc-dev/fix/clienttests
...
rpc: fix (*Client).BalanceOf
2020-08-14 11:54:36 +03:00
Evgenii Stratonikov
a8cda69bc3
rpc: fix (*Client).BalanceOf
...
Add missing argument and write tests.
2020-08-14 11:19:24 +03:00
Evgenii Stratonikov
cadebdfc19
core: add tests for (*Blockchain).verifyHashAgainstScript
2020-08-14 09:40:36 +03:00
Evgenii Stratonikov
1eb9a4c6c6
core: allow to use verification contracts
...
In NEO3 we can't just appcall hash, as verification script has no access
to state. Instead we use `verify` method of an arbitrary contract.
2020-08-14 09:40:34 +03:00
Evgenii Stratonikov
7f2a931fb6
core: add tests for (*Blockchain).verifyHeader
2020-08-14 09:37:32 +03:00
Evgenii Stratonikov
e8cf4d96ce
core: add tests for (*Blockchain).verifyTx
2020-08-14 09:37:30 +03:00
Roman Khimov
bf090a436b
Merge pull request #1315 from nspcc-dev/debugger-compatibility-fixes
...
Debugger compatibility fixes, part 2
2020-08-13 18:23:38 +03:00
Anna Shaleva
0834661cac
rpc: marshal getapplicationlog
stack as []stackitem.Item
...
Following https://github.com/neo-project/neo-modules/issues/318
2020-08-13 17:16:31 +03:00
Anna Shaleva
9456f729be
compiler: generate methods names with lowercased first letter
...
Methods names from debuginfo should match methods names from manifest.
Original method names are stored in ID field.
2020-08-13 13:28:20 +03:00
Anna Shaleva
3c170271c4
compiler: provide namespace for events names
...
For proper NEO3 debugger work we should provide namespaces for events
names in .debug.json files. But we don't have namespaces in .yml
configuration files and don't need this information for .manifest.json
generation, so let's just keep namespaces empty. This do not prevents
debugger from accepting our .debug.json files.
2020-08-13 10:44:46 +03:00
Evgenii Stratonikov
9cc6e22365
vm: pretty-print ST*/LD* opcodes
2020-08-13 10:38:13 +03:00
Evgenii Stratonikov
7d08d38cd2
vm: pretty-print PUSHINT* opcodes
2020-08-13 10:38:13 +03:00
Evgenii Stratonikov
92ddc474d8
vm: pretty-print CONVERT and ISTYPE opcodes
2020-08-13 10:38:13 +03:00
Roman Khimov
95d86b67c3
Merge pull request #1311 from nspcc-dev/debugger-compatibility-fixes
...
Debugger compatibility fixes
2020-08-12 18:42:18 +03:00
Anna Shaleva
44aefe76b4
compiler: add events to debuginfo from .yml config
2020-08-12 17:48:03 +03:00
Anna Shaleva
bcb7b9ba63
smartcontract: rename parameter ByteString to ByteArray
...
Debugger expects it to be ByteArray. C# compiler also compiles it
as `ByteArray` (in both manifest and debug.json).
The previous commit 6a2161207a
changed
this line as C# implementation serializes Blockchain.ApplicationExecuted.Stack
as array of stackitem.Item and deserializes it as array of
smartcontract.Parameter.
2020-08-12 17:48:03 +03:00
Roman Khimov
7bf0ae11db
Merge pull request #1309 from nspcc-dev/fix-yaml-import-path
...
*: use proper YAML library import path, fix #1306
2020-08-12 17:15:37 +03:00
Roman Khimov
292c186665
*: use proper YAML library import path, fix #1306
2020-08-12 16:31:06 +03:00
Roman Khimov
ca542f11fe
core: drop unused secondsPerBlock() method
2020-08-11 21:37:18 +03:00
Roman Khimov
b31e18096f
rpc/client: remove obsolete retry from invokeSomething()
...
All preview3 nodes have proper support for scoped signers in parameters.
2020-08-11 21:21:38 +03:00
Roman Khimov
acc2265169
transaction: attribute type is now type, not usage
2020-08-11 21:10:50 +03:00
Roman Khimov
fb70c82157
transaction: there are no valid attributes defined for preview3
2020-08-11 21:10:12 +03:00
Roman Khimov
b1034d8ed6
state: drop Neo 2 Account and everything related
...
It's substituted with NEP5Balances now.
2020-08-11 20:42:02 +03:00
Roman Khimov
34156ef78d
core: fix (*HeaderHashList).Write comment
2020-08-11 20:33:16 +03:00
Roman Khimov
2354af463a
core: drop some unused HeaderHashList functions
2020-08-11 20:33:16 +03:00
Roman Khimov
08fd6180b2
native: drop validators count structure
...
It's not used since #1252 .
2020-08-11 20:19:55 +03:00
Roman Khimov
c3f7a419a0
Merge pull request #1296 from nspcc-dev/smartcontract/examples
...
examples: update examples
2020-08-11 19:09:13 +03:00
Anna Shaleva
b5494320f9
compiler, cli: support events from .yml config file
...
We currently can't process events in codegen, so we have to provide
them via .yml config file. Do not delete the rest of the code connected
with conversion of MethodDebugInfo.Event into manifest.Event as we have
issue #1038 .
2020-08-11 13:42:06 +03:00
Evgenii Stratonikov
a34ba92d46
compiler: allow to split main package across multiple files
2020-08-11 11:12:55 +03:00
Evgenii Stratonikov
553e57c2c4
compiler: make sequence points on global var/const declarations
2020-08-11 11:12:30 +03:00
Evgenii Stratonikov
128626de5c
compiler: save sequence points for init
function
2020-08-11 11:12:30 +03:00
Evgenii Stratonikov
40fa7c0f6e
compiler: emit all used files in DebugInfo.Documents
2020-08-11 11:12:29 +03:00
Evgenii Stratonikov
057e1c6e3c
compiler: provide filename to Compile()
2020-08-11 11:10:45 +03:00
Anna Shaleva
5ef6d4d857
consensus: add test for payload.Verify
...
Closes #1178
2020-08-10 22:03:33 +03:00
Roman Khimov
25ce154cf8
Merge pull request #1300 from nspcc-dev/various-preview3-fixes
...
Various preview3 testnet fixes
2020-08-10 21:49:30 +03:00
Roman Khimov
c16040aecc
native: sort GetValidators result
...
As it's returned sorted now. Fixes state change mismatch for
NextValidators. It also partially reverts
2f8e7e4d33
and significantly changes the test
chain as the fees are no longer being sent to the same account.
2020-08-10 19:49:09 +03:00
Roman Khimov
dba248236c
smartcontract: add CreateDefaultMultiSigRedeemScript
...
And use it where appropriate. Some of our code was just plain wrong (like the
one in GAS contract) and unification is always useful here.
2020-08-10 18:58:11 +03:00
Roman Khimov
80302c5c07
consensus: use dbft.M() for new block witness
...
We're collecting dbft.M() number of signatures in getBlockWitness(), so we
should use the same value for M here.
2020-08-10 18:49:48 +03:00
Evgenii Stratonikov
f2cb1d5f02
compiler: use constants in interops
...
We now support using exported constants, so there is no
need in declaring functions. All functions from `interop/`
are not to be compiled.
Fix #1298 .
2020-08-10 17:52:31 +03:00
Roman Khimov
fb97ea9458
native: don't register standby validators on initialization
...
C# doesn't do that since neo-project/neo#1762 .
2020-08-10 17:51:46 +03:00
Roman Khimov
6e252fbaae
rpc: answer with zero-length when there are no registered validators
...
There is a huge difference between
"result" : [],
and
"result" : null,
2020-08-10 17:50:19 +03:00
Roman Khimov
f287681fa7
core/native: fix VotersCount zero value encoding
...
Empty byte array is enough to be bigint value of zero. Fixes state differences
with C# node.
2020-08-10 17:07:14 +03:00
Roman Khimov
5a42b5c7ae
network: correct block addition check
...
Fixes missing an error on block addition when the header actually went it, but
the block didn't.
2020-08-10 16:51:56 +03:00
Evgenii Stratonikov
bf01599430
vm: check return value on context unload
...
When calling external contracts we expect exactly 1 value to be on
stack. For methods returning nothing, `Null` value is pushed, otherwise
it is an error.`
2020-08-10 11:52:33 +03:00
Evgenii Stratonikov
bbae7318a5
smartcontract: adjust param types according to NEO3
2020-08-10 11:14:48 +03:00
Evgenii Stratonikov
b65369e111
emit: remove unused functions
2020-08-10 11:14:48 +03:00
Roman Khimov
4aeaf05f90
Merge pull request #1289 from nspcc-dev/fix/nep5
...
Port `getnep5transfers` changes to master
2020-08-10 11:11:24 +03:00
Evgenii Stratonikov
14aba7fc80
core: fix failing tests after merge
...
Related f5131491b
.
2020-08-10 09:20:34 +03:00
Roman Khimov
f5131491b7
Merge pull request #1271 from nspcc-dev/core/call_from_native
...
core: contractCall from native contracts
2020-08-07 21:24:50 +03:00
Anna Shaleva
c87e2262c3
core: remove ScriptHashGetter from interop context
...
We have VM inside the context, so don't need ScriptHashGetter anymore.
2020-08-07 20:31:20 +03:00
Anna Shaleva
42736095a1
core: add test to call contract from native
...
Closes #1200
2020-08-07 20:31:16 +03:00
Evgenii Stratonikov
412fc53cdd
rpc: provide timestamps in getnep5transfers
...
Set default value for the first timestamp to a week ago.
2020-08-07 18:42:34 +03:00
Evgenii Stratonikov
807338f97e
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-07 18:21:06 +03:00
Anna Shaleva
995053f2eb
core: add VM into interop context
2020-08-07 16:15:24 +03:00
Roman Khimov
c3c88a57cd
Merge pull request #1281 from nspcc-dev/drop-go-1.12-and-fix-some-things
...
Drop go 1.12 and fix some things
2020-08-07 13:34:54 +03:00
Roman Khimov
d5a9d80c12
core: refactor out policy check for transaction
...
We were checking blocked accounts twice which is obviously excessive. We also
have our accounts sorted, so we can rely on that in CheckPolicy(). It also
doesn't make much sense to check MaxBlockSystemFee in Blockchain code, policy
contract can handle that.
2020-08-07 12:21:52 +03:00
Roman Khimov
90180c6fb6
native: pass DAO to CheckPolicy(), it doesn't need interop context
...
Simplify things a bit.
2020-08-07 12:21:52 +03:00
Roman Khimov
791c983304
core: drop GetScriptHashesForVerifying
...
It no longer depends on blockchain state and there can't ever be an error, in
fact we can always iterate over signers, so copying these hashes doesn't make
much sense at all as well as sorting arrays in verifyTxWitnesses (witnesses
order must match signers order).
2020-08-07 12:21:52 +03:00
Roman Khimov
c19838ea67
core: use errors.Is in PoolTx
...
Just in case.
2020-08-07 12:21:52 +03:00
Roman Khimov
4c38fae54c
core: fix mempool error check in PoolTx
...
ErrAlreadyExists should be returned for ErrDup, not ErrConflict.
2020-08-07 12:21:52 +03:00
Roman Khimov
0e2784cd2c
always wrap errors when creating new ones with fmt.Errorf()
...
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.
Fix #350 .
2020-08-07 12:21:52 +03:00
Roman Khimov
205f52c563
core: use error wrapping to provide more details
2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae
remove github.com/pkg/errors from dependencies
...
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Evgenii Stratonikov
bfda60c683
native: add missing witness checks to NEO.(Un)registerCandidate
2020-08-07 09:17:02 +03:00
Evgenii Stratonikov
8af3f05358
native: implement NEO.UnregisterCandidate
method
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
38a92323c9
native: fill votes when registering unregistered candidate
...
If a candidate was registered, then unregistered and then again
registered, it's votes must not be lost.
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
27169d140f
core: implement (*Blockchain).GetStandByCommitee()
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
05c24d9401
cli: support voting
...
Closes #1206 .
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
a3f419f8df
emit: allow to emit Null
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
e5d973d3a4
config: rename StandbyValidators to StandbyCommittee
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
b14b047c78
native: add tests for delegated voting
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
9bc731b3b1
native: implement delegated voting
...
Close #867 .
2020-08-06 20:39:13 +03:00
Evgenii Stratonikov
f0b62cdaa6
native: make *totalSupply accept DAO
...
There is no need to provide full interop context.
2020-08-06 14:26:24 +03:00
Evgenii Stratonikov
3e39f0f211
native: rename Validator to Candidate
2020-08-06 14:26:24 +03:00
Roman Khimov
e1d3223505
Merge pull request #1247 from nspcc-dev/feature/pointers
...
Support pointers in compiler
2020-08-06 13:53:08 +03:00
Roman Khimov
5e53aceb0f
Merge pull request #1277 from nspcc-dev/restrict-verification-call-flags
...
core: restrict verification scripts with CallFlags.None
2020-08-06 13:52:14 +03:00