Evgeniy Stratonikov
db4e7558e0
native: cache all roles in Designate
2021-01-28 17:09:05 +03:00
Evgenii Stratonikov
43e4d3af88
oracle: integrate module in core and RPC
...
1. Initialization is performed via `Blockchain` methods.
2. Native Oracle contract updates list of oracle nodes
and in-fly requests in `PostPersist`.
3. RPC uses Oracle module directly.
2021-01-28 13:00:58 +03:00
Evgenii Stratonikov
7e16bea126
network: implement Oracle module
2021-01-28 12:43:20 +03:00
Evgeniy Stratonikov
73f888f02e
core: allow to overload contract methods
...
Multiple methods with different parameter count can co-exist.
2021-01-27 12:51:07 +03:00
Roman Khimov
054ca27e9c
state: use checksums and names to calculate contract hashes
...
It allows to deploy the same NEF using one sender and get different contract
hashes. See neo-project/neo#2240 .
2021-01-22 12:22:48 +03:00
Roman Khimov
6b9b37f170
native: don't call CreateNativeContractHash() in oracle contract
...
Move oracleScript from global context to Oracle itself. We have the hash
already computed by NewContractMD, there is no need to repeat this
calculation.
2021-01-22 11:28:13 +03:00
Roman Khimov
476cbbebdc
native: make registering as a candidate cost more
...
Follow neo-project/neo#2252 .
2021-01-21 23:02:59 +03:00
Evgeniy Stratonikov
c6894f3f55
native: check for committee in setters
2021-01-21 15:20:34 +03:00
Roman Khimov
6ecc6f0422
native: call native contracts by ID instead of name
...
Fix #1666 .
2021-01-18 00:38:23 +03:00
Roman Khimov
f39ede9869
opcode: add CALLT opcode, move ABORT/ASSERT
...
Refs. #1644 . Hash compatibility test temporarily disabled, to be enabled when
it's up to date with current C# master.
2021-01-18 00:14:52 +03:00
Evgenii Stratonikov
1c0c331e25
core: update System.Contract.Call
syscall
...
1. Remove `System.Contract.CallEx`.
2. Extend number of parameters.
3. Add return value count to `VM.Context`.
2021-01-14 18:23:36 +03:00
Evgenii Stratonikov
dbe81f9b80
smartcontract: move flags to a separate package
2021-01-14 17:52:09 +03:00
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