AnnaShaleva
92282c70cb
*: support customisable NotaryServiceFeePerKey value
...
* Add corresponding methods to Notary contract.
* Extend RPC Client API.
* Adjust tests.
2022-03-01 19:08:16 +03:00
Roman Khimov
aefb26255a
dao: drop DAO interface
...
It's a remnant from the days when we had Simple and Cached DAO
implementations, now it makes zero sense.
2022-02-16 18:24:20 +03:00
Roman Khimov
9d2ef775cf
storage: simplify (*MemCachedStore).Put/Delete interface
...
They never return errors, so their interface should reflect that. This allows
to remove quite a lot of useless and never tested code.
Notice that Get still does return an error. It can be made not to do that, but
usually we need to differentiate between successful/unsuccessful accesses
anyway, so this doesn't help much.
2022-02-16 18:24:20 +03:00
Roman Khimov
ac7e922606
native: avoid big.Int allocation in burn()
...
addTokens and incBalance only read the amount, so it's not a problem.
2021-12-02 15:40:43 +03:00
Roman Khimov
24a3cce1ca
Merge pull request #2169 from nspcc-dev/states-diff_mainnet_131795
...
core: allow transfer 0 GAS/NEO with zero balance
2021-09-14 17:30:41 +03:00
Anna Shaleva
7fc57c9d58
core: allow transfer 0 GAS/NEO with zero balance
...
This commit fixes states diff at 131795 block of mainnet.
Transaction:
```
NEO-GO-VM > loadbase64 DAAQDBSPsxdYh6cITC3gUKI4oWmYxJs49gwUj7MXWIenCEwt4FCiOKFpmMSbOPYUwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQwAEQwUj7MXWIenCEwt4FCiOKFpmMSbOPYMFL1Mb4Fqp6gHiEwzM6xSc8fLS+RpFMAfDAh0cmFuc2ZlcgwU9WPqQLwoPU0OBcSOowWz8qBzQO9BYn1bUjk=
READY: loaded 176 instructions
NEO-GO-VM 0 > ops
INDEX OPCODE PARAMETER
0 PUSHDATA1 ("") <<
2 PUSH0
3 PUSHDATA1 8fb3175887a7084c2de050a238a16998c49b38f6
25 PUSHDATA1 8fb3175887a7084c2de050a238a16998c49b38f6
47 PUSH4
48 PACK
49 PUSH15
50 PUSHDATA1 7472616e73666572 ("transfer")
60 PUSHDATA1 f563ea40bc283d4d0e05c48ea305b3f2a07340ef // NEO token
82 SYSCALL System.Contract.Call (627d5b52)
87 ASSERT
88 PUSHDATA1 ("")
90 PUSH1
91 PUSHDATA1 8fb3175887a7084c2de050a238a16998c49b38f6
113 PUSHDATA1 bd4c6f816aa7a807884c3333ac5273c7cb4be469
135 PUSH4
136 PACK
137 PUSH15
138 PUSHDATA1 7472616e73666572 ("transfer")
148 PUSHDATA1 f563ea40bc283d4d0e05c48ea305b3f2a07340ef // NEO token
170 SYSCALL System.Contract.Call (627d5b52)
175 ASSERT
```
Go's applog:
```
{
"id" : 1,
"result" : {
"txid" : "0x97d2ccb01467b22c73a2cb95f7af298f3a5bd8c849d7044371898b8efecdaabd",
"executions" : [
{
"exception" : "at instruction 87 (ASSERT): ASSERT failed",
"stack" : [],
"gasconsumed" : "4988995",
"notifications" : [],
"trigger" : "Application",
"vmstate" : "FAULT"
}
]
},
"jsonrpc" : "2.0"
}
```
C#'s applog:
```
{
"jsonrpc" : "2.0",
"result" : {
"executions" : [
{
"stack" : [],
"notifications" : [
{
"contract" : "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"state" : {
"type" : "Array",
"value" : [
{
"type" : "ByteString",
"value" : "j7MXWIenCEwt4FCiOKFpmMSbOPY="
},
{
"type" : "ByteString",
"value" : "j7MXWIenCEwt4FCiOKFpmMSbOPY="
},
{
"value" : "0",
"type" : "Integer"
}
]
},
"eventname" : "Transfer"
},
{
"contract" : "0xd2a4cff31913016155e38e474a2c06d08be276cf",
"state" : {
"value" : [
{
"type" : "Any"
},
{
"type" : "ByteString",
"value" : "vUxvgWqnqAeITDMzrFJzx8tL5Gk="
},
{
"value" : "2490",
"type" : "Integer"
}
],
"type" : "Array"
},
"eventname" : "Transfer"
},
{
"contract" : "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"state" : {
"value" : [
{
"value" : "vUxvgWqnqAeITDMzrFJzx8tL5Gk=",
"type" : "ByteString"
},
{
"value" : "j7MXWIenCEwt4FCiOKFpmMSbOPY=",
"type" : "ByteString"
},
{
"value" : "1",
"type" : "Integer"
}
],
"type" : "Array"
},
"eventname" : "Transfer"
}
],
"vmstate" : "HALT",
"gasconsumed" : "9977990",
"trigger" : "Application",
"exception" : null
}
],
"txid" : "0x97d2ccb01467b22c73a2cb95f7af298f3a5bd8c849d7044371898b8efecdaabd"
},
"id" : 1
}
```
2021-09-10 17:18:09 +03:00
Anna Shaleva
61fd7bd6ba
core: avoid nil
values during natives manifest marshalling
2021-09-10 11:38:59 +03:00
Roman Khimov
64c780ad7a
native: optimize totalSupply operations during token burn/mint
...
We burn GAS in OnPersist for every transaction so some buffer reuse here is
quite natural.
This also doesn't change a lot in the overall TPS picture, maybe adding some
1%.
2021-08-03 17:59:38 +03:00
Roman Khimov
5c65d33439
native: move required balance check to token contracts
...
Which duplicates the check, but deduplicates error path. This check forced
double balance deserialization which is quite costly operation, so we better
do it once.
It's hardly noticeable as of TPS metrics though, maybe some 1-2%%.
2021-08-03 17:59:38 +03:00
Anna Shaleva
e8bed184d5
core: implement dynamic NEP17 balances tracking
...
Request NEP17 balances from a set of NEP17 contracts instead of getting
them from storage. LastUpdatedBlock tracking remains untouched, because
there's no way to retrieve it dynamically.
2021-07-29 10:23:01 +03:00
Roman Khimov
5f13de3a76
*: simplify some integer checks with IsUint64()
...
If we need a positive number we can do `IsUint64()` instead of checking that
`Int64()` is `> 0`.
2021-07-19 15:42:42 +03:00
Evgeniy Stratonikov
d2e8254848
native: fix typo in comments
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-05 11:04:19 +03:00
Evgeniy Stratonikov
a7722f0fa5
native: save balance value in storage for failed transfers
...
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-07-05 11:03:42 +03:00
Anna Shaleva
be902afe9e
core: do not allow NEP17 roundtrip in case of insufficient funds
...
NEP17 roundtrip is prohibited if from account doesn't have enough funds.
This commit fixes states diff in block 92057 where account
NfuwpaQ1A2xaeVbxWe8FRtaRgaMa8yF3YM initiates two NEO roundtrips with
amount exceeding the account's balance:
block 92057: value mismatch for key +////xTbYWBH3r5qhRKZAPFPHabKfb2vhQ==: QQMhAkwBIQOZZwEA vs QQMhAkwBIQN/ZwEA
block 92057: value mismatch for key +v///ws=: kqlddcitCg== vs tphddcitCg==
block 92057: value mismatch for key +v///xTbYWBH3r5qhRKZAPFPHabKfb2vhQ==: QQEhBUWyDu0W vs QQEhBWmhDu0W
C#'s applog (contains False and False on stack for both transfers):
```
{
"id" : 1,
"jsonrpc" : "2.0",
"result" : {
"executions" : [
{
"gasconsumed" : "11955500",
"exception" : null,
"stack" : [
{
"value" : false,
"type" : "Boolean"
},
{
"value" : false,
"type" : "Boolean"
}
],
"vmstate" : "HALT",
"trigger" : "Application",
"notifications" : []
}
],
"txid" : "0x8e73a7e9a566a514813907272ad65fc965002c3b098eacc5bdda529af19d7688"
}
}
```
Go's applog (both transfers succeeded and GAS minted):
```
{
"result" : {
"executions" : [
{
"gasconsumed" : "11955500",
"trigger" : "Application",
"stack" : [
{
"type" : "Boolean",
"value" : true
},
{
"type" : "Boolean",
"value" : true
}
],
"vmstate" : "HALT",
"notifications" : [
{
"eventname" : "Transfer",
"contract" : "0xd2a4cff31913016155e38e474a2c06d08be276cf",
"state" : {
"value" : [
{
"type" : "Any"
},
{
"value" : "22FgR96+aoUSmQDxTx2myn29r4U=",
"type" : "ByteString"
},
{
"value" : "4316",
"type" : "Integer"
}
],
"type" : "Array"
}
},
{
"state" : {
"type" : "Array",
"value" : [
{
"value" : "22FgR96+aoUSmQDxTx2myn29r4U=",
"type" : "ByteString"
},
{
"type" : "ByteString",
"value" : "22FgR96+aoUSmQDxTx2myn29r4U="
},
{
"type" : "Integer",
"value" : "1111111111"
}
]
},
"contract" : "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"eventname" : "Transfer"
},
{
"contract" : "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"state" : {
"type" : "Array",
"value" : [
{
"value" : "22FgR96+aoUSmQDxTx2myn29r4U=",
"type" : "ByteString"
},
{
"type" : "ByteString",
"value" : "22FgR96+aoUSmQDxTx2myn29r4U="
},
{
"type" : "Integer",
"value" : "1111111"
}
]
},
"eventname" : "Transfer"
}
]
}
],
"txid" : "0x8e73a7e9a566a514813907272ad65fc965002c3b098eacc5bdda529af19d7688"
},
"id" : 1,
"jsonrpc" : "2.0"
}
```
2021-06-09 13:36:50 +03:00
Anna Shaleva
58ab3b5ad1
core: get native nep17 balance from contract storage
...
Not from DAO's items with storage.STNEP17Balances prefix, because
changes are reflected there only after notifications processing. And
this happens only after the transaction script is executed, but there
might be cases when we need to get the balance that was updated
earlier during the same transaction processing.
Affects storage dumps.
2021-04-01 18:37:44 +03:00
Evgeniy Stratonikov
9cb38a4b1b
native: support StorageFee
2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
3278d23852
native: rename Price
to CPUFee
...
Method price is now multiplied by `BaseExecFee`.
2021-03-11 10:12:30 +03:00
Evgeniy Stratonikov
55698d0426
dao: use raw state.StorageItem
instead of pointer
...
It is now a slice, there is no need for additional indirection.
2021-03-09 12:11:25 +03:00
Evgeniy Stratonikov
cbda20aca3
core: fix native method call flags
...
Replace `WriteStates` with `States`.
Follow neo-project/neo#2339.
Close #1775 .
Related #1725 .
2021-02-25 18:07:33 +03:00
Anna Shaleva
4893faa374
core: remove NEP17BalanceState if balance is null [addTokens]
...
Affects states.
2021-02-12 23:48:30 +03:00
Evgeniy Stratonikov
6ca7b4b966
interop: rename ContractID
to ID
...
Helps further refactoring, see next commit.
2021-02-11 12:27:43 +03:00
Roman Khimov
a442e1530d
native: rename onPayment into onNEP17Payment
...
Follow neo-project/neo#2287 .
2021-02-05 16:09:51 +03:00
Roman Khimov
6ecc6f0422
native: call native contracts by ID instead of name
...
Fix #1666 .
2021-01-18 00:38:23 +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
4fa1476c03
native: use Hash160 method parameters where appropriate
...
Partially reverts 33386065bc
, see
neo-project/neo#2183 .
2021-01-12 18:08:12 +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
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
ab12eee346
native: move contract deployment to management contract
...
See neo-project/neo#2119 .
2020-12-14 15:23:46 +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
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
Evgenii Stratonikov
e903e40085
core: call from native contracts synchronously
...
Follow neo-project/neo#2130 .
2020-12-10 16:43:46 +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
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
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
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