Roman Khimov
38f0432f36
core: remove stale storeBlock comment, fix #365
...
After transaction unification and UTXO removal storeBlock became quite simple
and doesn't require any refactoring any more.
2020-07-16 23:06:17 +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
Roman Khimov
f46ed798f0
Merge pull request #1169 from nspcc-dev/neo3/rpc/fields_names_adjustment
...
rpc: adjust RPC calls JSON fields
2020-07-15 18:24:54 +03:00
Anna Shaleva
538616e9f8
rpc: adjust getrawtransaction
RPC-call JSON fields names
...
Part of #1130
2020-07-15 14:44:13 +03:00
Anna Shaleva
a3e306ff78
core: implement Secp256k1 Verify and CheckMultisig interops
...
Closes #918 .
2020-07-14 16:21:34 +03:00
Anna Shaleva
5326fc587a
core: rename Neo.Crypto.CheckMultisig to Neo.Crypto.CheckMultisigWithECDsaSecp256r1
...
Part of #918
2020-07-14 16:19:12 +03:00
Anna Shaleva
17233e1d8e
core: rename Neo.Crypto.Verify to Neo.Crypto.VerifyWithECDsaSecp256r1
...
Part of #918
2020-07-14 16:19:12 +03:00
Roman Khimov
4c23aa1d7c
Merge pull request #1174 from nspcc-dev/neo3/interop/getscriptcontainer
...
core, compiler: return tx from GetScriptContainer interop
2020-07-14 08:58:52 +03:00
Roman Khimov
dafb9eea4d
Merge pull request #1177 from nspcc-dev/no-free-vm-runs
...
No free VM runs
2020-07-14 08:42:13 +03:00
Roman Khimov
db027ad9c5
vm: zero GAS means no GAS, use fee data to properly limit execution
...
We were accepting transactions with zero system fee, but we shouldn't do
that. Also, transaction's verification execution has to be limited by network
fee.
2020-07-14 08:37:29 +03:00
Anna Shaleva
c4f7b06974
core, compiler: return struct from GetScriptContainer interop
...
Closes #1173
2020-07-14 06:04:48 +03:00
Roman Khimov
419d68329c
core: limit GAS available for block verification
2020-07-13 18:24:58 +03:00
Roman Khimov
3134e364b2
core: fix CalculateNetworkFee() for multisig contracts
...
We return m from the vm.ParseMultiSigContract and n is the length of pubs,
invocation script then pushes m signatures for n keys.
2020-07-13 18:05:46 +03:00
Roman Khimov
afc5ee1ded
core: fix ECDSA verifiation price, it's 1000000 and it's defined in crypto
2020-07-13 18:04:50 +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
7eef895061
consensus: use GetNextBlockValidators where appropriate
...
GetValidators without parameter is called upon DBFT initialization and it
should receive validators for the next block (that will create it),
parameterized GetValidators is used for NextConsensus calculation where we
need a list for the current state of the chain.
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
Roman Khimov
fedcc6b6fc
transaction: drop old attributes
...
They're not supported in Neo 3. Also change data encoding to base64 following
Neo 3 changes.
2020-07-10 20:40:27 +03:00
Anna Shaleva
789ee2d3c1
core: do not update mempool while verifying tx
...
Closes #1168
2020-07-09 20:45:59 +03:00
Anna Shaleva
4be1009def
core: refactor checkBalanceAndUpdate
2020-07-09 18:27:20 +03:00
Anna Shaleva
e81ccb7deb
rpc: adjust getblock
RPC-call JSON fields names
...
Part of #1130
2020-07-09 17:34:53 +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
43b28ffa06
core: get rid of NEP5TransferSize
...
Part of #1133
It will help us to use big.Int to store amount of NEP5 tokens. As far as
big.Int doesn't have constant size, we shouldn't use `NEP5TransferSize`
constant anymore.
2020-07-09 13:25:03 +03:00
Evgenii Stratonikov
5787d7775f
transaction: fail creating tx if there is additional data present
2020-07-03 18:03:57 +03:00
Evgenii Stratonikov
27b3054df4
transaction: set feePerByte on tx construction
2020-07-03 17:52:13 +03:00
Evgenii Stratonikov
3097dc60e5
transaction: cache feePerByte
2020-07-03 17:37:01 +03:00
Anna Shaleva
c421805141
core: fixed typo in method description
2020-06-29 21:40:59 +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
Roman Khimov
8ad355b444
Merge pull request #1124 from nspcc-dev/forward-port-from-2.x
...
Forward port from 2.x
2020-06-29 11:52:45 +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
8c18142e8a
keys: implement PublicKeys.Copy()
...
Implement convenient wrapper over explicit allocation and copying.
2020-06-29 10:44:35 +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
Roman Khimov
cab437284d
core: fix TestGetClaimable occasional failures
2020-06-27 12:36:43 +03:00
Roman Khimov
efa8ae5be4
core: fix TestSubscriptions occasional failures
...
panic: Log in goroutine after TestSubscriptions has completed
goroutine 1079 [running]:
testing.(*common).logDepth(0xc00057a100, 0xc00039e210, 0xa4, 0x3)
/usr/local/go/src/testing/testing.go:634 +0x51a
testing.(*common).log(...)
/usr/local/go/src/testing/testing.go:614
testing.(*common).Logf(0xc00057a100, 0xe32eaa, 0x2, 0xc0009560e0, 0x1, 0x1)
/usr/local/go/src/testing/testing.go:649 +0x91
go.uber.org/zap/zaptest.testingWriter.Write(0xf64120, 0xc00057a100, 0x0, 0xc0003fe400, 0xa5, 0x400, 0xc000958e40, 0xc0009560d0, 0xc000958e60)
/go/pkg/mod/go.uber.org/zap@v1.10.0/zaptest/logger.go:130 +0x120
go.uber.org/zap/zapcore.(*ioCore).Write(0xc0005cd050, 0x0, 0xbfb54ffc0626aba2, 0x916de700, 0x1485500, 0x0, 0x0, 0xe43fb0, 0x1c, 0x0, ...)
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/core.go:90 +0x1c5
go.uber.org/zap/zapcore.(*CheckedEntry).Write(0xc000102d10, 0xc00039a000, 0x5, 0x5)
/go/pkg/mod/go.uber.org/zap@v1.10.0/zapcore/entry.go:215 +0x1e8
go.uber.org/zap.(*Logger).Info(0xc00035eba0, 0xe43fb0, 0x1c, 0xc00039a000, 0x5, 0x5)
/go/pkg/mod/go.uber.org/zap@v1.10.0/logger.go:187 +0x96
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).persist(0xc00000cb40, 0xc00017c2c0, 0xbe8a00)
/go/src/github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:839 +0x6c9
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).Run.func2(0xc00000cb40, 0xc0005c6c30)
/go/src/github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:302 +0x54
created by github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).Run
/go/src/github.com/nspcc-dev/neo-go/pkg/core/blockchain.go:301 +0x25d
FAIL github.com/nspcc-dev/neo-go/pkg/core 2.463s
2020-06-25 19:22:38 +03:00
Evgenii Stratonikov
978b3c96fe
native: cache GetValidators result
2020-06-24 19:42:50 +03:00
Roman Khimov
5251607fb7
transaction: s/txid/hash/ for JSON to match C# implementation
...
It uses `hash` for transactions now, but `txid` for application logs.
2020-06-24 10:43:58 +03:00
Roman Khimov
d81d826bfc
core: fix Storage.Get to return Null when there is no value
...
Match C# implementation and fix state inconsistency at block 249920 of
preview2 testnet. Make our Go Storage.Get return nil and adapt
examples/tests.
2020-06-24 10:43:58 +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
d5c9449a43
dao: combine GetNextContractID and PutNextContractID
...
And fix contract create to really update the ID, eliminating this difference
in the storage (preview2 testnet):
file BlockStorage_100000/dump-block-39000.json: block 38043: key mismatch: 0c000000617373657464df4ebe92334d1fc7e64b10f1d1e33942d9905e510000000000000009 vs 00000000617373657464df4ebe92334d1fc7e64b10f1d1e33942d9905e510000000000000009
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
cd2dca0259
state: fix the way NEO balance is being serialized
...
Actually, our format is way better, but for preview2 compatibility we need to
use this one.
2020-06-24 10:21:24 +03:00
Roman Khimov
c124d2bcdf
core: fix gas generation coefficients to match Neo 3
...
Follow neo-project/neo#911 . Fixes state differences at block 4528 of preview2
testnet compared to C# node.
2020-06-24 10:21:24 +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
9f11a55bd6
core: add policy check to mempool
...
After block was stored it's possible to have new FeePerByte constraint,
so we should remove all transactions which do not meet this requirement.
Also caching of FeePerByte was added in order not to re-verify
transactions each time mempool needs to be updated.
2020-06-24 07:58:09 +03:00
Anna Shaleva
ce402a70d2
core: add policy check to (*Blockchain).verifyTx method
...
If any of transaction's script hashes for verifying are included into
Policy blocked accounts list, transaction is invalid.
2020-06-24 07:58:09 +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
8de0332107
*: use MaxTransactionsPerBlock from Policy native contract
...
part of #904
1. We now have MaxTransactionsPerBlock set in native Policy contract,
so this value should be used in (dbft).GetVerified method instead
of passing it as an argument.
2. Removed (dbft).WithTxPerBlock.
2. DBFT API has changed, so update it's version.
3. Removed MaxTransactionsPerBlock from node configuration, as we
have it set in native Policy contract.
2020-06-24 07:58:05 +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
Roman Khimov
a2cd2264a8
core: fix HasStorage check in storageGetContext
...
It was returning nil which is wrong.
2020-06-20 00:04:28 +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
4b31c18316
core: fix Neo.Native.Deploy
price
2020-06-19 12:58:33 +03:00
Evgenii Stratonikov
540ac23ca8
core: calculate prices of Neo.Crypt.*
opcodes correctly
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
Evgenii Stratonikov
81adb7ce83
core: set price getter for native contract persist routine
2020-06-19 11:38:56 +03:00
Roman Khimov
93b0011988
Merge pull request #1069 from nspcc-dev/addr-locking-and-other-fixes
...
Addr, locking and other fixes
2020-06-18 23:29:19 +03:00
Evgenii Stratonikov
e7d8bb92f6
core/tests: extend native contract test
...
Check if native contract's method price is taken into account.
2020-06-18 22:44:10 +03:00
Evgenii Stratonikov
5354352d63
core: remove transaction priority
...
There is no such thing as high/low priority transactions, as there are
no free transactions anymore and they are ordered by fees contained
in transaction itself.
Closes #1063 .
2020-06-18 22:44:10 +03:00
Evgenii Stratonikov
2f724b792c
core: remove config fields related to free transactions
...
In NEO3 every transaction must have some gas attached.
Closes #1064 .
2020-06-18 22:44:08 +03:00
Roman Khimov
1081791c68
core: fix contract manifest unpacking in System.Contract.Create
...
It's just JSON, io.Serializable is only used for DB storage where the length
should be obtained from the stream. Fixes:
2020-06-18T22:14:10.571+0300 WARN contract invocation failed {"tx": "1ffd475a9c246495d6206cb80a9a78e9d14a433ded60cd37aa87d897655606e1", "block": 25893, "error": "error encountered at instruction 3696 (SYSCALL): failed to invoke syscall: invalid character ':' after top-level value"}
2020-06-18 22:38:34 +03:00
Evgenii Stratonikov
84387b2416
core: set gas limit to transaction.SystemFee for all transactions
2020-06-18 22:17:48 +03:00
Roman Khimov
90d3bcbdc3
state: initialize PublicKey before decoding into it, fix #1061
...
These are pointers and decoding into a nil pointer is a bad idea.
2020-06-18 21:59:58 +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
Roman Khimov
f0fbb2d8ff
core: prevent panic on forced exit
...
If we're to close the Blockchain while it's storing a block this might happen:
panic: assignment to entry in nil map
goroutine 63 [running]:
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemoryStore).put(...)
/home/rik/dev/neo-go/pkg/core/storage/memory_store.go:53
github.com/nspcc-dev/neo-go/pkg/core/storage.(*MemCachedStore).Persist(0xc000673a40, 0x0, 0x0, 0x0)
/home/rik/dev/neo-go/pkg/core/storage/memcached_store.go:118 +0x245
github.com/nspcc-dev/neo-go/pkg/core/dao.(*Simple).Persist(0xc003dbdcc0, 0xc003b18900, 0xc002505538, 0xc001c510e0)
/home/rik/dev/neo-go/pkg/core/dao/dao.go:543 +0x2e
github.com/nspcc-dev/neo-go/pkg/core/dao.(*Cached).Persist(0xc003b189c0, 0xc000240000, 0x0, 0x0)
/home/rik/dev/neo-go/pkg/core/dao/cacheddao.go:169 +0x756
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).storeBlock(0xc0001f4000, 0xc003611040, 0x0, 0x10)
/home/rik/dev/neo-go/pkg/core/blockchain.go:647 +0xfa2
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddBlock(0xc0001f4000, 0xc003611040, 0x0, 0x0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:447 +0xee
github.com/nspcc-dev/neo-go/pkg/network.(*blockQueue).run(0xc0006f4120)
/home/rik/dev/neo-go/pkg/network/blockqueue.go:48 +0x158
created by github.com/nspcc-dev/neo-go/pkg/network.(*Server).Start
/home/rik/dev/neo-go/pkg/network/server.go:179 +0x2b5
2020-06-18 21:35:17 +03:00
Evgenii Stratonikov
8a0b2be285
core: process NEP5 transfers emitted by Native.onPersist
...
All GAS is minted/burnt during `onPersist` call.
2020-06-18 16:38:08 +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
295d8fc70e
core: save application logs for native persist
2020-06-18 15:32:27 +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
Roman Khimov
b483c38593
block/transaction: add network magic into the hash
...
We make it explicit in the appropriate Block/Transaction structures, not via a
singleton as C# node does. I think this approach has a bit more potential and
allows better packages reuse for different purposes.
2020-06-18 12:39:50 +03:00
Roman Khimov
8fda6a3407
block: fix ConsensusData hashing
...
It's DoubleSha256 as with the rest of the structures.
2020-06-18 12:22:49 +03:00
Roman Khimov
a7cce3f894
smartcontract: use new VerifiableDecodable for ParameterContext
...
And implement it for Transaction, the only user of ParameterContext for
now. Which make correct signing/verifying possible for cases when
serialization for general transmission and signing differ.
2020-06-18 12:12:56 +03:00
Roman Khimov
0002b65238
block: it's not a padding, but a witness count in the base
...
At least that's the interpretation C# codebase has, so be a bit more correct
in error message.
2020-06-18 12:12:00 +03:00
Roman Khimov
b9a66c64e1
block: drop paddings from structures
...
It makes no sense at all storing them in a structure, they're just a part of
encoding/decoding process.
2020-06-18 12:11:41 +03:00
Roman Khimov
26f11a52d9
config: move NetMode into its own micropackage
...
It's going to be used a bit more and pulling whole config just for one type is
a bit wrong.
2020-06-18 12:09:57 +03:00
Roman Khimov
5f276de003
Merge pull request #1057 from nspcc-dev/fix/newaddress
...
Update addresses to NEO3 format
2020-06-17 16:25:32 +03:00
Evgenii Stratonikov
7b4ca57e33
*: change address to the new format
...
NEO3 uses new prefix for address (53 = 0x35), thus string representations as
well as encrypted WIFs should be changed.
2020-06-17 15:58:21 +03:00
Evgenii Stratonikov
3762ebdd08
core: implement System.Runtime.GetInvocationCounter syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
75e597f880
core: implement System.Runtime.GetNotifications syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
a4e4439967
core,vm: implement System.Runtime.GasLeft syscall
2020-06-17 11:24:11 +03:00
Evgenii Stratonikov
a7d4fff897
vm: make (*VM).GasLimit public
...
VM is inherently single-threaded and replacing setter/getter methods
with public field simplifies code a bit.
2020-06-16 15:13:20 +03:00
Evgenii Stratonikov
1f97f3abd8
core: adjust prices and flags for System.Runtime.* interops
...
Related #1055 .
2020-06-16 12:30:55 +03:00
Evgenii Stratonikov
ad2a75a500
core: move System.ExecutionEngine.* interops to System.Runtime.*
2020-06-16 12:30:55 +03:00
Evgenii Stratonikov
52a27e9be4
core: implement System.Contract.CreateStandardAccount syscall
2020-06-16 12:12:29 +03:00
Evgenii Stratonikov
5b4f38d717
core: implement System.Contract.IsStandard syscall
2020-06-16 12:12:27 +03:00
Evgenii Stratonikov
b1d2d70c02
core: adjust prices for blockchain/contract syscalls
2020-06-16 12:04:57 +03:00
Evgenii Stratonikov
6339efac11
core: implement System.Json.* interops
2020-06-16 11:35:06 +03:00
Evgenii Stratonikov
aae312d408
core,vm: adjust prices for iterator/enumerator syscalls
...
Closes #1027 .
2020-06-16 11:05:26 +03:00
Evgenii Stratonikov
18066143bd
core,vm: adjust binary (de-)serialization syscalls
...
Related #1027 .
1. Move System.Runtime.(De)serialize to System.Binary.*
2. Rename compiler stubs.
3. Adjust opcode prices.
2020-06-16 11:00:38 +03:00
Roman Khimov
b3507d490d
Merge pull request #1051 from nspcc-dev/neo3/rpc/scopes
...
core: add json marshaller for Cosigner's scopes
2020-06-15 16:13:48 +03:00
Anna Shaleva
3568ab3d6d
core: add json marshaller for Cosigner's scopes
...
Following C# implementation, we should marshal Scopes as a set of
strings instead of single byte.
2020-06-15 13:48:15 +03:00
Evgenii Stratonikov
2e996ea57d
core: adjust System.Storage.*
interop prices
2020-06-15 12:02:28 +03:00
Evgenii Stratonikov
61bba1a39c
core: store precise gas price in interop descriptions
...
In NEO3 sycalls can have prices less than 10^5, we need to store them
precisely. Adjusting actual prices is to be done in the following tasks.
2020-06-15 12:02:28 +03:00
Evgenii Stratonikov
fd2cd291e7
core: calculate opcode prices correctly
2020-06-15 12:02:22 +03:00
Evgenii Stratonikov
8f20a70969
core: calculate a price of System.Storage.Put
correctly
...
It also depends on the item already stored by key.
2020-06-15 12:02:21 +03:00
Roman Khimov
fe31c7ed2d
Merge pull request #1047 from nspcc-dev/neo3/rpc/invoke
...
rpc: update invoke* RPC-calls
2020-06-11 21:39:20 +03:00
Anna Shaleva
9e7fca013e
rpc: update CLI and RPC client invoke* calls
...
part of #1036
2020-06-11 20:32:05 +03:00
Anna Shaleva
d5355acfa9
rpc: update RPC server invoke* calls
...
part of #1036
2020-06-11 19:34:13 +03:00
Evgenii Stratonikov
971ab0646f
core: specify allowed triggers for interops
...
Related #1026 , #1027 , #1028 , #1031 .
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
b12add5a78
smartcontract: rewrite trigger types for NEO3
2020-06-11 13:16:07 +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
bda94c74c3
vm: check calling flags on syscall invocation
2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
55ab7535be
core: optimize contractCallEx
...
Provide script hash upon script load.
2020-06-11 13:06:10 +03:00
Evgenii Stratonikov
a86e1910e1
core: remove unused interops
...
Missed in #1040 .
2020-06-11 10:51:19 +03:00
Evgenii Stratonikov
f8a11f61b6
core: update *.Contract.* interops
...
1. Remove GetScript, IsPayable, GetStorageContext.
2. Revert 82319538
related to GetStorageContext.
3. Rename Migrate to Update.
4. Move remaining to System.Contract.*.
Related #1031 .
2020-06-11 10:50:35 +03:00
Evgenii Stratonikov
c69f8a2fa3
core: check for permission in System.Contract.Call(Ex)
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
5514b3f52f
smartcontract,vm: remove DynamicInvoke feature
...
It doesn't exist in NEO3.
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
a03af55732
core: provide monotonically increasing ID for contracts
...
ID is a contract identifier which doesn't change during migration.
It is also used as a part of storage context instead of contract hash.
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
20616cc97f
interop: perform contract checks in CheckWitness
2020-06-11 10:45:25 +03:00
Evgenii Stratonikov
7256efd1ed
vm: implement (*VM).AddGas
...
Calculating interop prices can be tricky. It is more convenitent to burn
gas inside interops where necessary parameters are popped.
2020-06-11 10:45:25 +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
Evgenii Stratonikov
38d020d1a2
core: move Neo.Storage.* interops to System.*
2020-06-10 12:13:35 +03:00
Evgenii Stratonikov
0472a0b0b1
core: move Neo.Runtime/Enumerator/Iterator.* interops to System.*
2020-06-10 12:13:35 +03:00
Evgenii Stratonikov
97c6ac7a73
core: move Neo.Blockchain.* syscalls to System.*
2020-06-10 12:13:18 +03:00
Evgenii Stratonikov
3d3fe9398e
core: remove Neo.Header/Witness/Account.* interops
...
They are not present in NEO3.
2020-06-10 12:13:18 +03:00
Anna Shaleva
8b7abd36c9
core: remove Block.GetTransactions, Block.GetTransactionsCount interops
...
Updated System.Blockchain.GetBlock interop replaced the functionality of
the following interops:
System.Block.GetTransactions
System.Block.GetTransactionCount
Neo.Block.GetTransactions
Neo.Block.GetTransactionsCount
2020-06-09 23:24:11 +03:00
Anna Shaleva
7a2d37cf7e
core: update System.Blockchain.GetBlock interop
...
closes #1025
Now we put on stack stackitem.Array instead of Interop, so we're able to
use all available block properties without extra interop getters.
Removed Neo.Blockchain.GetBlock interop as we don't need it anymore.
2020-06-09 23:24:04 +03:00
Anna Shaleva
e2187c0a96
core: remove Block.GetTransaction interops
...
Removed Neo.Block.GetTransaction and System.Block.GetTransaction
interops. These interops were replaced by new
System.Blockchain.GetTransactionFromBlock interop.
2020-06-09 22:54:21 +03:00
Anna Shaleva
d692de5ea4
core: add System.Blockchain.GetTransactionFromBlock interop
2020-06-09 22:54:16 +03:00
Anna Shaleva
1e63ae4b3f
core: update System.Blockchain.GetTransactionHeight interop
...
Update System.Blockchain.GetTransactionHeight and removed
Neo.Blockchain.GetTransactionHeight interop as we don't need it.
2020-06-09 22:04:18 +03:00
Anna Shaleva
53655c5ac2
core: implement new System.Blockchain.GetTransaction interop
...
closes #1023
Now we put on stack stackitem.Array instead of Interop, so we don't
need old transaction-related interops anymore. Removed the following
interops:
System.Transaction.GetHash
Neo.Transaction.GetAttributes
Neo.Transaction.GetHash
Neo.Transaction.GetWitnesses
Neo.Attribute.GetData
Neo.Attribute.GetUsage
Also removed the following duplicated NEO interop:
Neo.Blockchain.GetTransaction
2020-06-09 22:04:13 +03:00
Anna Shaleva
f2e3be6fef
core: remove old AntShares interops
...
We don't need them anymore.
2020-06-09 20:54:00 +03:00
Roman Khimov
795523f5cd
Merge pull request #1013 from nspcc-dev/neo3/vm/stackitem_refactoring
...
vm: move StackItem to a separate package
2020-06-08 15:30:44 +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
Evgenii Stratonikov
138385e512
transaction: encode Script in base64
2020-06-08 10:31:51 +03:00
Evgenii Stratonikov
1fa25efa79
transaction: encode witness scripts in base64
2020-06-08 10:23:56 +03:00
Roman Khimov
63f4f34659
mempool: drop TxWithFee type
...
All the fees are in transaction, this makes no sense.
2020-06-05 19:21:40 +03:00
Roman Khimov
a986e2a064
*: drop support for old on-chain assets
...
You no longer can transfer them, so creating/renewing/storing doesn't make
much sense.
2020-06-05 19:21:37 +03:00
Roman Khimov
bf6435eeaa
storage: drop STValidator prefix, it's not used
2020-06-05 19:20:16 +03:00
Roman Khimov
709146f295
transaction: drop Inputs and Outputs, forget UTXO
2020-06-05 19:20:16 +03:00
Roman Khimov
21efccd300
transaction: remove type field, set Version to 0
...
Two changes being done here, because they require a lot of updates to
tests. Now we're back into version 0 and we only have one type of
transaction.
It also removes GetType and GetScript interops, both are obsolete in Neo 3.
2020-06-05 19:20:16 +03:00
Roman Khimov
dfb26f9ab2
block: don't attempt verification if there was a decoding error
2020-06-05 19:20:16 +03:00
Roman Khimov
f63b286c35
core: update genesis block to store timestamp in ms
2020-06-05 19:20:16 +03:00
Roman Khimov
35b30ccfdf
core: drop OLDPUSH1, it's no longer needed
...
Fixes #927 .
2020-06-05 19:20:16 +03:00
Roman Khimov
0a09a20900
transaction: drop Register transaction type
...
And everything associated like SystemFee configuration.
2020-06-05 19:20:16 +03:00
Roman Khimov
169c5ae775
transaction: drop Issue TX support
2020-06-05 19:20:16 +03:00
Roman Khimov
f445f7c602
transaction: drop Contract transaction type
2020-06-05 19:20:16 +03:00
Roman Khimov
6853470603
block: precompute ConsensusData hash on UnmarshalJSON
...
That's what we usually do for block or transaction hashes.
2020-06-05 19:20:16 +03:00
Roman Khimov
dfc7a9bfd1
transaction: drop Claim TX type
2020-06-05 19:20:16 +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
1bc6d29c0d
core: fix potential NPE in GetUtilityTokenBalance
2020-06-05 19:20:16 +03:00
Roman Khimov
9f5fd21160
core: drop UXTO NEO and GAS transactions from the genesis block
...
They're no longer required. Adjust test chain for that, now it only has
invocations, transfers NEO/GAS and pays the fees with NEP5 GAS.
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
657bb7575e
rpc: change getunclaimed to getunclaimedgas
...
getunclaimed doesn't exist on Neo 3 and getunclaimedgas works for NEP5 GAS.
2020-06-05 19:20:16 +03:00
Roman Khimov
31ef0c4339
core: don't check systemfee with UTXO outputs
...
SystemFee is already being checked by verifyTx against Sender's balance.
2020-06-05 19:20:16 +03:00
Roman Khimov
d9400800e3
transaction: drop Gas field from InvocationTX
...
It essentialy is the new SystemFee, so use that. Had to increase GAS transfer
in test chain to 1000 to pay for deployment.
2020-06-05 19:20:16 +03:00
Roman Khimov
30c74152ce
core: add balance checks for NEP5 transfer to TestCreateBasicChain
2020-06-05 19:20:16 +03:00
Roman Khimov
0a35ee00c6
core: print txes in LE in TestCreateBasicChain
...
LE is human and RPC compatible representation, BE hex is almost unusable.
2020-06-05 19:20:16 +03:00
Roman Khimov
bf6525e54d
core: fix GetUtilityTokenBalance
...
The value stored in NEP5 tracker for GAS is Fixed8 already, so we need to
type-cast it, but not multiply by 10⁸ again.
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
Evgenii Stratonikov
44709cf6fe
core: make GetUnspentCoins interop return array, fix #978 .
2020-05-27 12:01:50 +03:00
Roman Khimov
8231953842
core: fix Neo.Contract.GetStorageContext security check
...
This syscall should only work for contracts created by current transaction and
that is what is supposed to be checked here. Do so by looking at the
differences between ic.dao and original lower DAO.
2020-05-26 19:58:49 +03:00
Roman Khimov
7633439845
rpc/block: rework the way Block is JSONized
...
Our block.Block was JSONized in a bit different fashion than result.Block in
its NextConsensus and Index fields. It's not good for notifications because
third-party clients would probably expect to see the same format. Also, using
completely different Block representation is probably making our client a bit
weaker as this representation is harder to use with other neo-go components.
So use the same approach we took for Transactions and wrap block.Block which is
to be serialized in proper way.
Fix `Script` JSONization along the way, 3.0 node wraps it within `witnesses`.
2020-05-26 11:36:47 +03:00
Roman Khimov
2dc16c0694
transaction: add json.Unmarshaler to Attribute
...
It actually was missing and it might affect Transaction conversion to/from
JSON.
2020-05-26 11:36:47 +03:00
Roman Khimov
44ae9086b6
core: improve and fix locking in storeBlock
...
Getting batch, updating Prometheus metrics and pushing events doesn't require
any locking: batch is a local cache batch that no one outside cares about,
Prometheus metrics are not critical to be in perfect sync and events are
asynchronous anyway.
Native contracts also don't require any locks and they should be processed
before dumping storage changes.
2020-05-26 11:36:47 +03:00
Roman Khimov
3ca71d5e8d
core: add Blockchain event subscription mechanism
...
A deep internal part of #895 . Blockchainer interface is also extended for
various uses of these methods.
2020-05-25 00:27:39 +03:00
Roman Khimov
ac40d357f0
core: improve documentation a little
2020-05-24 23:54:01 +03:00
Roman Khimov
c9b1d359d8
core: ensure we produce correct blocks for tests
...
Check for correct merkle root generation.
2020-05-24 23:52:54 +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
1afd630169
core: add senders' fees monitor to mempool
...
In order to simplify maintainance of overall current senders` fees
in the mempool we are to keep them in a separate map.
2020-05-20 23:34:25 +03:00
Anna Shaleva
7acf5b2841
core: add SystemFee and NetworkFee to transaction
...
closes #831
2020-05-20 23:26:48 +03:00
Anna Shaleva
fc3acdc80c
core: add native contracts' hashes getters
2020-05-20 23:16:04 +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
Anna Shaleva
4ebac5a069
core: fix bug in nep5 notifications handling
...
Native contracts deployment creates `Transfer` notifications and adds
them into interop context. However, these notifications were not stored
for two reasons:
1. typo in `Transfer` (so these notifications were not recognised during
processing of the invocation tx in (*Blockchain).storeBlock(...) method)
2. these notifications have `from` adress setted to null, so conversion
to []byte fails. Same thing could happen with `to`.
Related C# issue: https://github.com/neo-project/neo/issues/1646
For now, made both `transfer` and `Transfer` valid.
2020-05-20 23:16:04 +03:00
Evgenii Stratonikov
c0147c76ac
emit: remove tailCall argument from AppCall
...
There is no TAILCALL opcode in NEO3.
2020-05-07 14:59:01 +03:00
Evgenii Stratonikov
73c82584a3
vm,compiler: replace APPCALL with System.Contract.Call
...
Contract calls are performed via syscall System.Contract.Call
in NEO3. This implements this in compiler and removes APPCALL from the
VM.
2020-05-07 14:52:03 +03:00
Evgenii Stratonikov
ec900c7ff7
core: implement System.Contract.Call interop
2020-05-07 14:39:06 +03:00
Evgenii Stratonikov
301c1b7601
native: save native contract state on deploy
2020-05-07 14:03:14 +03:00
Evgenii Stratonikov
f9f3192b48
vm: move RET and SYSCALL opcodes
2020-05-07 13:23:05 +03:00
Evgenii Stratonikov
5ab4b9284b
core: remove unused function from tests
2020-05-06 16:00:16 +03:00
Evgenii Stratonikov
977c431bf1
vm: implement ASSERT/ABORT opcodes
...
Rename THROWIFNOT to ASSERT, add ABORT opcode.
ABORT cannot be caught, but the implementation should be postponed until
exception handling is implemented.
2020-05-06 15:54:19 +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
Anna Shaleva
d1ec01c45e
util: implement Serializable interface over Uint160
2020-05-04 11:49:14 +03:00
Anna Shaleva
08f5708edb
core: remove Script attribute type
2020-05-04 11:49:14 +03:00
Evgenii Stratonikov
519b31a704
vm: remove crypto-related opcodes
...
All cryptography has moved to interops in NEO3.
There is no SHA256 interop RN, but it is to appear later.
Closes #777 .
2020-04-29 19:16:38 +03:00
Roman Khimov
c1aa96d614
Merge pull request #911 from nspcc-dev/feature/convert
...
vm: implement CONVERT opcode
2020-04-28 18:08:36 +03:00
Evgenii Stratonikov
be38798785
vm: move Bool method to the StackItem interface
2020-04-28 15:13:41 +03:00
Anna Shaleva
fa467ce628
core: add txes duplication check on block.DecodeBinary
2020-04-27 18:00:01 +03:00
Anna Shaleva
29d321b5e1
*: drop miner transaction
...
1. Completely remove miner transaction
2. Change validation rule for block: block without transactions is
valid.
2020-04-27 17:57:37 +03:00
Anna Shaleva
55fd9f8d24
core: change block.ConsensusData to neo3 format
...
1. Dropped `Base.ConsensusData` block field
2. Added `Block.ConsensusData` field with `Nonce` and `PrimaryIndex`
3. Removed "Neo.Header.GetConsensusData" and
"AntShares.Header.GetConsensusData" interops
2020-04-27 17:57:37 +03:00
Anna Shaleva
0de5cb1bde
core, consensus: nanoseconds-precision timestamp
...
Keep timestamp of consensus messages in nanoseconds-precision state
2020-04-27 17:57:32 +03:00
Anna Shaleva
aa554f0a9a
core: update block timestamp format
...
Changed block.Timestamp from uint32 to uint64
2020-04-27 17:56:44 +03:00
Roman Khimov
e6f5cffff6
transaction: drop Enrollment and State types
...
They're completely replaced now by the NEO native contract voting system.
2020-04-27 16:06:58 +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
7caa81a81c
rpc/test: generate block for submitblock on-the-fly
...
There is no need to provide hex when chain is dumped.
2020-04-24 08:54:22 +03:00
Evgenii Stratonikov
0f17402599
testchain: implement Sign function
...
Sign any data by all consensus nodes.
2020-04-23 17:09:09 +03:00
Evgenii Stratonikov
008e6eb233
vm: implement new PUSH opcodes
2020-04-23 10:52:28 +03:00
Evgenii Stratonikov
cc20ba651d
core: use opcodes instead of raw bytes in tests
...
It will be helpful during future opcode reordering in NEO3.
2020-04-23 10:37:01 +03:00
Evgenii Stratonikov
351fdd469f
core: calcultate NEO owner on-the-fly
2020-04-23 10:36:44 +03:00
Evgenii Stratonikov
1e50016a91
core,test: move helper functions for testchain to the internal package
...
Our test chain is used in core,rpc and (in future) interop packages.
It is better to have all related declarations in one place to avoid
code duplication.
2020-04-22 18:17:11 +03:00
Evgenii Stratonikov
c508a36827
core,network: shutdown services in tests properly
2020-04-22 17:53:59 +03:00
Anna Shaleva
2b5c14160c
core: add sender field to transaction
...
closes #860
2020-04-20 17:21:28 +03:00
Evgenii Stratonikov
cde4ccf01c
vm: remove CHECKSIG/VERIFY/CHECKMULTISIG opcodes
2020-04-20 11:55:24 +03:00
Evgenii Stratonikov
4740d937aa
vm: dont use SetCheckedHash outside of vm
package
2020-04-20 11:55:24 +03:00
Evgenii Stratonikov
941410a840
core: change verification scripts to new format
...
Verification scripts now invoke Neo.Crypto.* interops instead of
CHECKSIG/VERIFY opcodes.
2020-04-20 11:55:24 +03:00
Roman Khimov
ab8296bc57
Merge pull request #857 from nspcc-dev/neo3/verifiable
...
core,crypto: implement Verifiable interface
2020-04-17 13:06:55 +03:00
Evgenii Stratonikov
ceff8736f2
vm: use ID-based syscalls
...
In NEO3 SYSCALL opcode has 4-byte ID parameter.
This commit removes support for string-based syscalls and
changes SYSCALL's parameter to be fixed 4-byte value.
2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
bfbbef952a
vm: move InteropNameToID to emit package
2020-04-17 11:46:31 +03:00
Evgenii Stratonikov
82b230f19f
core: rename *block.Base.GetHashableData to GetSignedPart()
...
This allow to use `Block` as a Verifiable item.
When tx is provided, it is set as an interop's script container.
Otherwise, block is set.
2020-04-17 11:12:40 +03:00
Evgenii Stratonikov
a92872931c
interop/crypto: allow ECDsaVerify to verify ScriptContainer
...
When verifying transaction or block, verification script can be
a simple PUSHNULL + SYSCALL, which means that script-encontaining
entity should be verified.
2020-04-17 11:12:40 +03:00
Evgenii Stratonikov
8f08065a8e
interop/crypto: allow ECDsaVerify to accept interop items
...
When invokes with interop item on stack, it should check
for the signature of Verifiable item it contains.
2020-04-17 11:12:40 +03:00
Roman Khimov
888be75445
Merge pull request #863 from nspcc-dev/drop-publish-tx
...
Drop publish tx
2020-04-16 21:23:37 +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
Evgenii Stratonikov
9586af32f2
core: move runtime.CheckWitness interop to a separate package
2020-04-16 15:54:58 +03:00
Evgenii Stratonikov
8a2130f5b6
core: extend Blockchainer with GetStandByValidators()
...
A list of standby validators can be needed in native contracts.
2020-04-16 15:54:58 +03:00
Evgenii Stratonikov
b446753c57
core,vm: move get/putContextScriptHash to vm
package
2020-04-16 15:54:52 +03:00
Roman Khimov
40991d3be3
transaction: drop AgencyType and VotingType
...
I have no idea what are they about.
2020-04-16 14:44:46 +03:00
Roman Khimov
4912e4f425
*: drop Publish transaction type
...
It shouldn't be used even in NEO 2 as it was substituted by contract
deployment interop functions.
2020-04-16 14:40:20 +03:00
Anna Shaleva
5fa11987d2
core: add validUntilBlock field to transaction
...
1. closes #841
2. Commented out test cases where binary transaction are used.
These test cases marked with `TODO NEO3.0: Update binary` and need to be
updated.
3. Updated other tests.
4. Added cache to calculateValidUntilBlock() RPC-client method.
2020-04-15 13:46:43 +03:00
Roman Khimov
1e3c36433f
Merge pull request #844 from nspcc-dev/neo3/nonce
...
core: add nonce field to transaction
2020-04-14 16:24:02 +03:00
Anna Shaleva
65503aa9b4
core: add nonce field to transaction
...
1. Closes #840 : added Nonce field to transaction.Transaction and
removed Nonce field from transaction.MinerTx
2. Added following methods to different tx types:
- NewMinerTx()
- NewMinerTxWithNonce(...)
- NewEnrollmentTx(...)
- NewIssueTx()
- NewPublishTx(...)
- NewRegisterTx(...)
- NewStateTx(...)
in order to avoid code duplication when new transaction is created.
3. Commented out test cases where binary transaction/block are used.
These test cases marked with `TODO NEO3.0: Update binary` and need to be
updated.
4. Updated other tests
5. Added constant Nonce to GoveringTockenTx, UtilityTokenTx and genesis
block to avoid data variability. Also marked with TODO.
2020-04-14 16:19:41 +03:00
Evgenii Stratonikov
a99e0d7ba6
core: fix typo in TestECDSAVerify
2020-04-14 16:15:50 +03:00
Roman Khimov
ace5614a3d
Merge pull request #783 from nspcc-dev/neo3/movecrypto
...
Implement Neo.Crypto.* interops
2020-04-14 15:54:30 +03:00
Roman Khimov
c40d7aa7f4
core: bump DB version to make it differ from 2.0 branch
2020-04-14 12:54:57 +03:00
Evgenii Stratonikov
c23af595c9
core: implement Neo.Crypto.ECDsaCheckMultisig interop
2020-04-13 13:47:39 +03:00
Evgenii Stratonikov
5a30af2c75
core: implement Neo.Crypto.ECDsaVerify interop
2020-04-13 13:46:31 +03:00
Evgenii Stratonikov
1611ede58c
crypto/keys: implement NewPublicKeyFromBytes()
...
It is convenient to have a single function instead of
allocating new `PublicKey` and using `DecodeBytes()` on it.
2020-04-13 13:13:15 +03:00
Anna Shaleva
d1f92a585b
core: add NewTransactionFromBytes method to Transaction
...
Added `NewTransactionFromBytes(b []byte)` method to
transaction.Transaction in order to avoid code duplication.
2020-04-13 12:04:43 +03:00
Evgenii Stratonikov
30cc2c5783
core: move enumerator/iterator interops to a separate packages
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
7ffc6c0936
core: move interopContext to a separate package
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
90a08986d6
core: fix typo in function doc-comment
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
89d1f7ce75
core: remove unneeded comment
...
Serialization interops are already implemented.
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
a7c19d445b
core: move Blockchainer interface to a separate package
2020-04-11 10:56:36 +03:00
Evgenii Stratonikov
efddcf3bfe
core: remove interop methods from interopContext
...
If interops are defined as a separate functions
they can be implemented in a separate packages
which can help us to structure core.
2020-04-11 10:56:35 +03:00
Anna Shaleva
54cdfe4a23
storage: add support of BadgerDB
...
closes #820
2020-04-09 13:55:59 +03:00
Evgenii Stratonikov
ee0ba9b1b4
core: make SpawnVM a method of context
...
spawnVMWithInterops is rather long too type and
it doesn't use Blockchain in any way.
2020-04-08 08:38:45 +03:00
Evgenii Stratonikov
a71cd0961e
core/dao: remove unnecessary slice type
...
It is used only once, so a simple `sort.Slice`
invocation will suffice.
2020-04-08 08:38:45 +03:00
Evgenii Stratonikov
030b7754ad
core: move DAO to a separate package
2020-04-08 08:38:44 +03:00
Roman Khimov
9997661998
Merge pull request #821 from nspcc-dev/fix-cache-propagation-to-invocations
...
core: wrap cached dao properly, don't miss cached data
2020-04-06 11:52:41 +03:00
Evgenii Stratonikov
1fcc019bf3
rpc: update test chain
...
Also provide info for getblockheader RPC while
generating test chain.
2020-04-06 09:31:09 +03:00
Roman Khimov
5f09381cf4
core: wrap cached dao properly, don't miss cached data
...
Fixes #817 where invoked contract missed updated account information because
it got it one layer below cachedDao used to process the block.
2020-04-03 10:15:11 +03:00
Roman Khimov
2d0ad30fcf
vm: rework Map with internal slice representation
...
Which makes iterating over map stable which is important for serialization and
and even fixes occasional test failures. We use the same ordering here as
NEO 3.0 uses, but it should also be fine for NEO 2.0 because it has no
defined order.
2020-04-01 19:33:53 +03:00
Roman Khimov
9b5dab57e8
Merge pull request #810 from nspcc-dev/refactor/config
...
config: move config.go out of config
2020-04-01 10:29:57 +03:00
Anna Shaleva
5a984fdf88
config: move config.go out of config/
...
closes #423
2020-03-31 17:55:59 +03:00
Roman Khimov
e41853d0a4
Merge pull request #789 from nspcc-dev/fix/tx_specific_data_marshalling
...
rpc: fix marshalling of type-specific tx data
2020-03-30 16:10:25 +03:00
Anna Shaleva
9c09ad9c89
rpc: fix marshalling of type-specific tx data
...
closes #585
2020-03-30 15:48:50 +03:00
Roman Khimov
237de73dec
Merge pull request #807 from nspcc-dev/optimize-memcached-persist
...
storage: optimize (*MemCachedStore).Persist for memory-backed ps
2020-03-29 13:41:21 +03:00
Roman Khimov
4758de71ec
storage: optimize (*MemCachedStore).Persist for memory-backed ps
...
Most of the time it's persisted into the MemoryStore or MemCachedStore, when
that's the case there is no real need to go through the Batch mechanism as it
incurs multiple copies of the data.
Importing 1.5M mainnet blocks with verification turned off, before:
real 12m39,484s
user 20m48,300s
sys 2m25,022s
After:
real 11m15,053s
user 18m2,755s
sys 2m4,162s
So it's around 10% improvement which looks good enough.
2020-03-28 17:21:50 +03:00
Roman Khimov
c738975b7b
Merge pull request #803 from nspcc-dev/feature/appcall
...
emit: implement AppCallWithOperationAndArgs
2020-03-27 13:30:48 +03:00
Evgenii Stratonikov
db2dccf7cb
emit: implement AppCallWithOperationAndArgs
...
It is nice to have a typical task of calling contract method
with specific arguments incapsulated inside some function.
2020-03-27 11:05:36 +03:00
Evgenii Stratonikov
0036b3e52b
random: make use or random package in tests
...
Also implement Bytes/Fill routines for generating byte slices.
2020-03-27 10:27:46 +03:00
Evgenii Stratonikov
9abda40171
testserdes: implement helpers for encode/decode routines
...
Frequently one needs to check if struct serializes/deserializes
properly. This commit implements helpers for such cases including:
1. JSON
2. io.Serializable interface
2020-03-27 10:27:46 +03:00
Evgenii Stratonikov
fcc4877f43
go.mod: update boltdb to v1.3.4
...
Also import lib as declared in it's go.mod:
via `go.etcd.io/bbolt`.
2020-03-25 17:07:54 +03:00
Evgenii Stratonikov
c992d6c518
core: reuse buffer in (*cacheddao).Persist()
...
When serializing multiple accounts, cost of a buffer grow
can become significant. This commit tries to amortize it by
reusing the same buffer in a single `Persist()` call.
2020-03-25 13:13:54 +03:00
Evgenii Stratonikov
6ed2bd63b9
core: marshal AppExecResult.Stack as an array
...
Closes #782 .
2020-03-23 16:27:47 +03:00
Roman Khimov
8400f0add2
mempool: gofmt -s
2020-03-17 16:47:51 +03:00
Roman Khimov
ec76a0bf15
mempool: disallow more than one issue tx at once
...
Technically they could conflict for available asset amount, but as they're
very rare (and even can be considered obsolete) we can simplify this check.
2020-03-17 11:40:01 +03:00
Roman Khimov
d5d0479671
core: verify results of issue transaction
...
It shouldn't try to issue more tokens than there is available.
2020-03-17 11:40:01 +03:00
Roman Khimov
10601cb375
core: add issuer hashes into the verification list for Issue TX
...
As it should be done.
2020-03-17 11:40:00 +03:00
Roman Khimov
dca637d2d0
core: add owner hash to verified list for Register TX
...
As it should be done.
2020-03-17 11:37:02 +03:00
Roman Khimov
77a799f7d0
core: add missing state tx verifications
2020-03-16 20:14:59 +03:00
Roman Khimov
6ede65610d
core: add appropriate hashes to check for State TX
...
These checks are important for proper transaction verification.
2020-03-16 19:52:28 +03:00
Evgenii Stratonikov
b193e78def
core: remove duplication from IsDoubleClaim/IsDoubleSpend
2020-03-16 14:11:19 +03:00
Evgenii Stratonikov
cdf025bf89
transaction: implement AddVerificationHash() method
2020-03-16 14:11:19 +03:00
Roman Khimov
e9429374aa
Merge pull request #756 from nspcc-dev/feature/unclaimed
...
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 13:21:23 +03:00
Evgenii Stratonikov
e503d1001d
core/state: do not unmarshal Unclaimed balances in account
2020-03-16 12:19:32 +03:00
Roman Khimov
e6e8761d35
core: fix contract's state migration and don't swallow errors
...
Fixes difference in state changes at mainnet's block 2442790 because contract
migration in b4eb2dc35226e6520ee4e09a56197dff91547b50a7f57edc82930fc18c75dffc
doesn't actually transfer the storage state, it only deletes the old one.
And add an error check just in case.
2020-03-16 11:52:09 +03:00
Roman Khimov
d9a83373ed
Merge pull request #748 from nspcc-dev/feature/splitnep5
...
core: store NEP5 balances separately from account
2020-03-12 18:31:25 +03:00
Evgenii Stratonikov
ac475940a0
core: cache NEP5Transfers in cached DAO
2020-03-12 17:16:11 +03:00
Evgenii Stratonikov
6fa2a998f4
core: cache NEP5Balances in cached DAO
2020-03-12 17:06:20 +03:00
Evgenii Stratonikov
32401a567e
core: store NEP5Transfers in batches
...
This is an append-only log which is read only during some RPCs.
It is rather slow to get it from base every time we need to append to
it. This commit stores all NEP5Transfers in batches, so that
only a last batch needs to be unmarshaled during block processing.
2020-03-12 14:51:12 +03:00
Evgenii Stratonikov
3c6d9653b0
core/state: add Size() method to NEP5TransferLog
2020-03-12 12:58:30 +03:00
Evgenii Stratonikov
df2598c8dc
core: store NEP5 balances separately
...
There is no need to take and unmarshal an account structure only
to get it's NEP5 balances.
2020-03-12 12:58:28 +03:00
Roman Khimov
bbd802681e
cli: make gas parameter to deployment add gas to the base price
...
That's how it was intended to behave originally. One thing questionable here
is contract price (policy thing, basically) being moved to smartcontract
package, but it's probably fine for NEO 2.0 (as it won't change) and we'll
make something better for NEO 3.0.
2020-03-11 20:34:36 +03:00
Roman Khimov
5f1868af28
Merge pull request #743 from nspcc-dev/optimize-some-db-accesses
...
Optimize some db accesses
2020-03-11 17:33:36 +03:00
Roman Khimov
abd7855890
Merge pull request #742 from nspcc-dev/add-dynamic-appcall
...
vm: add support for dynamic invocations in APPCALL
2020-03-11 17:27:05 +03:00
Roman Khimov
8c902a7223
core: cache UnspentCoins in cachedDao
...
1.5M block import time (VerifyBlocks disabled) on AMD Ryzen 5 1600/16GB/HDD,
before:
real 159m16.551s
user 69m58.279s
sys 7m34.334s
after:
real 139m41.836s
user 67m12.477s
sys 6m19.420s
12% which is even a bit more than could be expected from inputs analysis (that
has around 10% cache hits for a block-wide cache), worth doing.
2020-03-11 12:40:02 +03:00
Roman Khimov
23464401bc
core/state: merge spent and unspent coins state, use it to store more things
...
This change reduces pressure on DB by doing the following things:
* not storing additional KV pair for SpentCoin
* storing Output right in the UnspentCoin, thus eliminating the need to get a
full transaction from DB
At the same time it makes UnspentCoin more fat and hot, but it should probably
worth it.
Also drop `GetUnspentCoinStateOrNew` as it shouldn't ever existed, UTXOs
can't come out of nowhere.
1.5M block import time (VerifyBlocks disabled) on AMD Ryzen 5 1600/16GB/HDD,
before:
real 302m9.895s
user 96m17.200s
sys 13m37.084s
after:
real 159m16.551s
user 69m58.279s
sys 7m34.334s
So it's almost two-fold which is a great improvement.
2020-03-11 12:40:02 +03:00
Roman Khimov
e1f194ea7b
core: treat state.Coin as a bitfield
...
As it was intended to.
2020-03-11 12:22:57 +03:00
Roman Khimov
377fb382aa
core: move (un)SpentCoin structs into the state package
...
As they're all about the state.
2020-03-11 12:22:52 +03:00
Roman Khimov
8318adac56
vm: add support for dynamic invocations in APPCALL
...
Fixes #740 .
2020-03-10 17:17:36 +03:00
Evgenii Stratonikov
ebf867b11d
state: add a test for NEP5Transfer size
...
It's size is used in NEP5TransferLog so we need to be
sure it reflects reality.
2020-03-10 13:02:14 +03:00
Roman Khimov
ee57b96566
Merge pull request #733 from nspcc-dev/fix-getreferences-interop-regression
...
Fix GetReferences interop regression
2020-03-10 10:27:36 +03:00
Roman Khimov
0e2bda4f21
core: drop txHash from SpentCoinState
...
It's a key for it, makes no sense storing it as data.
2020-03-09 16:58:21 +03:00
Roman Khimov
eb404ceae3
core: fix max contract description limit check
...
It differs from other parameters in C# code. Fixes #735 .
2020-03-09 14:18:51 +03:00
Roman Khimov
4587121c7f
core: fix error propagation in contract-related interops
...
Obvious bug that hides failed contract deployments.
2020-03-09 14:18:00 +03:00
Roman Khimov
4b83e9a5cd
Merge pull request #732 from nspcc-dev/feature/getvalidators
...
rpc: implement getvalidators
2020-03-07 21:43:38 +03:00
Anna Shaleva
456a2d55fd
rpc: implement getvalidators
...
closes #714
2020-03-07 18:05:40 +03:00
Roman Khimov
baeaa3dbe6
core: optimize tx verification, only get references and results once
...
Getting references requires DB access and that is expensive.
2020-03-06 20:15:01 +03:00
Roman Khimov
fe4916f691
core: simplify GetTransactionResults() a bit
...
Make less movements.
2020-03-06 19:26:39 +03:00
Roman Khimov
ced5ddbb9e
core: fix wrong references ordering in interop function
...
Broken by 9f7018503a
. Almost the same problem as
in 01082a8988
(though it is deterministic now,
just not the way the contract expects).
2020-03-06 19:20:55 +03:00
Roman Khimov
0e8ff558d1
Merge pull request #727 from nspcc-dev/fix-wrong-endian-in-interop-hashes
...
core: fix wrong endian used in interop functions
2020-03-06 19:07:28 +03:00
Roman Khimov
f8eee778f4
Merge pull request #724 from nspcc-dev/feature/submitblock
...
rpc: implement submitblock
2020-03-06 12:08:45 +03:00
Anna Shaleva
a746d8e6e6
rpc: implement submitblock RPC
...
closes #344
2020-03-06 12:03:08 +03:00
Evgenii Stratonikov
40188c5400
core: get rid of unnecessary copies
...
There is no need to keep Balances and Unclaimed slices
sorted, we need only to remove a single element.
2020-03-05 20:42:20 +03:00
Anna Shaleva
d3063c26e1
core: add custom error to blockhain.go
...
Add InvalidBlockIndex error to AddBlock func
2020-03-05 20:30:19 +03:00
Roman Khimov
a9abd3d841
core: fix wrong endian used in interop functions
...
C# uses ToArray() or UintXXX(bytes) here which interprets hashes as they
should be interpreted (BE, although they always convert to LE when converting
to String just for the fun of it). It leads to state difference for us at
block 2025204 where even though we have the same value for the key, the key
itself differs, ours:
dd2b538e2a0c1db1ae5061c15be14f916bd1e678e512ffcda6d9499d8e7fe97ee71fd6b8004583d9afe09cc4dadbd5deb63d01e061009b7cffdaa674beae0f930ebe6085af900093e5fe56b34a5c220ccdcf6efc336fc5000000000000000000000000000000000010
theirs:
dd2b538e2a0c1db1ae5061c15be14f916bd1e67861e0013db6ded5dbdac49ce0afd9834500b8d61fe77ee97f8e9d49d9a6cdff12e5009b7cffdaa674beae0f930ebe6085af900093e5fe56b34a5c220ccdcf6efc336fc5000000000000000000000000000000000010
In this key there is a tx hash encoded
(e512ffcda6d9499d8e7fe97ee71fd6b84583d9afe09cc4dadbd5deb63d01e061 in LE used
by all the tools like neoscan).
I love Neo.
2020-03-05 19:44:09 +03:00
Evgenii Stratonikov
95a8fa234f
rpc: implement getnep5transfers RPC
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
6d270c4550
core,rpc: add NEP5 contract to testdata
...
Also transfer tokens between accounts.
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
f92fd3c948
core: track NEP5 transfers
2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
e8c4179a9c
core: track NEP5 balances
2020-03-05 18:22:19 +03:00
Evgenii Stratonikov
3a510b9dad
core: allow transfer amount to be bytes
...
VM can produce both big.Int and []byte because they
are converted to each other on demand.
2020-03-05 15:18:38 +03:00
Roman Khimov
d03b2ef4a1
Merge pull request #706 from nspcc-dev/feature/transfer
...
cli: implement transfer from multisig accounts
2020-03-05 12:28:01 +03:00
Roman Khimov
5c781be08d
Merge pull request #718 from nspcc-dev/fix-invocation-tx-checks-and-fee
...
Fix Invocation TX checks and fee
2020-03-05 11:51:51 +03:00
Roman Khimov
9ac8001c7d
core: protect (*Blockchain).keyCache with a lock
...
Avoid failures like this:
fatal error: concurrent map writes
goroutine 103 [running]:
runtime.throw(0xca6fe3, 0x15)
/usr/lib64/go/1.12/src/runtime/panic.go:617 +0x72 fp=0xc000687988 sp=0xc000687958 pc=0x42d8d2
runtime.mapassign(0xb9d4a0, 0xc0000b1f80, 0xc000687a6c, 0x13bd940)
/usr/lib64/go/1.12/src/runtime/map.go:590 +0x5e3 fp=0xc000687a10 sp=0xc000687988 pc=0x40e2a3
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHashAgainstScript(0xc0000f8000, 0x1300d1f5a3d348be, 0x78607089e4fe9fab, 0xc0a21e4f71, 0xc000d16070, 0x1e2b8881f8178e92, 0xd589cfa965287bb8, 0x24a4e4f292ebc797, 0xb90d3120d878e619, 0xc0001d01e0, ...)
/home/rik/dev/neo-go/pkg/core/blockchain.go:1866 +0x371 fp=0xc000687ad8 sp=0xc000687a10 pc=0x984ed1
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeaderWitnesses(0xc0000f8000, 0xc000d16000, 0xc00042d950, 0x1, 0xc00008a6c0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:1914 +0x209 fp=0xc000687c90 sp=0xc000687ad8 pc=0x985999
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).verifyHeader(0xc0000f8000, 0xc000d16000, 0xc00042d950, 0xf0ee0049d611101f, 0xf8967398a8f9351b)
/home/rik/dev/neo-go/pkg/core/blockchain.go:1254 +0x235 fp=0xc000687d70 sp=0xc000687c90 pc=0x97e4e5
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).addHeaders(0xc0000f8000, 0x1, 0xc000d12000, 0x7d0, 0x7d0, 0x0, 0x1)
/home/rik/dev/neo-go/pkg/core/blockchain.go:369 +0x266 fp=0xc000687e68 sp=0xc000687d70 pc=0x973f46
github.com/nspcc-dev/neo-go/pkg/core.(*Blockchain).AddHeaders(0xc0000f8000, 0xc000d12000, 0x7d0, 0x7d0, 0x0, 0xc0003640c0)
/home/rik/dev/neo-go/pkg/core/blockchain.go:338 +0x51 fp=0xc000687eb0 sp=0xc000687e68 pc=0x973cb1
github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleHeadersCmd(0xc00022c140, 0xdd0ca0, 0xc000374000, 0xc00000c020)
/home/rik/dev/neo-go/pkg/network/server.go:431 +0x74 fp=0xc000687fc0 sp=0xc000687eb0 pc=0x9ce5e4
runtime.goexit()
/usr/lib64/go/1.12/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc000687fc8 sp=0xc000687fc0 pc=0x45ca51
created by github.com/nspcc-dev/neo-go/pkg/network.(*Server).handleMessage
/home/rik/dev/neo-go/pkg/network/server.go:705 +0xa4a
...
2020-03-04 20:26:18 +03:00
Evgenii Stratonikov
7eaeb18f18
transaction: marshal ContractTX even if Data is nil
...
It contains no information so it doesn't matter anyway.
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
634e9483d3
transaction: unmarshal Witness properly
...
Both verification and invocation scripts need to
be unmarshaled from hex.
Also fix failing RPC tests: block contains non-pointer
`transaction.Witness` field and (*Witness).MarshalJSON method
is not called.
2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
33f99104e8
transaction: unmarshal Output properly
...
Address is marshaled in base58 and needs to be
decoded accordingly.
2020-03-04 20:01:26 +03:00
Roman Khimov
81d89cd502
core: fix SystemFee calculation for Invocation TXes
...
They have it specified right in the transaction. Unfortunately, this little
change rendered invalid our RPC test chain, but I think it became even better
after it, especially given that chain generation is a nice test by itself, so
it should be running as a regular test.
2020-03-04 19:23:23 +03:00
Roman Khimov
ae6edf0601
core: add a check for fractional gas in invocation TXes
...
It's not allowed in C# code and that's reasonable as it's a sysfee essentially
that can only be integer.
2020-03-04 19:23:23 +03:00
Roman Khimov
823798514a
util: rename Int64Value to IntegralValue, add FractionalValue
...
Makes it's interface more clear and allows to easily access fractional part.
2020-03-04 19:23:23 +03:00
Roman Khimov
7cc847d655
transaction: add some missing InvocationTX decoding checks
...
Script must have something inside and GAS can't be negative.
2020-03-04 19:23:23 +03:00
Roman Khimov
e41d434a49
*: move all packages from CityOfZion to nspcc-dev
2020-03-03 17:21:42 +03:00
Roman Khimov
59e6dac351
Merge pull request #708 from nspcc-dev/fix/trigger
...
core: convert trigger.Type to byte when pushing on stack
2020-03-03 16:17:01 +03:00
Evgenii Stratonikov
fe3bbbd78a
core: convert trigger.Type to byte when pushing on stack
2020-03-03 16:13:19 +03:00
Roman Khimov
c3e73c5b7d
core: don't reverify stale headers in addHeader
...
During networked synchronization we expect there to be a lot of duplicate
headers received and it makes no sense for us reverifying them.
2020-03-03 15:34:03 +03:00
Evgenii Stratonikov
05a3625b7d
wallet: implement (*Account).SignTx
...
It is used in both CLI and RPC.
2020-03-02 18:03:56 +03:00
Evgenii Stratonikov
6add4f3e50
transaction: disallow negative outputs
...
Otherwise it is possible to make outputs which will sum
to the expected value, but steal GAS from some other account.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
9e9d59b49a
core: set NetworkFee to 0 for Claim and Miner transactions
...
Claim tx have no GAS inputs and a positive output which
can lead to negative network fee.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
de5215a564
core: use GetAccountStateOrNew() in (*Blockchain).GetValidators()
...
Target of the transaction output may not yet exist in database.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
1b9968df67
core: optimize CalculateClaimable()
...
Because accumulated system fee is stored for every block,
it is easy to calculate sum with just to reads.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
258d8be1dd
core: store all accumulated SystemFee with every block
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
f69c8a763b
core: store system fee together with block
...
Recalculating system fee can be rather costly if done
frequently.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
972e0d8ad1
core: add one more Contract tx to the test chain
...
When testing CLI it is useful to have some spent coins
on an account with a known key.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
45b8669b42
core: verify Claim transactions
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
44792ed5f7
core: make test chain format compatible with mainnet
...
Write uint32 length before every block.
2020-03-02 18:01:49 +03:00
Evgenii Stratonikov
0e2a1f40ba
core: add ContractTX to a testchain generator
...
Simple transfer from multisig account to the account
of one of the validators.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
72d72296c3
core: implement (*Transaction).GetSignedPart()
...
Marshalling it and taking all but last byte violates incapsulation
and is just wrong in case transaction already contains any witnesses.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
95d9f36c98
core: implement UnclaimedBalance tracking
...
To make it easy to get unclaimed coins for the
specified account they must be tracked together.
2020-03-02 18:00:00 +03:00
Evgenii Stratonikov
7095ec6c51
core: implement (*Blockchain).CalculateClaimable
...
Calculating amount of GAS that can be claimed is required
for getclaimable RPC.
2020-03-02 18:00:00 +03:00
Roman Khimov
252a9f2f31
Merge pull request #690 from nspcc-dev/feature/getapplicationlog
...
rpc: implement getapplicationlog RPC
2020-03-02 17:41:32 +03:00
Anna Shaleva
ff4384d7ff
rpc: implement getapplicationlog RPC
...
Closes #500
2020-03-02 17:25:27 +03:00
Anna Shaleva
7d46404e2d
smartcontract: turn trigger types into Type
...
1) Turn trigger types from byte constants into Type
2) Add auto-generated stringer for future purposes
2020-03-02 17:25:27 +03:00
Evgenii Stratonikov
a3dacd3b74
tests: replace t.Fatal with require where possible
...
This makes tests less verbose and unifies the style
they are written in.
2020-03-02 17:22:27 +03:00
Evgenii Stratonikov
66f96e3f32
core: shutdown Blockchain gracefully in tests
2020-03-02 17:22:27 +03:00
Evgenii Stratonikov
3a5224344e
core: verify headers in AddHeaders()
...
Headers can be malformed so public methods should verify them
before adding.
2020-03-02 17:22:26 +03:00
Evgenii Stratonikov
357bb4ce41
core: get rid of global variables in tests
...
It can lead to unnecessary race conditions and is just
a bad practice.
2020-03-02 17:04:08 +03:00
Evgenii Stratonikov
8ca94e23c8
core: replace makeBlocks() with addBlocks() in tests
...
This simplifies tests a bit.
2020-03-02 17:04:08 +03:00
Evgenii Stratonikov
cbf26bac83
mempool: do not allocate new slice for verified transactions
...
Because transactions a iterated in an increasing order,
we can filter slice in-place.
2020-03-02 10:38:27 +03:00
Roman Khimov
3e2b490025
mempool: rework inputs verification, check Claim txes
...
Use more efficient check for Input and also check Claims to avoid double
claiming.
2020-02-27 13:43:35 +03:00
Roman Khimov
f329de73e8
mempool: fix Remove bug (dropping wrong tx!)
...
Uncovered by TestMemPoolAddRemoveWithInputsAndClaims (to be added later)
2020-02-27 13:43:35 +03:00
Roman Khimov
7d59fa0066
Merge pull request #696 from nspcc-dev/tx-verification-fixes
...
Claim and enrollment TX verification fixes
2020-02-27 12:45:36 +03:00
Roman Khimov
00d199ed85
core: fix NetworkFee calculation
...
Add doesn't change the variable state. Thanks to GolangCI for catching this.
2020-02-27 12:32:56 +03:00
Roman Khimov
7bea6e043e
core: add double claim verification check
2020-02-27 12:32:56 +03:00
Roman Khimov
29586f2aa7
core: add duplicate Claim verification check
...
Refactor HaveInputsDuplicate() out of the core and Blockchain, it doesn't
depend on the Blockchain state. Make it more efficient.
2020-02-27 12:32:56 +03:00
Roman Khimov
9b1ad40273
core: drop GetScriptHashesForVerifyingClaim, fix Claim's ScriptHash getter
...
Claim transactions should _add_ claims scripthashes to the standard list, not
replace them. And this code is actually very reusable.
2020-02-27 12:32:56 +03:00
Roman Khimov
9f7018503a
core/transaction: use new transaction.InOut for References
...
We don't need a map here, use simpler structures.
2020-02-27 12:00:03 +03:00
Roman Khimov
80de208a68
transaction: unbind GroupInputsByPrevHash from Transaction
...
Which allows to use it for ClaimTX. Make it also a bit more efficient as maps
are expensive.
2020-02-27 12:00:03 +03:00
Roman Khimov
b1b184f77f
Merge pull request #692 from nspcc-dev/persist-timer-fix
...
core: reschedule the next persist in a second from previous one
2020-02-26 10:34:40 +03:00
Roman Khimov
c258adb532
core: move spent coin management out of the inner storeBlock loop
...
prevHash == input.PrevHash, so make less DB accesses and more real work. Fix
some bugs along the way:
* spentCoins structure may already be present in the DB when persisting TX,
there is nothing wrong with that and we shouldn't overwrite it
* it's only used for NEO and only to check for claim validity. Thus, when
processing claim tx the corresponding spentCoins should always be present
in the DB
2020-02-25 17:21:09 +03:00
Roman Khimov
36c6b6af14
core: put unspents get/put one loop above in storeBlock
...
Everywhere in this code prevHash == input.PrevHash, thus we can easily move
some common code out of the loop saving on DB accesses and
serialization/deserialization.
2020-02-24 18:53:10 +03:00
Roman Khimov
5c9681508b
transaction: strip off a layer of redirection from ClaimTX.Claims
...
We don't need a pointer here and this change makes this field compatible with
Transaction.Inputs which is useful in many scenarios.
2020-02-24 18:22:27 +03:00
Roman Khimov
ed9e9e8590
storage: add locking into (*MemoryStore).Seek
...
It was missing there.
2020-02-24 17:51:50 +03:00
Roman Khimov
b49808b766
core: reschedule the next persist in a second from previous one
...
It makes little sense queueing up several persistence goroutines (or actually
even running them concurrently).
2020-02-24 17:17:25 +03:00
Roman Khimov
d5e6028c13
core: add validator public key into the list of hashes to verify
...
That should be done for Enrollment transactions.
2020-02-21 20:04:16 +03:00
Roman Khimov
a903147b60
keys: rename Signature to GetScriptHash, make it return Uint160
...
Signature itself wasn't used at all and its name is very misleading, Uint160
script hash is way more useful.
2020-02-19 12:19:03 +03:00
Roman Khimov
eb11e5fb11
core: implement basic policying support, fix #370
...
Implement mempool and consensus block creation policies, almost the same as
SimplePolicy plugin for C# node provides with two caveats:
* HighPriorityTxType is not configured and hardcoded to ClaimType
* BlockedAccounts are not supported
Other than that it allows us to run successfuly as testnet CN, previously our
proposals were rejected because we were proposing blocks with oversized
transactions (that are rejected by PoolTx() now).
Mainnet and testnet configuration files are updated accordingly, but privnet
is left as is with no limits.
Configuration is currently attached to the Blockchain and so is the code that
does policying, it may be moved somewhere in the future, but it works for
now.
2020-02-19 12:19:02 +03:00
Roman Khimov
22f5667530
mempool: return fee along with tx when requesting tx
...
Users of GetVerifiedTransactions() don't want to recalculate tx fee and it's
nice to have it returned from TryGetValue() also sometimes.
2020-02-19 12:19:02 +03:00
Roman Khimov
06daeb44f3
core: make IsLowPriority work with pre-calculated fee
...
Don't recalculate it again and again.
2020-02-19 12:19:02 +03:00
Roman Khimov
a4294f4b5f
core: export UtilityTokenID and GoverningTokenID
...
Both are very useful outside of the core, this change also makes respective
transactions initialize with the package as they don't depend on any kind of
input and it makes no sense recreating them again and again on every use.
2020-02-19 12:13:27 +03:00
Roman Khimov
b41a5239c6
core: always sort the result of GetValidators
...
It wasn't sorted when all validators were elected. There is also no need to do
`Unique()` on the result because validators are distinguished by the key, so
no two registered validators can have the same key.
2020-02-18 20:36:22 +03:00
Evgenii Stratonikov
a2f012e589
core: deploy new smart-contract in test blocks
...
Also put smart-contract sources in testdata and
add invocation TX with APPCALL and storage.Put.
2020-02-18 11:59:28 +03:00
Anna Shaleva
2b9e63c511
core: add func to generate RPC test data
...
newRPCTestChain function generates test chain "testblocks.acc" for RPC
tests
2020-02-17 23:54:25 +03:00
Roman Khimov
dfb38e1da1
Merge pull request #649 from nspcc-dev/feature/dump_storage
...
cli: add possibility to dump storage changes on restore
2020-02-16 23:50:31 +03:00
Roman Khimov
b5453ad24f
Merge pull request #672 from nspcc-dev/fix-sigsegv-on-reference-check
...
core: deal with bad transaction Inputs
2020-02-14 13:23:42 +03:00
Roman Khimov
0fceaf12d2
core: deal with bad transaction Inputs
...
They may not really have a reference. Fixes #671 .
2020-02-14 09:42:10 +03:00
Roman Khimov
992ccc0b26
Merge pull request #664 from nspcc-dev/sort-validator-keys
...
core: sort GetValidators() result
2020-02-13 21:46:26 +03:00
Evgeniy Kulikov
8d410a6659
Add JSON tags for RPC response types
...
- Attribute should have 2 fields (usage, data)
- VOut should have 4 (5) fields (asset, value, address, n)
- Script should have 2 fields (invocation, verification)
2020-02-13 19:06:54 +03:00
Roman Khimov
d4cd134aef
core: sort GetValidators() result
...
As C# node does it. Technically it's only needed for consensus and could be
implemented in the appropriate package, but for better compatibility with C#
node we're better returning it sorted right here.
2020-02-13 17:07:27 +03:00
Roman Khimov
26af9200b0
core: refactor voting processing, fix pending tx subtractions
...
Deduplicate code and add missing token check for subtractions that are being
done in GetValidators() for pending transactions.
2020-02-13 13:07:34 +03:00
Roman Khimov
c8a248596e
core: introduce ValidatorsCount, make a proper count
...
We were completely lacking ValidatorsCount that is supposed to track the
number of votes with particular count of consensus nodes which in theory can
change the number of active consensus nodes (if it ever to exceed the number
of standby validators), so we were not producing the right count and based on
that not giving the right set of validators.
Fixes #512 .
2020-02-13 13:07:34 +03:00
Roman Khimov
357b675090
core: don't choose duplicating standby validators
...
We may already have chosen some of standby validators, so don't repeat.
2020-02-13 13:07:34 +03:00
Roman Khimov
f9c6a0d77c
core: make voting choose the best validators
...
They need to be sorted in order for voting system to work.
2020-02-13 13:07:34 +03:00
Roman Khimov
2ff7ceb8cf
core: properly update validator votes for Account descriptor
...
ValidatorsCount is not implemented yet, but we need to update validators
properly, adding account's vote to their votes count.
2020-02-13 13:07:34 +03:00
Roman Khimov
8310b76d28
core: properly save votes when processing Account descriptor
...
They were ignored basically.
2020-02-13 13:07:34 +03:00
Roman Khimov
807309a0de
core/state: only drop unregistered non-voted validators
...
Simple as that: UnregisteredAndHasNoVotes != !RegisteredAndHasVotes
Registered validators should stay in the DB, we might be in the process of
updating votes for them and that starts with subtraction.
2020-02-13 13:07:34 +03:00
Roman Khimov
38d0efc96c
core: fix Registered state descriptor processing
...
It has simple boolean value encoded, no `strconv` needed (it actually chokes
on such input).
2020-02-12 21:27:40 +03:00
Roman Khimov
803fb39bb0
transaction: fix wrong state descriptor serdes
...
Wrong field order.
2020-02-12 21:23:28 +03:00
Evgenii Stratonikov
0a894db7f8
storage: add Exists flag to KeyValue in batch
...
Set Exists flag if an item with the specified key was already
present in storage before persisting.
2020-02-12 12:16:31 +03:00
Evgenii Stratonikov
b1d9e1132d
cli: dump storage changes into JSON files
2020-02-12 12:16:31 +03:00
Evgenii Stratonikov
fb9af98179
storage: implement GetBatch() to view storage changes
...
GetBatch returns changes to be persisted.
2020-02-12 12:16:31 +03:00
Roman Khimov
38de2af073
Merge pull request #655 from nspcc-dev/fix-mempool-deadlock-on-reverification
...
core: get transactions from dao when mempool should not be used
2020-02-11 13:34:23 +03:00
Roman Khimov
292051d8df
core: get transactions from dao when mempool should not be used
...
All of these places deal strictly with the chain and shouldn't ever be
bothered with mempool. It also fixes a deadlock on reverification of
non-standard tx:
1 @ 0x42f62f 0x43fbe9 0x43fbbf 0x43f95d 0x967059 0x966f66 0x972c7c 0x974e13 0x97a5d9 0x97bdf0 0x976147 0x966cc0 0x970f70 0x96c8cb 0x9ba858 0x45ca51
0x43f95c sync.runtime_SemacquireMutex+0x3c /usr/local/go/src/runtime/sema.go:71
0x967058 sync.(*RWMutex).RLock+0x128 /usr/local/go/src/sync/rwmutex.go:50
0x966f65 github.com/CityOfZion/neo-go/pkg/core/mempool.(*Pool).TryGetValue+0x35 /go/src/github.com/CityOfZion/neo-go/pkg/core/mempool/mem_pool.go:229
0x972c7b github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).GetTransaction+0x4b /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:782
0x974e12 github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).References+0x132 /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:944
0x97a5d8 github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).GetScriptHashesForVerifying+0x58 /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:1410
0x97bdef github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).verifyTxWitnesses+0x4f /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:1545
0x976146 github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).isTxStillRelevant+0x216 /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:1067
0x966cbf github.com/CityOfZion/neo-go/pkg/core/mempool.(*Pool).RemoveStale+0xff /go/src/github.com/CityOfZion/neo-go/pkg/core/mempool/mem_pool.go:208
0x970f6f github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).storeBlock+0x2ecf /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:614
0x96c8ca github.com/CityOfZion/neo-go/pkg/core.(*Blockchain).AddBlock+0xea /go/src/github.com/CityOfZion/neo-go/pkg/core/blockchain.go:308
0x9ba857 github.com/CityOfZion/neo-go/pkg/network.(*blockQueue).run+0x157 /go/src/github.com/CityOfZion/neo-go/pkg/network/blockqueue.go:48
2020-02-10 18:53:22 +03:00
Anna Shaleva
9b03f968b1
core: fixe FreeGasLimit constraint
...
Lack of FreeGasLimit in privnet leads to gas limit exceeding in case of transactions with small amount of GAS to be used for invoke operation (< real cost of the transaction). Solution: Fixed constraint in case when FreeGasLimit == 0. So now we are able to perform transactions in privnet with FreeGasLimit = 0 for free.
2020-02-10 18:07:19 +03:00
Roman Khimov
9b9adb28c1
Merge pull request #642 from nspcc-dev/feature/emit
...
vm, compiler: move Emit* functions to a separate package
Closes #449 , #534 .
2020-02-08 15:56:48 +03:00
Roman Khimov
7ccf7974b6
core: substitute bad notifications with error messages
...
Tesnet sync failed with:
Feb 07 00:04:19 nodoka neo-go[1747]: 2020-02-07T00:04:19.838+0300 WARN blockQueue: failed adding block into the blockchain {"error": "failed to store notifications: not supported", "blockHeight": 713984, "nextIndex": 713985}
because some (not so) smart contract emitted a notification with an
InteropItem inside.
2020-02-07 15:34:59 +03:00
Evgenii Stratonikov
8243a8b3a7
emit: use io.BinWriter instead of bytes.Buffer
2020-02-06 18:45:37 +03:00
Evgenii Stratonikov
4d8a3a359b
vm: move Emit* functions to a separate package
...
Also strip 'Emit' prefix because 'emit' is now
in the package name.
2020-02-06 18:45:37 +03:00
Roman Khimov
ab14a4619d
Merge pull request #647 from nspcc-dev/fix-mempool-and-chain-locking
...
Fix mempool and chain locking
This allows us easily make 1000 Tx/s in 4-nodes privnet, fixes potential
double spends and improves mempool testing coverage.
2020-02-06 18:43:29 +03:00
Evgenii Stratonikov
9204b95d5b
core: fix GAS price definitions
2020-02-06 18:19:08 +03:00
Roman Khimov
18695e660b
mempool: drop RemoveOverCapacity(), handle it right in the Add()
...
Simplifies things a lot and removes useless code.
2020-02-06 17:50:11 +03:00
Roman Khimov
684cbf5bac
mempool: make it almost 100% test-covered
2020-02-06 17:50:11 +03:00
Roman Khimov
6672f4b26f
mempool: iterate over slice in GetVerifiedTransactions()
...
It's more efficient and keeps transactions sorted by priority.
2020-02-06 16:59:20 +03:00
Roman Khimov
e97396e56c
mempool: test addition of conflicting tx to the pool
2020-02-06 15:57:20 +03:00
Roman Khimov
1133bbe584
mempool: remove unverified transactions pool
...
Our mempool only contains valid verified transactions all the time, it never
has any unverified ones. Unverified pool made some sense for quick unverifying
after the new block acceptance (and gradual background reverification), but
reverification needs some non-trivial locking between blockchain and mempool
and internal mempool state locking (reverifying tx and moving it between
unverified and verified pools must be atomic). But our current reverification
is fast enough (and has all the appropriate locks), so bothering with
unverified pool makes little sense.
2020-02-06 15:45:16 +03:00
Roman Khimov
b675903f52
mempool/core: redesign mempool dances on block acceptance
...
We not only need to remove transactions stored in the block, but also
invalidate some potential double spends caused by these transactions. Usually
new block contains a substantial number of transactions from the pool, so it's
easier to make one pass over it only keeping valid items rather than remove
them one by one and make an additional pass to recheck inputs/witnesses.
2020-02-06 15:45:16 +03:00
Roman Khimov
b567ce86ac
mempool: implement insertion to sorted slice
...
Which is way faster than sort.Sort'ing things all the time.
2020-02-06 15:44:18 +03:00
Roman Khimov
35183b6dba
mempool: reverse the order of sorted slice
...
Chopping off the last element of the slice if way easier than doing it with
the first one.
2020-02-06 15:44:16 +03:00
Roman Khimov
794027a90b
mempool: use one slice for both priorities
...
It doesn't harm as we have transactions naturally ordered by fee anyway and it
makes managing them a little easier. This also makes slices store item itself
instead of pointers to it which reduces the pressure on the memory subsystem.
2020-02-06 15:43:45 +03:00
Roman Khimov
325bea3fa9
mempool: cache Feer invocation results in the item
...
They shouldn't depend on the chain state and for the same transaction they
should always produce the same result. Thus, it makes no sense recalculating
them over and over again.
2020-02-06 15:41:56 +03:00
Roman Khimov
e01bfeeb4d
mempool: remove lock indirection from the Pool
...
After the f0bb886be3
with all methods of Pool
being pointer-based it makes no sense having this lock as a pointer.
2020-02-06 15:41:56 +03:00
Roman Khimov
a928ad9cfa
mempool: make item an internal thing of mempool package
...
Nobody outside should care about these details, mempool operates on
transactions and that's it.
2020-02-06 15:41:56 +03:00
Roman Khimov
f0e3a31bc8
mempool: fix appending to sorted pools
...
Appending and not changing the real Items is utterly wrong.
2020-02-06 15:41:56 +03:00
Roman Khimov
f9963cca37
core: short-circuit verifyInputs when there are no inputs
2020-02-06 15:41:56 +03:00
Roman Khimov
70b3839fd0
core/mempool: fix AddBlock and tx pooling concurrency issues
...
Eliminate races between tx checks and adding them to the mempool, ensure the
chain doesn't change while we're working with the new tx. Ensure only one
block addition attempt could be in progress.
2020-02-06 15:41:52 +03:00
Roman Khimov
f0bb886be3
mempool: make all methods pointer methods
...
Makes no sense copying the Pool around.
2020-02-04 17:36:11 +03:00
Roman Khimov
388fed06e5
transaction: forbid serializing invalid transactions
...
Transaction that has no data is invalid and can't be serialized, so throw an
error if someone tries to.
2020-02-03 16:33:03 +03:00
Evgeniy Kulikov
eb59460032
Merge pull request #614 from nspcc-dev/configurable-mempool-size
...
config: add MemPoolSize configuration parameter
2020-01-23 13:25:27 +03:00
Roman Khimov
d6784e8f45
config: add MemPoolSize configuration parameter
...
Allow tuning/experimenting with mempool.
2020-01-23 13:10:44 +03:00
Evgenii Stratonikov
303b82cc44
core: set free GAS limit via config
2020-01-22 14:32:21 +03:00
Evgenii Stratonikov
4718375db1
rpc: return amount of consumed GAS in invoke*
2020-01-22 14:31:57 +03:00
Evgenii Stratonikov
4eae55143f
core: restrict GAS available for invocation transactions
...
There are 10 GAS available for free plus any amount of GAS
attached to a transaction.
2020-01-22 14:31:54 +03:00
Roman Khimov
32213b1454
Merge pull request #601 from nspcc-dev/refactoring/core
...
core: refactor out Block, BlockBase and Header, closes #597 .
2020-01-20 16:19:20 +03:00
Roman Khimov
46b82b4fb5
keys: don't return error from PrivateKey.Sign
...
As it can't ever happen.
2020-01-17 17:00:30 +03:00
Evgenii Stratonikov
28183b81d6
mempool: simplify names of exported types
...
With the move to a separate package, naming can be simplified:
MemPool -> Pool, PoolItem -> Item, PoolItems -> Items.
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
fed6fba9b6
core: refactor out MemPool
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
79bceb3e40
block: use require in tests
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
489b88afbb
block: rename BlockBase to Base
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
63c56cca5c
core: refactor out Block, BlockBase and Header structs
...
See #597 .
2020-01-16 10:16:24 +03:00
Evgenii Stratonikov
9dc5571327
core,rpc: close Blockchain in tests
...
If blockchain is not closed, logging in defer can occur
after test has finished, which will lead to a panic with
"Log in goroutine after Test* has completed".
2020-01-10 11:47:56 +03:00
Evgenii Stratonikov
637c99eda7
core: simplify newInteropContext
2020-01-10 11:14:29 +03:00
Evgenii Stratonikov
aecdf470e7
cli,pkg: use zap.Logger
2020-01-10 11:14:27 +03:00
Evgenii Stratonikov
9c79684516
storage: panic on error in boltdb.Seek
...
Error in Seek means something is terribly wrong (e.g. db was not opened) and
error drop is not the right thing to do, because caller
will continue working with the wrong view.
2020-01-09 15:17:35 +03:00
Roman Khimov
c306d2f07c
Merge pull request #581 from nspcc-dev/feat/storage_find
...
core: implement Neo.Storage.Find interop, closes #422 .
2019-12-26 15:46:46 +03:00
Evgenii Stratonikov
48cf4f4a84
core: implement Neo.Storage.Find interop
2019-12-26 15:21:41 +03:00
Roman Khimov
f8887b63ba
Merge pull request #578 from nspcc-dev/fix/sign
...
consensus: verify payloads correctly, closes #555 .
2019-12-26 13:07:40 +03:00
Evgenii Stratonikov
714c466c2c
core: add ScriptFromWitness function
...
Extracting verification script from witness became a common task.
This commit adds such a possibility.
2019-12-26 10:49:56 +03:00