Anna Shaleva
c5c5e4c208
core: do not panic if transaction with empty script is being serialized
...
See https://github.com/nspcc-dev/neo-go/pull/2485#discussion_r872695786 .
Allows to avoid panic:
```
(18:28:29)[sergio@transient:morph-control-load]% downloads/neofs-adm morph -c configuration/config.yaml init --contracts downloads/neofs-contract-v0.15.1
Stage 1: transfer GAS to alphabet nodes.
Waiting for transactions to persist...
Stage 2: set notary and alphabet nodes in designate contract.
Stage 2: already performed.
Stage 3: deploy NNS contract.
NNS contract is already deployed.
Stage 4: deploy NeoFS contracts.
Alphabet contract #0 is already deployed.
Alphabet contract #1 is already deployed.
Alphabet contract #2 is already deployed.
Alphabet contract #3 is already deployed.
audit contract is already deployed.
balance contract is already deployed.
container contract is already deployed.
neofsid contract is already deployed.
netmap contract is already deployed.
proxy contract is already deployed.
reputation contract is already deployed.
subnet contract is already deployed.
Waiting for transactions to persist...
Stage 4.1: Transfer GAS to proxy contract.
Stage 5: register candidates.
Stage 6: transfer NEO to alphabet contracts.
Stage 7: set addresses in NNS.
NNS: Set alphabet0.neofs -> 2efeb27866fa774ec6bfb43babaadcc7b28f9bb7
NNS: Set alphabet1.neofs -> 5606bc6598a538ac59ded3caa842247b9b26097a
NNS: Set alphabet2.neofs -> 2a8308cfd2706ddd5f67adfdf3954c6836806b5d
NNS: Set alphabet3.neofs -> 718d0459e6787f0f13f1e1898bf2ce6bc4bb452d
NNS: Set audit.neofs -> 54d516b36c3380efa2b2f26bda300b6c6302b8e7
NNS: Set balance.neofs -> 72b3255944524cb822788a7542c9d06cba208c0c
NNS: Set container.neofs -> 20a20f4352a49f161eccb7d5a806fd46dcab81ea
NNS: Set neofsid.neofs -> 04a3a71535689b820093cefe7ae188ed7591ad27
NNS: Set netmap.neofs -> 9a34c97b2ba6bd986fd9140a9c3d59059fa430f4
NNS: Set proxy.neofs -> 4eba34ec016f8709a511b02765a1195e31a921ea
NNS: Set reputation.neofs -> 77b5b2cf596957cc05ca3d57503ef08d72792301
NNS: Set subnet.neofs -> b0abe16bc7f56b2e7e0694ae2b36207c6aaa8636
panic: error serializing *transaction.Transaction: transaction has no script
goroutine 1 [running]:
github.com/nspcc-dev/neo-go/pkg/io.GetVarSize({0xbf6240, 0xc0003634a0})
github.com/nspcc-dev/neo-go@v0.98.2/pkg/io/size.go:68 +0x6fd
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).AddNetworkFee(0xc0004080c0, 0xc0003634a0, 0x0, {0xc00000e248, 0x1, 0x93})
github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/rpc.go:966 +0x6b
github.com/nspcc-dev/neo-go/pkg/rpc/client.(*Client).CreateTxFromScript(0x0, {0x0, 0x0, 0x0}, 0x1, 0x0, 0x0, {0xc0001c7990, 0x1, 0x1})
github.com/nspcc-dev/neo-go@v0.98.2/pkg/rpc/client/nep17.go:128 +0x345
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).sendCommitteeTx(0xc00014a370, {0x0, 0x0, 0x0}, 0xc0016bcf30, 0x2)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:336 +0x131
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).updateNNSGroup(0xc0001c7c88, {0x13, 0xd3, 0x6b, 0x85, 0x3e, 0x86, 0xbe, 0x77, 0xb7, ...}, ...)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:89 +0x134
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.(*initializeContext).setNNS(0xc00014a370)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize_nns.go:74 +0x8c5
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph.initializeSideChainCmd(0x12a00e0, {0xc22a22, 0x4, 0x4})
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/initialize.go:94 +0x2bc
github.com/spf13/cobra.(*Command).execute(0x12a00e0, {0xc00013a6c0, 0x4, 0x4})
github.com/spf13/cobra@v1.1.3/command.go:852 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0x129c760)
github.com/spf13/cobra@v1.1.3/command.go:960 +0x3ad
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/cobra@v1.1.3/command.go:897
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules.Execute(...)
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/root.go:48
main.main()
github.com/nspcc-dev/neofs-node/cmd/neofs-adm/main.go:10 +0x25
zsh: exit 2 downloads/neofs-adm morph -c configuration/config.yaml init --contracts
```
2022-05-16 15:19:17 +03:00
Roman Khimov
ffeb3b8473
transaction: microoptimize Hash()
...
It doesn't cost much, but it's used _a lot_, so optimizing it makes sense.
name old time/op new time/op delta
TxHash-8 4.89ns ± 5% 0.54ns ± 2% -88.86% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
TxHash-8 0.00B 0.00B ~ (all equal)
name old allocs/op new allocs/op delta
TxHash-8 0.00 0.00 ~ (all equal)
2021-12-02 14:48:35 +03:00
Roman Khimov
7808762ba0
transaction: avoid reencoding and reading what can't be read
...
name old time/op new time/op delta
DecodeFromBytes-8 1.79µs ± 2% 1.46µs ± 4% -18.44% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
DecodeFromBytes-8 800B ± 0% 624B ± 0% -22.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
DecodeFromBytes-8 10.0 ± 0% 8.0 ± 0% -20.00% (p=0.000 n=10+10)
2021-08-23 21:41:38 +03:00
Roman Khimov
d314f82db3
transaction: drop Network from Transaction
...
We only need it when signing/verifying.
2021-03-26 13:45:18 +03:00
Anna Shaleva
e5cdecfa9f
core: fix transaction hashes
2021-03-18 17:57:54 +03:00
Roman Khimov
4462a6a6b7
change block/tx/extensible signing process, fix #1741
...
Sign [magic, hash], see neo-project/neo#2314 .
2021-03-12 11:27:50 +03:00
Anna Shaleva
a6d4a266b9
core: check transaction's scripts length during decoding
2021-02-17 13:19:23 +03:00
Evgeniy Stratonikov
b0fbd897ad
Revert "rpc: marshal fees and GAS as Fixed8 decimal"
...
This reverts commit a79b12b4d4
.
2021-02-09 11:16:52 +03:00
Anna Shaleva
840104461b
config: update testnet netmode to preview5 magic
2021-02-05 18:57:54 +03:00
Roman Khimov
120ae4841f
transactions: fix JSON unmarshalling of fees
...
Fixed8 is already marshalled as a string and stripping quotes from it just
leads to interpreting it as a float with all regular float problems (like
test transaction failing with `txid doesn't match transaction hash`).
2021-01-22 18:22:09 +03:00
Evgenii Stratonikov
e4c3339c91
util: move Fixed8
to encoding/fixedn package
2020-12-09 11:18:18 +03:00
Evgenii Stratonikov
a79b12b4d4
rpc: marshal fees and GAS as Fixed8 decimal
2020-11-26 15:04:30 +03:00
Evgenii Stratonikov
7d91a3a89e
pkg: move internal/ package to the root directory
...
This way we can use it in scripts and cli.
2020-11-24 16:39:56 +03:00
Anna Shaleva
f259a614de
core: add transaction.HasSigner method
2020-10-23 16:32:26 +03:00
Anna Shaleva
7947e99a1e
core: add transaction.GetAttributes
2020-10-23 11:05:03 +03:00
Evgenii Stratonikov
fa09b9af7b
transaction: rename FeeOnly to None
...
Follow missed change from neo-project/neo#1816 .
`None` may be used for any signer. Currently it is used
for sender to only pay fees, or to sign tx attributes.
2020-10-01 15:28:19 +03:00
Evgenii Stratonikov
1625689316
transaction: implement OracleResponse attribute
2020-09-16 14:50:31 +03:00
Evgenii Stratonikov
06b29e409c
transaction: remove Attribute.Data field
2020-09-16 13:39:53 +03:00
Roman Khimov
19c69618c5
transaction: cache tx size, don't serialize it over and over again
2020-09-11 18:55:19 +03:00
Evgenii Stratonikov
7ee1ddff61
transaction: add tests for (*Transaction).isValid()
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
2661ebd295
transaction: add HighPriority attribute
...
HighPriority attributes specifies that transaction was
signed by a committee.
2020-08-23 09:39:46 +03:00
Evgenii Stratonikov
04bff62d65
transaction: update binary test data
2020-08-18 15:09:30 +03:00
Anna Shaleva
90825efa16
core: move transaction's sender to cosigners
...
Closes #1184
Ported changes from https://github.com/neo-project/neo/pull/1752
2020-08-04 17:33:50 +03:00
Evgenii Stratonikov
5787d7775f
transaction: fail creating tx if there is additional data present
2020-07-03 18:03:57 +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
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
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
0a09a20900
transaction: drop Register transaction type
...
And everything associated like SystemFee configuration.
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
dfc7a9bfd1
transaction: drop Claim TX type
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
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
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
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
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
Anna Shaleva
9c09ad9c89
rpc: fix marshalling of type-specific tx data
...
closes #585
2020-03-30 15:48:50 +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
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
e41d434a49
*: move all packages from CityOfZion to nspcc-dev
2020-03-03 17:21:42 +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
Roman Khimov
b246653f62
address: rename functions as per #579 comments
...
Make them more clear to understand.
2019-12-25 17:34:18 +03:00
Roman Khimov
e685e9bf9a
address: move into its own package
...
Doesn't really belong to the crypto.
2019-12-25 15:22:02 +03:00
Evgenii Stratonikov
7179e4ba9f
util: add LE suffix to Uint256 methods
2019-12-06 12:16:55 +03:00
Roman Khimov
27a57e1a2d
transaction: allow system fee specification in NewInvocationTX
...
It's not possible to create any deployment TX without it.
2019-11-20 16:12:40 +03:00
Roman Khimov
8d0ed9259c
transaction: fix invocation TX consistency in NewInvocationTX()
...
NewInvocationTX() returned a version number one transaction that actually
failed to pass that version down to the invocation data which lead to
serialization/deserialization inconsistency.
2019-10-23 14:50:24 +03:00
Roman Khimov
d1a4e43c48
io: redo Serializable to return errors in BinReader/BinWriter
...
Further simplifies error handling.
2019-09-17 13:21:52 +03:00
Roman Khimov
5bf00db2c9
io: move BinReader/BinWriter there, redo Serializable with it
...
The logic here is that we'll have all binary encoding/decoding done via our io
package, which simplifies error handling. This functionality doesn't belong to
util, so it's moved.
This also expands BufBinWriter with Reset() method to fit the needs of core
package.
2019-09-16 23:39:51 +03:00
Roman Khimov
203aab6a7e
transaction: add binary encoding for publish
...
And expand the test to check for it. Fixes #319 .
2019-08-30 19:19:43 +03:00