Anna Shaleva
456a2d55fd
rpc: implement getvalidators
...
closes #714
2020-03-07 18:05:40 +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
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