Commit graph

322 commits

Author SHA1 Message Date
Roman Khimov
36b5751262
Merge pull request #1665 from nspcc-dev/nefstate
Store NEF in contract state
2021-01-14 10:14:38 +03:00
Evgeniy Stratonikov
0b26b46234 state: store NEF instead of script for contract
NEFs for native contracts are set statically, thus
field values are taken from the reference implementation.
2021-01-13 15:34:10 +03:00
Roman Khimov
524bf9aaa0 native: swap oracle and role management init
Role management doesn't need oracles, but oracles do need role management. See
neo-project/neo#2187.
2021-01-12 21:27:42 +03:00
Roman Khimov
ca86b78536
Merge pull request #1622 from nspcc-dev/nativenames
native: update contract names
2021-01-12 20:59:10 +03:00
Roman Khimov
4fa1476c03 native: use Hash160 method parameters where appropriate
Partially reverts 33386065bc, see
neo-project/neo#2183.
2021-01-12 18:08:12 +03:00
Evgenii Stratonikov
33b926586a native: update contract names
Follow https://github.com/neo-project/neo/pull/2152 .
2021-01-12 17:58:05 +03:00
Anna Shaleva
c13382e27d core: fix (*NEO).getCandidates
Don't need to pay attention to key prefix while sorting.
2020-12-25 17:03:05 +03:00
Anna Shaleva
bc3f8a3b48 core: fix (*NEO).computeCommitteeMembers
In (*NEO).computeCommitteeMembers we return standbyCommittee in case
if there's not enought candidates. But there can be standby committee
members among candidates, so we need to fill in known votes.
2020-12-24 12:47:42 +03:00
Anna Shaleva
33386065bc core: adjust parameters of native methods
This commit is mostly about Hash160 -> ByteArray for native contracts'
methods. Manifest is included into states, so we need to be compatible.
2020-12-23 11:18:44 +03:00
Anna Shaleva
e40f3610ed core: store MinimumDeploymentFee as uint32 2020-12-22 16:09:16 +03:00
Anna Shaleva
b1324db847 core: add notifications to ManagmentContract 2020-12-18 16:52:51 +03:00
Anna Shaleva
d34353aec2 core: add MinimumDeploymentFee 2020-12-18 16:48:05 +03:00
Anna Shaleva
a65544aab1 core: fix Managment destroy price
Too expensive.
2020-12-18 16:46:09 +03:00
Evgenii Stratonikov
3397f2c9be native: cache contract in Management contract 2020-12-18 13:11:17 +03:00
Anna Shaleva
31b06907c9 core: restrict allowed Oracle callbacks 2020-12-17 11:41:28 +03:00
Evgenii Stratonikov
62da365302 native: allow to modify StoragePrice in the policy contract 2020-12-16 13:55:40 +03:00
Evgenii Stratonikov
4946556830 native: allow to modify ExecFeeFactor in the policy contract 2020-12-16 13:55:40 +03:00
Evgenii Stratonikov
1840c1c80d core: redefine opcode prices
Prices are defined in as a coefficients to `BaseExecFee` which
is defined by Policy contract (TBD later).
Native method prices are defined without need to multiply.
2020-12-16 13:55:39 +03:00
Evgenii Stratonikov
dda4ba8d4d native: add compatibility test for hashes 2020-12-15 12:58:04 +03:00
Evgenii Stratonikov
1ffa1f9ade native: fix contract hashes 2020-12-15 12:58:04 +03:00
Evgenii Stratonikov
5310c7f3ce native: fix NEP17.Transfer cost
It was increased with the introducion of `postTransfer`.
2020-12-15 12:04:10 +03:00
Roman Khimov
cb5ecaefe7 native: drop OnPersistEnd
Now that PostPersist is being run for every native contract we can do our
dirty caching tricks right there instead of OnPersistEnd.
2020-12-14 15:24:15 +03:00
Roman Khimov
cf8cf93e7a native: change contract names, move them to separate package
Follow neo-project/neo#2138 and make RPC client's GetNativeContractHash
case-sensitive.
2020-12-14 15:24:15 +03:00
Roman Khimov
aff1469482 native: uppercase token symbols
Follow neo-project/neo#2136.
2020-12-14 15:24:15 +03:00
Roman Khimov
1e9253f1f0 interop: rename Neo.Native.Call to System.Contract.CallNative 2020-12-14 15:24:13 +03:00
Roman Khimov
ab12eee346 native: move contract deployment to management contract
See neo-project/neo#2119.
2020-12-14 15:23:46 +03:00
Roman Khimov
ad3547783d native: drop Neo.Native.Deploy, move contract init to management contract
The contract is almost a stub at the moment, though it does deploy other
contracts.
2020-12-14 13:33:41 +03:00
Roman Khimov
090bee8624 native: change OnPersist/PostPersist handling
Every contract now has these and they're always invoked. See
neo-project/neo#1913 and neo-project/neo#2119.
2020-12-13 21:36:06 +03:00
Anna Shaleva
2290b91b83 core: fix verification call flag
Previous commit sets AllowCall flag as required for Neo.Native.Call, but
invocation script was loaded with ReadStates flag => native contracts
verification failed.

