Commit graph

854 commits

Author SHA1 Message Date
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
ca542f11fe core: drop unused secondsPerBlock() method 2020-08-11 21:37:18 +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
057e1c6e3c compiler: provide filename to Compile() 2020-08-11 11:10:45 +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
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
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
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
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
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
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
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
Roman Khimov
57ee8b80e5
Merge pull request #1246 from nspcc-dev/protocol/getblockbyindex
protocol: request blocks by index
2020-08-05 23:21:07 +03:00
Roman Khimov
b7f89b0544 core: restrict verification scripts with CallFlags.None
Follow neo-project/neo#1776. Looks very suspicious to me as it severely limits
verification scripts, but we have to be compatible at this point.
2020-08-05 19:17:48 +03:00
Evgenii Stratonikov
194da64975 core: deepcopy notification in System.Runtime.Notify
Make it impossible to change already emitted notifications via
`System.Runtime.GetNotifications`.
2020-08-05 11:19:41 +03:00
Roman Khimov
ef53a45e7a
Merge pull request #1264 from nspcc-dev/smartcontract/manifest/supported_standards
smartcontract: add list of supported standards to manifest
2020-08-04 22:17:00 +03:00
Anna Shaleva
7c6cdcbcc9 core: fix bug with policy.MaxVerificationGas
In 121c9664b we should take into account isValid flag of
NativePolicy contract while retrieving MaxVerificationGas native
policy value. Otherwise we won't be able to get MaxVerificationGas
after the node was restarted, because this value is not truly
stored along with the other native policy values.

This commit fixes bug with headers verification after the  node
restarting with an existing storage:

```
2020-08-03T12:52:56.158+0300	WARN	failed processing headers	{"error": "vm failed to execute the script with error: error encountered at instruction 0 (PUSHDATA1): gas limit is exceeded", "errorVerbose": "vm failed to execute the script with error: error encountered at instruction 0 (PUSHDATA1): gas limit is exceeded\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHashAgainstScript\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1454\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeaderWitnesses\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1517\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeader\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:1175\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:484\ngithub.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddHeaders\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/core/blockchain.go:453\ngithub.com/nspcc-dev/neo-go/pkg/network.(*Server).handleHeadersCmd\n\t/home/neospcc/Documents/GitProjects/nspcc-dev/neo-go/pkg/network/server.go:454\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1373"}
```
2020-08-04 17:52:34 +03:00