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
Evgenii Stratonikov
e52c39ae7e
manifest: remove EntryPoint from manifest
2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
121c9664b4
core: restrict maximum gas allow for verification
...
Disallow costly verification methods. We put this limit in policy
contract as it may be a subject to change in future.
In fact this value also overrides gas limit for header verification.
Close #1202 .
2020-07-25 14:33:38 +03:00
Anna Shaleva
6e44499cec
core: adjust Neo.Native.Deploy interop
...
Part of #1055 .
It could be that context.Block is nill.
2020-07-22 16:58:32 +03:00
Evgenii Stratonikov
3d7fa9de93
*: make Notify interop accept event name
2020-07-20 13:33:32 +03:00
Roman Khimov
acfded7f45
Merge pull request #1180 from nspcc-dev/fix-calling-scripthash-check-in-nep5
...
Add calling scripthash check to native nep5 transfers
2020-07-16 07:29:14 +03:00
Roman Khimov
59be6bcd24
native: add calling script hash to NEP5 transfer witness check
...
Fix transfers from contract's address.
2020-07-15 22:52:35 +03:00
Roman Khimov
d4c3a17883
interop/native: always use proper ScriptHashGetter, fix #924
...
All scripts are run in VM, so it's there to tell us about script hashes
involved and it must be used instead of nep5ScriptHash kludge.
2020-07-15 22:43:30 +03:00
Anna Shaleva
a3e306ff78
core: implement Secp256k1 Verify and CheckMultisig interops
...
Closes #918 .
2020-07-14 16:21:34 +03:00
Roman Khimov
579630a3fa
native: don't expose internal slices to the outside world
...
They should be hidden.
2020-07-11 19:54:50 +03:00
Roman Khimov
ae497228f0
core: use native NEO GetValidators for bc.GetValidators
...
NextBlockValidators are updated before the new block persist, so we need to
use GetValidators to get the list corresponding to the current state of the
chain.
2020-07-11 19:54:50 +03:00
Anna Shaleva
abe3c94b95
core: use big.Int to store NEP5 balances
...
closes #1133
2020-07-09 13:26:39 +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
f007cca80b
native: hide native contract methods
...
Copy public keys when returning them to the outside and hide unused
`GetValidators` method.
2020-06-29 10:48:37 +03:00
Evgenii Stratonikov
bbe02ac584
native: store typed nil
in validators cache
...
Fix `error encountered at instruction 0 (SYSCALL): sync/atomic: store of nil value into Value"`.
2020-06-29 10:37:52 +03:00
Evgenii Stratonikov
978b3c96fe
native: cache GetValidators result
2020-06-24 19:42:50 +03:00
Roman Khimov
7987cdadc0
native: update storage item value after gas distribution
...
Even if the value is zero, the GAS distribution updates the balance height, so
storage item must be updated too. Fixes the followin on preview2 testnet:
block 74227: value mismatch for key ffffffff1454a6cb279fbcedc66162ad4ad5d1d910202b92743e000000000000000000000005: 1041032104809fd5002103f3210128010000 vs 1041032104809fd50021033f110128010000
2020-06-24 10:22:21 +03:00
Roman Khimov
48fac6f87d
native: unify some transfer code
2020-06-24 10:22:21 +03:00
Roman Khimov
fccad11716
native: drop accounts with zero balance
...
They make no sense. Fixes preview2 testnet state problem:
file BlockStorage_100000/dump-block-70000.json: block 69935: state mismatch for key ffffffff1454a6cb279fbcedc66162ad4ad5d1d910202b92743e000000000000000000000005: Deleted vs Added
2020-06-24 10:22:21 +03:00
Roman Khimov
5e56c9db29
native: fix voting accounting in transfers processing
...
We should modify votes count exactly by the amount of NEO balance change, it
might be negative here.
2020-06-24 10:22:21 +03:00
Roman Khimov
37d44b94e1
native: fix netfee gas redistribution
...
Preview2 testnet:
file BlockStorage_100000/dump-block-12000.json: block 11562: key mismatch: feffffff1454a6cb279fbcedc66162ad4ad5d1d910202b92743e000000000000000000000005 vs feffffff1431b7e7aea5131f74721e002c6a56b610885813f79e000000000000000000000005
Originally this code was written to run after transactions processing, but
after 0fa4c49735
it works in different manner.
2020-06-24 10:22:21 +03:00
Roman Khimov
d0331bf21b
native: simplify votes saving in NEO contract
...
Follow C# behavior and fix state mismatch at block 11561 of preview2 testnet.
2020-06-24 10:22:21 +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
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
Anna Shaleva
9097a1a23d
smartcontract: update (Parameter).MarshalJSON method
...
MarshalJSON should be defined on structure (not pointer), as we use
structures to marshal parameters (e.g. in NotificationEvent and
Invoke of RPC result package) and never use pointers for that purpose.
Also added marshalling of nil array into `[]` instead of `null` to
follow C# implementation.
2020-06-24 07:58:09 +03:00
Anna Shaleva
c2735a4569
core: add cache to native Policy contract
...
We can cache maxBlockSize, maxTransactionsPerBlock and feePerByte
in order to reduce the number of storage requests.
2020-06-24 07:36:11 +03:00
Anna Shaleva
08cc04c3d5
core: add native policy contract
...
part of #904
2020-06-24 07:35:07 +03:00
Roman Khimov
36a65e3847
Merge pull request #1077 from nspcc-dev/neo3/smartcontract/id
...
core: store smartcontract items by id
2020-06-20 00:12:07 +03:00
Anna Shaleva
f1cdcbc99c
core: store smartcontract items by id
...
closes #1037
2020-06-19 20:48:45 +03:00
Anna Shaleva
c767ac2973
core: fix NEO native contract id
...
It should be set to -1 as in c# implementation.
2020-06-19 20:44:52 +03:00
Evgenii Stratonikov
a584c5a6a4
native: fix NEP5 contract method prices
...
Closes #1073 .
2020-06-19 12:58:33 +03:00
Evgenii Stratonikov
05dad10e82
native: fix native contract onPersist
script
...
C# implementation uses NEWARRAY for creating arguments.
Don't change our implementation in `emit`, because PACK is cheaper and
this script must not depend on the internal details of `emit` package anyway.
2020-06-19 11:58:38 +03:00
Roman Khimov
dd6895b103
native: optimize GAS onPersist for empty blocks
...
There is no need to get a list of validators when there are no transactions in
the block.
2020-06-18 21:51:29 +03:00
Evgenii Stratonikov
3e76b9a9bf
native: fix Transfer event in burn
...
Tokens should subtract, but transfer amount is positive.
2020-06-18 16:19:09 +03:00
Evgenii Stratonikov
3894b6db9f
native: take into account native contract method prices
...
Burn gas right before function invoke.
2020-06-18 15:32:27 +03:00
Evgenii Stratonikov
031fd93172
native: fix native contract prices
2020-06-18 15:32:27 +03:00
Evgenii Stratonikov
0fa4c49735
core,native: persist native contract via VM
...
After native contracts are deployed, single persist script is created
and executed at the start of every block persisting.
2020-06-18 15:32:27 +03:00
Evgenii Stratonikov
a3b876d55c
native: specify call flags for native contract methods
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
0dd00a49f5
core: specify require call flags in interop description
...
Related #1026 , #1027 , #1028 , #1031 .
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
df958caf93
core: add Manifest to state.Contract
2020-06-11 10:45:24 +03:00
Evgenii Stratonikov
425277098c
native: set ContractID for NEO & GAS contracts
2020-06-10 14:23:25 +03:00
Anna Shaleva
4bf103ca12
core: update native contract data serialisation format
...
closes #908
2020-06-08 13:29:35 +03:00
Anna Shaleva
7ca2807875
vm/encoding: move bigint from vm to encoding package
2020-06-08 13:27:13 +03:00
Anna Shaleva
783f5ecb01
vm: move StackItem to a separate package
...
closes #912
2020-06-08 13:27:08 +03:00
Roman Khimov
3d18f09def
core: fix CalculateClaimable for NEP5 NEO
...
It's not stored as Fixed8, so calculations need to be adjusted for that.
2020-06-05 19:20:16 +03:00
Roman Khimov
39dfebccc4
core: no longer treat sysfee as claimable
...
As it's not on Neo 3, it just gets burned and that's it. Only network fee is
being redistributed to CNs.
2020-06-05 19:20:16 +03:00
Roman Khimov
50ed4c5967
core: don't return an error from CalculateClaimable
...
As it never returns one.
2020-06-05 19:20:16 +03:00
Roman Khimov
a9955719da
native: make mint/burn for 0 no-ops
...
Prevent emitting useless transfer events and doing useless gets/puts.
2020-06-05 19:20:16 +03:00
Roman Khimov
7e586cc6ab
native: deduce transferred assets from sender on transfer
...
When money is being sent usually they go away from someone's pocket, so that
there is a little less money left there. Not in our case as it turns out, we
actually were adding money both to sender and receiver which is nice, but a
bit different from usual economic's expectations.
2020-06-05 19:20:16 +03:00
Anna Shaleva
8fb67615f8
core: sort results of Storage.Find and NEO.getRegisterValidators
...
Closes #909
We need to match elements order with C# implementation.
2020-05-29 17:33:01 +03:00
Anna Shaleva
9f2cb1726b
core: add witness check to nep5 transfer method
...
We have to check, whether transaction's sender is authorised to transfer
nep5 assets.
2020-05-20 23:34:27 +03:00
Anna Shaleva
7acf5b2841
core: add SystemFee and NetworkFee to transaction
...
closes #831
2020-05-20 23:26:48 +03:00
Anna Shaleva
6b2f4efdd4
core: fix bug in nep5TokenNative.addTokens method
...
Sometimes we want to add negative amount (e.g. when burning tokens).
2020-05-20 23:16:04 +03:00
Anna Shaleva
c7a040ff81
core: fix bug with native contracts methods initialisation
...
`NewNEO()` and `NewGAS()` methods are trying to initialise
both `onPersist` and `incBalance` methods of NEO and GAS AFTER
nep5TokenNative is set to the VALUE of created nep5 token.
In this situation an attemmpt to call the corresponding native contracts
methods (e.g. transfer native GAS) leads to contract invocation failure,
as far as `nep5TokenNative.incBalance` method is nil.
Fixed this by initializing both `onPersist` and `incBalance` methods
before getting the value of nep5 contract.
2020-05-20 23:16:04 +03:00
Evgenii Stratonikov
301c1b7601
native: save native contract state on deploy
2020-05-07 14:03:14 +03:00
Anna Shaleva
5ece9922c1
vm: hide GetContextScriptHash() method
...
After adding ScriptHashGetter interface to vm, there's no need in
GetContextScriptHash() to be exported.
2020-05-04 11:53:31 +03:00
Anna Shaleva
73167999cc
core: add cosigners field to transaction
...
closes #864
2020-05-04 11:53:31 +03:00
Roman Khimov
b83e84ca08
core: switch to the new voting system (via native NEO contract)
...
It has all the methods required now, so you can register, vote and get
voting results. Fixes #865 .
2020-04-27 16:06:50 +03:00
Roman Khimov
2fa3bdf6a9
core/native: move Votes from account to native NEO state
2020-04-27 12:30:39 +03:00
Roman Khimov
bc4a6a6bab
core/native: move NextValidators storage to NEO contract
2020-04-27 12:30:39 +03:00
Roman Khimov
66c80d429e
native: update voting information when changing Neo balance
2020-04-27 12:30:39 +03:00
Roman Khimov
36c6c6690b
native: distribute GAS even for empty transfers
...
As it's one of the use cases.
2020-04-27 12:30:39 +03:00
Roman Khimov
064636768b
core/native: move ValidatorsCount processing into native NEO contract
2020-04-27 12:30:39 +03:00
Roman Khimov
3476a18fa9
core/native: store validators in NEO native contract state
...
This technically breaks voting with UTXO-based NEO (processTXWithValidators*),
but we're moving towards the new system.
2020-04-27 12:30:39 +03:00
Roman Khimov
4e8ee697ee
native: store NEO and GAS state in the storage
...
As it should be done (although current serialization format is not quite
right).
2020-04-27 12:30:39 +03:00
Roman Khimov
8c02c6b22c
native: put proper Null StackItem for transfer event
...
nil is not a good StackItem, we have proper VM-level Null for this.
2020-04-27 12:30:39 +03:00
Roman Khimov
1dcace1594
native: don't distribute gas at block 0
...
It fails at the moment and it doesn't make sense at conceptual level.
2020-04-27 12:30:39 +03:00
Roman Khimov
30836ca69b
core/native: untangle native contracts initialization
...
The notion of NativeContractState shouldn't ever existed, native contract is a
contract and its state is saved as regular contract state which is critical
because we'll have MPT calculations over this state soon.
Initial minting should be done in Neo.Native.Deploy because it generates
notification that should have proper transaction context.
RegisterNative() shouldn't exist as a public method, native contracts are only
registered at block 0 and they can do it internally, no outside user should be
able to mess with it.
Move some structures from `native` package to `interop` also to avoid circular
references as interop.Context has to have a list of native contracts (exposing
them via Blockchainer is again too dangerous, it's too powerful tool).
2020-04-27 12:30:39 +03:00
Anna Shaleva
869c7d6afa
core: init native interops in the genesis block
...
closes #836
2020-04-27 12:30:39 +03:00
Evgenii Stratonikov
bfbbef952a
vm: move InteropNameToID to emit package
2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
76700f31cf
core: implement skeletons for NEO/GAS native contracts
2020-04-16 15:55:35 +03:00
Evgenii Stratonikov
25354c44f9
core: implement NativeContract support
2020-04-16 15:55:34 +03:00