Other contracts can also make use of AllowCall call flag.
2020-12-11 17:45:12 +03:00
Anna Shaleva
53e45d793b core: adjust call flags 2020-12-11 11:38:14 +03:00
Anna Shaleva
fadbae8997 core: rename call flags
Also new States flag is added and ReadOnly flag is adjusted.
2020-12-11 10:34:01 +03:00
Anna Shaleva
0b5cf78468 network: add notary request payload 2020-12-10 18:17:31 +03:00
Evgenii Stratonikov
e903e40085 core: call from native contracts synchronously
Follow neo-project/neo#2130.
2020-12-10 16:43:46 +03:00
Roman Khimov
02457d9f77
Merge pull request #1597 from nspcc-dev/fix/safemethods
manifest: add `Safe` flag to method descriptor
2020-12-09 16:32:19 +03:00
Evgenii Stratonikov
b7e86fa6a3 manifest: add Safe flag to method descriptor
`interop.Contex.AddMethod` sets `Safe` flag for native
contracts. This allows not to forget to change manifest
when changing call flags.
Also fixed invalid `Safe` flags for `Notary` and `Designate` contracts.
2020-12-08 13:27:43 +03:00
Anna Shaleva
74a143cee3 core: allow to change deposit's till for owner only 2020-12-08 10:39:20 +03:00
Roman Khimov
9211cb636c
Merge pull request #1555 from nspcc-dev/constant-contract-hashes
Constant contract hashes
2020-12-01 14:12:26 +03:00
Evgenii Stratonikov
1db27c004e native: do not fail on missing request in Oracle.PostPersist() 2020-12-01 12:29:18 +03:00
Evgenii Stratonikov
3085710e9b native: call onPayment only during transfer
OnPayment method should be called during GAS distribution
and NEO transfer.
2020-11-30 13:05:44 +03:00
Roman Khimov
1cf1fe5d74 *: introduce stable contract hashes
Follow neo-project/neo#2044.
2020-11-27 21:47:08 +03:00
Roman Khimov
7044e9be40
Merge pull request #1549 from nspcc-dev/core/fix_committee_update
core: update committee every [committee length] blocks
2020-11-27 11:04:40 +03:00
Anna Shaleva
17842dabd6 core: implement native Notary contract 2020-11-25 18:37:29 +03:00
Anna Shaleva
c013522296 core: remove native contracts' name method
We have `name` in contract manifest.
2020-11-25 18:37:29 +03:00
Anna Shaleva
0f68528095 core: add callback to VM context 2020-11-25 18:37:29 +03:00
Anna Shaleva
eca27055b8 core: fix NEP17 Transfer event
`Transfer` event declaration was placed at the wrong part of
`newNEP17Native`, that's why it had incorrect parameters.

Fixed.
2020-11-25 18:37:29 +03:00
Anna Shaleva
2fee69f26f core: add missing onPersist and postPersist methods to natives
Although not every contract is persisted (see
https://github.com/neo-project/neo/blob/master/src/neo/Ledger/Blockchain.cs#L94)
we have to add `onPersist` and `postPersist` methods to every
native contract in order to display them in manifest for users and
follow C# behaviour. In C# there are `onPersist` and `postPersist`
methods in base native contract class, see
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/NativeContract.cs#L141
and
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/NativeContract.cs#L148
2020-11-25 18:37:29 +03:00
Anna Shaleva
b00eb51c55 core: add P2PNotary designated role 2020-11-24 18:47:09 +03:00
Evgenii Stratonikov
7d91a3a89e pkg: move internal/ package to the root directory
This way we can use it in scripts and cli.
2020-11-24 16:39:56 +03:00
Evgenii Stratonikov
31eca342eb *: replace all NEP5 occurences to NEP17 2020-11-24 13:08:24 +03:00
Evgenii Stratonikov
b97dfae8d8 native: replace NEP-5 with NEP-17 2020-11-24 13:08:23 +03:00
Evgenii Stratonikov
42ae226f9e native: use proper stack for result
When native method calls other contract result should be put
on the stack of current context. With oracles this problem wasn't
noticed because of void return type.
2020-11-24 12:17:28 +03:00
Roman Khimov
eef921b8e0 native: allow NULL filter in oracle requests
Follow neo-project/neo#2067
2020-11-18 23:59:13 +03:00
Anna Shaleva
933bb4ca75 core: update committee every [committee length] blocks
Was changed in https://github.com/neo-project/neo/pull/1848. Affects
storage dumps.
2020-11-17 11:22:32 +03:00
Anna Shaleva
054e60c0cf core: remove NodeList from Oracle storage
The reference implementation does not store NodeList. This commit fixes
state difference for genesis block.
2020-11-16 19:09:34 +03:00
Roman Khimov
286d9185f4 smartcontract: remove contract features
We're featureless now, all contracts have access to storage and payable status
is to be determined via new NEP. Follow neo-project/neo#2060.
2020-11-13 21:26:23 +03:00
Evgenii Stratonikov
adf403666f native: decode storage item in Seek 2020-11-13 17:33:00 +03:00
Anna Shaleva
01296bda5f core: remove policy default values initialisation 2020-11-10 18:05:40 +03:00
Evgenii Stratonikov
54992ad4f3 core: provide account in calculate claimable
`getunclaimedgas` RPC should return all GAS available to claim.
2020-11-10 16:08:21 +03:00
Evgenii Stratonikov
860c146260 native: increase committee GAS bounty
Follow neo-project/neo#2049 .
2020-11-10 15:30:31 +03:00
Evgenii Stratonikov
af583c14ea native: add GAS rewards for voters
Close #1348.
2020-11-10 15:30:30 +03:00
Evgenii Stratonikov
a3c7130ab2 native: cache committee together with votes 2020-11-10 15:23:06 +03:00
Evgenii Stratonikov
c30d891aa9 consensus: update NextConsensus only when committee is recalculated 2020-11-09 17:35:32 +03:00
Roman Khimov
0ee377792e
Merge pull request #1519 from nspcc-dev/designate-role-history
native: implement designate contract history retention
2020-11-06 15:35:18 +03:00
Roman Khimov
47421f23f4 native: add events to oracle contract
Follow neo-project/neo#2036.
2020-11-06 13:49:07 +03:00
Roman Khimov
9e781bff47 native: implement designate contract history retention
Follow neo-project/neo#2007. Fix getDesignatedByRole price along the way.
2020-11-06 13:46:40 +03:00
Anna Shaleva
15a939b1da rpc: allow to getcontractstate by address, id or name
close #1423
2020-11-03 17:23:49 +03:00
Roman Khimov
eaa260474f trigger/core: split System trigger into OnPerist and PostPersist
Follow neo-project/neo#2022.
2020-10-29 19:17:07 +03:00
Roman Khimov
c4a4a84515 native: lower voting fee
Follow neo-project/neo#2010.
2020-10-26 22:12:56 +03:00
Anna Shaleva
0232bbcb0c core: refactor GASRecord handling
We should store each GAS record as
{
    Key: ContractID + RecordsPrefix + RecordID,
    Value: RecordValue,
}
So don't use state.GASRecord for storing anymore. However, it's still
useful to cache GasRecord values by using state.GASRecords, because we
have to keep GASIndexPairs sorted by indexes.
2020-10-23 12:49:12 +03:00
Anna Shaleva
0da01fde7f core: refactor blocked accounts logic 2020-10-23 11:42:30 +03:00
Anna Shaleva
6685f8eba9 core: restrict the maximum number of requests per URL 2020-10-22 11:32:02 +03:00
Anna Shaleva
7c232e2ddc core: add max nodes count restriction to designate contract 2020-10-22 11:32:02 +03:00
Evgenii Stratonikov
42ff4a8fc7 native: provide name method for all contracts 2020-10-09 15:06:28 +03:00
Roman Khimov
eb9b1cae36
Merge pull request #1474 from nspcc-dev/core/fixes
Some small improvements
2020-10-09 10:03:52 +03:00
Roman Khimov
70e9e329cd
Merge pull request #1463 from nspcc-dev/core/blocked_accounts_cache
core: add cache to Policy blocked accounts
2020-10-08 14:35:19 +03:00
Evgenii Stratonikov
037cecf1ac native: move OracleRequest to state package
It is used by multiple modules outside native
and produces unneeded dependencies.
2020-10-08 13:48:14 +03:00
Anna Shaleva
9fe2b04db9 core: add cache to Policy blocked accounts
Close #1441
2020-10-08 13:47:21 +03:00
Evgenii Stratonikov
17922038dc native: add GetOracleInvokeScript() 2020-10-07 10:04:19 +03:00
Roman Khimov
d6a1a22afa
Merge pull request #1452 from nspcc-dev/contract/deploy
Support `_deploy` method
2020-10-06 19:54:14 +03:00
Evgenii Stratonikov
b2a3a0851e emit: accept multiple opcodes in Opcode() 2020-10-06 18:03:25 +03:00
Roman Khimov
2ea29924c4
Merge pull request #1454 from nspcc-dev/core/policy_checks
core: add validation to policy methods
2020-10-05 19:09:59 +03:00
Anna Shaleva
560e470484 core: add validation to native Policy methods
close #1442
2020-10-05 18:08:37 +03:00
Roman Khimov
8e146d19b3
Merge pull request #1447 from nspcc-dev/core/fix_neo_cache
core: fix cache for (NEO).nextValidators and (NEO).committee
2020-10-02 17:09:43 +03:00
Anna Shaleva
eccf639803 core: add InitializeCache method to NEO native contracts
There might be a case when cached contract values store nil (e.g.
after restoring chain from dump). We should always initialize cached
values irrespective to the (NEO).Initialize method.

This commit fixes a bug introduced in 83e94d3
when 4-nodes privnet is failing after restoring from dump:
```
$ docker logs neo_go_node_one
=> Try to restore blocks before running node
2020-09-30T11:55:49.122Z	INFO	no storage version found! creating genesis block
2020-09-30T11:55:49.124Z	INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2020-09-30T11:55:49.124Z	INFO	service hasn't started since it's disabled	{"service": "Prometheus"}
2020-09-30T11:55:49.124Z	INFO	skipped genesis block	{"hash": "3792eaa22c196399a114666fd491c4b9ac52491d9abb1f633a8036a8ac81e4db"}
2020-09-30T11:55:49.141Z	INFO	shutting down service	{"service": "Pprof", "endpoint": ":30001"}
2020-09-30T11:55:49.141Z	INFO	shutting down service	{"service": "Prometheus", "endpoint": ":40001"}
2020-09-30T11:55:49.141Z	INFO	blockchain persist completed	{"persistedBlocks": 3, "persistedKeys": 146, "headerHeight": 3, "blockHeight": 3, "took": "324.27µs"}
2020-09-30T11:55:49.150Z	INFO	restoring blockchain	{"version": "0.1.0"}
2020-09-30T11:55:49.150Z	INFO	service hasn't started since it's disabled	{"service": "Prometheus"}
2020-09-30T11:55:49.151Z	INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2020-09-30T11:55:49.443Z	INFO	starting rpc-server	{"endpoint": ":30333"}
2020-09-30T11:55:49.443Z	INFO	node started	{"blockHeight": 3, "headerHeight": 3}

    _   ____________        __________
   / | / / ____/ __ \      / ____/ __ \
  /  |/ / __/ / / / /_____/ / __/ / / /
 / /|  / /___/ /_/ /_____/ /_/ / /_/ /
/_/ |_/_____/\____/      \____/\____/

/NEO-GO:/

2020-09-30T11:55:49.444Z	INFO	new peer connected	{"addr": "172.23.0.5:39638", "peerCount": 1}
2020-09-30T11:55:49.444Z	INFO	new peer connected	{"addr": "172.23.0.5:20333", "peerCount": 2}
2020-09-30T11:55:49.444Z	WARN	peer disconnected	{"addr": "172.23.0.5:20333", "reason": "identical node id", "peerCount": 1}
2020-09-30T11:55:49.445Z	WARN	peer disconnected	{"addr": "172.23.0.5:39638", "reason": "identical node id", "peerCount": 0}
2020-09-30T11:55:49.445Z	INFO	new peer connected	{"addr": "172.23.0.3:20335", "peerCount": 1}
2020-09-30T11:55:49.445Z	INFO	new peer connected	{"addr": "172.23.0.2:20334", "peerCount": 2}
2020-09-30T11:55:49.445Z	INFO	started protocol	{"addr": "172.23.0.3:20335", "userAgent": "/NEO-GO:/", "startHeight": 3, "id": 1339919829}
2020-09-30T11:55:49.445Z	INFO	new peer connected	{"addr": "172.23.0.4:20336", "peerCount": 3}
2020-09-30T11:55:49.445Z	INFO	started protocol	{"addr": "172.23.0.4:20336", "userAgent": "/NEO-GO:/", "startHeight": 3, "id": 4036722359}
2020-09-30T11:55:49.445Z	INFO	node reached synchronized state, starting consensus
2020-09-30T11:55:49.445Z	INFO	started protocol	{"addr": "172.23.0.2:20334", "userAgent": "/NEO-GO:/", "startHeight": 3, "id": 1557367037}
panic: runtime error: integer divide by zero

goroutine 132 [running]:
github.com/nspcc-dev/dbft.(*Context).GetPrimaryIndex(...)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/context.go:83
github.com/nspcc-dev/dbft.(*Context).reset(0xc0000e0780, 0x0)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/context.go:208 +0x64b
github.com/nspcc-dev/dbft.(*DBFT).InitializeConsensus(0xc0000e0780, 0x964800)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/dbft.go:87 +0x51
github.com/nspcc-dev/dbft.(*DBFT).Start(0xc0000e0780)
	github.com/nspcc-dev/dbft@v0.0.0-20200925163137-8f3b9ab3b720/dbft.go:81 +0x4b
github.com/nspcc-dev/neo-go/pkg/consensus.(*service).Start(0xc0001a2160)
	github.com/nspcc-dev/neo-go/pkg/consensus/consensus.go:206 +0x56
github.com/nspcc-dev/neo-go/pkg/network.(*Server).tryStartConsensus(0xc0000ec500)
	github.com/nspcc-dev/neo-go/pkg/network/server.go:311 +0xda
github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage(0xc0000ec500, 0x104d800, 0xc000222090, 0xc0000a6f10, 0x0, 0x0)
	github.com/nspcc-dev/neo-go/pkg/network/server.go:781 +0xa7a
github.com/nspcc-dev/neo-go/pkg/network.(*TCPPeer).handleConn(0xc000222090)
	github.com/nspcc-dev/neo-go/pkg/network/tcp_peer.go:162 +0x2e7
created by github.com/nspcc-dev/neo-go/pkg/network.(*TCPTransport).Dial
	github.com/nspcc-dev/neo-go/pkg/network/tcp_transport.go:40 +0x1ac
```
2020-10-02 17:03:06 +03:00
Roman Khimov
b5d138b150
Merge pull request #1451 from nspcc-dev/native/designative
native: implement Designate contract
2020-10-02 16:09:33 +03:00
Anna Shaleva
6b201893fa core: unexport NewNEO() and NewGAS() methods 2020-10-02 15:45:49 +03:00
Evgenii Stratonikov
c468c02ef5 native: implement Designate contract 2020-10-02 11:03:25 +03:00
Roman Khimov
5365da9860 native: remove unregistered candidate with 0 votes on NEO transfer
See neo-project/neo#1935.
2020-09-29 22:38:38 +03:00
Evgenii Stratonikov
26dc807a2d native: initialize cache in OnPersist
If node started from non-zero height, `Initialize` is
not called thus cache is empty. Thus we should initialize
it before any tx is executed.
2020-09-29 10:17:47 +03:00
Evgenii Stratonikov
05118e96f4 native: store cache during Oracle contract creation
`Initialize` is not called during restore from dump.
2020-09-28 15:34:04 +03:00
Evgenii Stratonikov
e0e7fd5367 native: cache GASPerBlock values
Close #1421.
2020-09-28 10:53:48 +03:00
Evgenii Stratonikov
e91d13c615 core: implement oracle tx verification 2020-09-25 17:34:11 +03:00
Evgenii Stratonikov
f084acc339 native: cache oracle script hash 2020-09-25 17:34:11 +03:00
Evgenii Stratonikov
bd1790bddf native: cache oracle nodes 2020-09-25 17:34:11 +03:00
Evgenii Stratonikov
141d6e325f native: implement basis for oracle contract 2020-09-25 17:34:11 +03:00
Evgenii Stratonikov
5b205ffa7d native: cache committee script hash 2020-09-25 16:32:10 +03:00
Evgenii Stratonikov
ca1b8a7df0 state: implement marshalers for oracle-related state 2020-09-25 16:32:10 +03:00
Evgenii Stratonikov
30526046e7 native: don't push void result in Call
This was done in https://github.com/neo-project/neo/pull/1693
for native calls. `OnPersist` script still uses `DROP` though
as value is pushed via `CheckReturn` logic for regular calls.
2020-09-25 16:32:10 +03:00
Evgenii Stratonikov
c5cdaae87a native: support postPersist method
It should be called for NEO contract to distribute
committee bounties.
2020-09-23 14:47:09 +03:00
Evgenii Stratonikov
af16519413 native: do not update committee every block
Update frequency depends on committee size and
amount of validators. For mainnet it is 28.
2020-09-23 14:42:13 +03:00
Evgenii Stratonikov
81a11c629a native: remove getValidators method
Follow https://github.com/neo-project/neo/pull/1920 .
2020-09-23 14:42:13 +03:00
Evgenii Stratonikov
83e94d3bbc native: cache committee members 2020-09-23 14:42:13 +03:00
Evgenii Stratonikov
43b3e15330 native: send GAS to a committee member on persist 2020-09-23 14:42:12 +03:00
Evgenii Stratonikov
5a38208361 native: implement NEO.Get/SetMaxGasPerBlock() 2020-09-23 14:12:42 +03:00
Evgenii Stratonikov
7d90d79ae6 core: update claimable GAS calculation 2020-09-23 14:12:42 +03:00
Evgenii Stratonikov
230700ee81 core: do not persist Policy contract
It has nothing to persist.
2020-09-05 10:54:47 +03:00
Evgenii Stratonikov
dce456f77f native: fix a bug in GetCommitteeMembers
Return standby committee instead of validators.
2020-08-27 18:40:37 +03:00
Evgenii Stratonikov
4782a94200 native: do not rewrite NextValidators in (*NEO).OnPersist()
There is no need in writing the same value again and again.
Closes #1337.
2020-08-24 16:45:09 +03:00
Evgenii Stratonikov
2661ebd295 transaction: add HighPriority attribute
HighPriority attributes specifies that transaction was
signed by a committee.
2020-08-23 09:39:46 +03:00
Roman Khimov
a7670303e8 stackitem: change Bool() to TryBool(), prepare for its failures 2020-08-21 20:55:20 +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
e7d13e6db2 *: fix misspellings found in Go Report Card 2020-08-14 12:16:24 +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
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
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
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
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
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
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
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
Anna Shaleva
90825efa16 core: move transaction's sender to cosigners
Closes #1184

Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Anna Shaleva
66ceaa6b75 smartcontract: add list of supported standards to manifest
Closes #1204
2020-08-04 17:29:44 +03:00
Roman Khimov
62f5aa8eb4
Merge pull request #1254 from nspcc-dev/native/policy/maxblocksystemfee
core, consensus: add maxBlockSystemFee to native Policy
2020-08-04 13:13:06 +03:00
Anna Shaleva
4a1c8464f9 core: use maxBlockSize to apply policy to tx set
We should also take into account maxBlockSize in
(bc *Blockchain).ApplyPolicyToTxSet
2020-08-04 10:59:09 +03:00
Anna Shaleva
c647f8e4ed core: add maxBlockSystemFee to native Policy
Closes #1195
2020-08-04 10:59:00 +03:00
Roman Khimov
00671deb8f
Merge pull request #1241 from nspcc-dev/fix/string
Ensure strings are valid UTF-8 where appropriate
2020-08-03 18:10:27 +03:00
Anna Shaleva
13336f9dba core: adjust calling flags of native Policy methods 2020-08-03 16:09:10 +03:00
Anna Shaleva
60f9abae40 core: chenge maxBlockSizeKey of native Policy 2020-08-03 16:00:15 +03:00
Evgenii Stratonikov
f40aba4cd0 vm: convert items to UTF-8 strings
Add `stackitem.ToString` for seamless string conversion.
2020-07-30 12:37:31 +03:00
Anna Shaleva
b9bdab8ec8 core: store nep5balances using contract id
Closes #1194
2020-07-29 15:15:48 +03:00
Anna Shaleva
4bf88ba6b0 core: decouple native contracts from interop service
Closes #1191.
2020-07-29 10:33:18 +03:00
Evgenii Stratonikov
7d8fead1fd native: change onPersist return type to Void 2020-07-27 11:08:01 +03:00