Commit graph

259 commits

Author SHA1 Message Date
Anna Shaleva
e5cdecfa9f core: fix transaction hashes 2021-03-18 17:57:54 +03:00
Roman Khimov
9d500b86fc context: s/hex/data/ for JSON
See neo-project/neo#2394.
2021-03-12 13:10:24 +03:00
Roman Khimov
dc980b5847 sc/context: add network magic into the context
See neo-project/neo#2393, we need this to be able to sign multisig
transactions.
2021-03-12 12:59:14 +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
Roman Khimov
3e9bd0be72 smartcontract: use base64 encoding for verifiable items
See neo-project/neo#1199.
2021-03-11 19:55:20 +03:00
Evgeniy Stratonikov
1cb25d3190 native: use proper types in manifest 2021-03-11 11:48:38 +03:00
Anna Shaleva
9015e50847 core: refactor Neo.Crypto.CheckMultisigWithECDsaSecpr1
Rename it to Neo.Crypto.CheckMultisig and remove `message` parameter.
2021-03-10 21:46:05 +03:00
Evgeniy Stratonikov
106c27782e cli/wallet: allow to cosign with a contract
Contracts have empty verification script and their hash is
calculated differently.
2021-03-09 15:45:02 +03:00
Evgeniy Stratonikov
b9136dbfc0 smartcontract: use hash in GetWitness()
All necessary info must already be in context.
2021-03-09 15:45:02 +03:00
Evgeniy Stratonikov
20d2386414 smartcontract: use script instead of address in context 2021-03-09 15:45:02 +03:00
Evgeniy Stratonikov
7a176727ca smartcontract: add GetMajorityNodeCount() 2021-03-09 13:46:44 +03:00
Roman Khimov
abee3b5b05
Merge pull request #1722 from nspcc-dev/fix/nep11
smartcontract: add NEP-11 standard check
2021-02-22 22:27:09 +03:00
Evgeniy Stratonikov
b38443fe20 smartcontract: add checks for onNEP*Payable methods
When they are present in contract, we want them
to have correct signature.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
d89f055697 smartcontract: add checks for parameter names
It can be annoying to use parameter names as specified by standard,
so a separate `CheckABI` is supported.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
9d4ccf0fcc smartcontract: add test for Optional methods
They should be checked only if name + parameter count matches.
This is how methods are identified in NEO.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
eb26a61078 smartcontract: remove IsNEP17() 2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
9c0bbd0bfd smartcontract: add NEP-11 standard check
The only method missing is name, because it is
provided in manifest.
2021-02-19 17:06:07 +03:00
Anna Shaleva
488e75a246 cli: add filebytes parameter type 2021-02-19 10:52:45 +03:00
Anna Shaleva
0f1473897b core: temp manifest.Extra marshalling fix
Manifest.Extra still serialized as JSON message with undefined  order
of items, so it affects contract states dumps.
2021-02-12 23:48:30 +03:00
Roman Khimov
a3abdbd7f0 manifest: add duplicate events/methods checks to ABI
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
dc3967ae7b manifest: add manifest validity checks
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
284476c070 manifest: add Permission and Permissions validity checks
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
15ed905757 manifest: add validity checks for Parameter
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
f0c3066ef6 manifest: add method validity check
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
f3c761e4c2 manifest: move Parameter into a file of its own 2021-02-09 22:31:26 +03:00
Roman Khimov
0b2e9312af manifest: add event validity check
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
f78e3fb290 manifest: move Event into a file of its own 2021-02-09 22:31:26 +03:00
Roman Khimov
e9ea89b4e3 manifest: add group signature length check
Refs. #1699.
2021-02-09 22:31:24 +03:00
Roman Khimov
296c7a10fc manifest: move Group code into a file of its own 2021-02-09 22:31:22 +03:00
Roman Khimov
1a4958b1d5 manifest: add ABI validity check
Some methods must be defined in a valid ABI. Refs. neo-project/neo#2263.
2021-02-08 13:27:39 +03:00
Roman Khimov
5ba074b4cf manifest: return an error from IsValid
Be more specific.
2021-02-08 12:04:57 +03:00
Roman Khimov
211fe307ee manifest: move ABI code into file of its own
Make it a little more convenient to work with it.
2021-02-08 11:55:16 +03:00
Roman Khimov
60dfffc574 manifest: remove no longer used Serializable interface
It was used when manifests were saved into JSON.
2021-02-08 10:52:53 +03:00
Roman Khimov
e4b5b59663
Merge pull request #1704 from nspcc-dev/binary_manifest
core: serialise manifest as stackitem
2021-02-05 23:58:07 +03:00
Roman Khimov
cd9b34416e native: call onNEP11Transfer for NEP-11 transfers
See neo-project/neo#2287.
2021-02-05 20:48:45 +03:00
Anna Shaleva
a2715404d0 core: serialise manifest as stackitem 2021-02-05 19:10:15 +03:00
Roman Khimov
a442e1530d native: rename onPayment into onNEP17Payment
Follow neo-project/neo#2287.
2021-02-05 16:09:51 +03:00
Evgeniy Stratonikov
73f888f02e core: allow to overload contract methods
Multiple methods with different parameter count can co-exist.
2021-01-27 12:51:07 +03:00
Evgeniy Stratonikov
719dceff77 nef: merge Compiler and Version fields 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
0bbdee2ce1 nef: add Reserved bytes 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
52843fc1bf nef: add Tokens field 2021-01-19 11:19:24 +03:00
Evgenii Stratonikov
dbe81f9b80 smartcontract: move flags to a separate package 2021-01-14 17:52:09 +03:00
Evgeniy Stratonikov
11191c0a08 nef: support JSON serialization 2021-01-13 15:26:35 +03:00
Roman Khimov
2e0fe370cf nef: lower MaxScriptLength
Follow neo-project/neo#2119 changes.
2020-12-14 15:24:15 +03:00
Roman Khimov
fc361213a7
Merge pull request #1608 from nspcc-dev/core/callflags
core: adjust call flags
2020-12-11 19:23:15 +03:00
Anna Shaleva
fadbae8997 core: rename call flags
Also new States flag is added and ReadOnly flag is adjusted.
2020-12-11 10:34:01 +03:00
Evgenii Stratonikov
ec1ff42872 manifest: add Safe flag for NEP-17 methods 2020-12-10 18:04:49 +03:00
Evgenii Stratonikov
ea4d14d20d manifest/standard: check Safe flag in Comply() 2020-12-08 13:47:05 +03:00
Evgenii Stratonikov
b7e86fa6a3 manifest: add Safe flag to method descriptor
`interop.Contex.AddMethod` sets `Safe` flag for native
contracts. This allows not to forget to change manifest
when changing call flags.
Also fixed invalid `Safe` flags for `Notary` and `Designate` contracts.
2020-12-08 13:27:43 +03:00
Roman Khimov
1672887123 nef: increase version field to 32 bytes
Follow recent C# changes.
2020-11-30 11:26:29 +03:00
Roman Khimov
4d0eaef510 nef: treat Version as string
Following changes in C# code and simpilifying things a lot.
2020-11-27 21:47:08 +03:00
Roman Khimov
e12c52f588 nef: change checksum calculation scheme
It's now being calculated for whole file, not just header.
2020-11-27 21:47:08 +03:00
Roman Khimov
0c7e727859 nef: drop scripthash
It's no longer a part of the file.
2020-11-27 21:47:08 +03:00
Roman Khimov
c5e39dfabf nef: forbid NEFs with zero-length scripts 2020-11-26 18:30:53 +03:00
Roman Khimov
b92ea2a48a manifest/compiler: drop hashes from ABI and debug info
See neo-project/neo-devpack-dotnet#391 and neo-project/neo#2044.
2020-11-26 18:30:49 +03:00
Roman Khimov
34d2eaf00e manifest: update maximum possible length
As per neo-project/neo#2002.
2020-11-26 18:07:20 +03:00
Evgenii Stratonikov
279b769fa3 manifest: support interface checking
There are some standards (NEP5, etc.) which impose
some restrictions on what methods and events a contract
must contain and their signatures. This commit supports
checking if arbitrary manifest complies with the standard.
2020-11-26 12:50:29 +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
Evgenii Stratonikov
b97dfae8d8 native: replace NEP-5 with NEP-17 2020-11-24 13:08:23 +03:00
Evgenii Stratonikov
c849176be7 manifest: include contract Name 2020-11-24 11:23:44 +03:00
Roman Khimov
3cb945f022 manifest: simplify marshaling 2020-11-13 21:46:26 +03:00
Roman Khimov
286d9185f4 smartcontract: remove contract features
We're featureless now, all contracts have access to storage and payable status
is to be determined via new NEP. Follow neo-project/neo#2060.
2020-11-13 21:26:23 +03:00
Roman Khimov
112fa5b92d smartcontract: drop unused ContractDetails
That's a remnant from 2.0.
2020-11-13 21:00:54 +03:00
Roman Khimov
0f827ee6ba
Merge pull request #1531 from nspcc-dev/core/applicationlog_with_multiple_triggers
core, rpc: store multiple execution results for single hash
2020-11-12 19:05:22 +03:00
Anna Shaleva
251a660b85 smartcontract: ignore case in trigger.FromString 2020-11-12 17:49:28 +03:00
Anna Shaleva
9c3d8cd398 smartcontract: fix nef.GetVersion
It should be able to parse versions like `1.1.1-rc.1`.

Close #1540.
2020-11-12 17:08:54 +03:00
Roman Khimov
eaa260474f trigger/core: split System trigger into OnPerist and PostPersist
Follow neo-project/neo#2022.
2020-10-29 19:17:07 +03:00
Evgenii Stratonikov
44abaa8ef3 smartcontract: implement GetDefaultHonestNodeCount
We may use this in other parts of code.
2020-10-08 13:48:14 +03:00
Roman Khimov
f45c032eff nef: limit the number of bytes to be read during decode 2020-10-07 18:30:44 +03:00
Roman Khimov
63c7469dfd manifest: limit its size when decoding 2020-10-07 18:29:19 +03:00
Evgenii Stratonikov
2d9ef9219a core: call _deploy method during create/update 2020-10-06 18:03:25 +03:00
Evgenii Stratonikov
b2a3a0851e emit: accept multiple opcodes in Opcode() 2020-10-06 18:03:25 +03:00
Anna Shaleva
acacac1b24 rpc: use state.AppExecResult for ApplicationLog marshalling
Closes #1371
2020-09-07 13:38:32 +03:00
Anna Shaleva
34df5d5949 smartcontract: update trigger.Type stringer
We have to explicitly specify the type of `All` trigger type for proper
automatic generation of string representation.
2020-09-07 11:13:58 +03:00
Anna Shaleva
e1a266ab86 smartcontract: increase MaxManifestSize 2020-08-27 11:50:09 +03:00
Evgenii Stratonikov
51cebe9e47 smartcontract: support creation of majority multisig scripts 2020-08-23 09:39:46 +03:00
Roman Khimov
8e619cc671
Merge pull request #1318 from nspcc-dev/fix/verifytests
Add tests for `verifyTx` and `verifyHeader`
2020-08-14 17:24:03 +03:00
Roman Khimov
92f37a5d36
Merge pull request #1324 from nspcc-dev/fix-goreportcard-issues
Fix goreportcard issues
2020-08-14 14:50:35 +03:00
Evgenii Stratonikov
7854dcfd8f core: replace interop names with named constants 2020-08-14 14:21:54 +03:00
Evgenii Stratonikov
f3650e20b0 vm: move InteropNameToID to a separate package 2020-08-14 13:54:11 +03:00
Roman Khimov
e7d13e6db2 *: fix misspellings found in Go Report Card 2020-08-14 12:16:24 +03:00
Evgenii Stratonikov
1eb9a4c6c6 core: allow to use verification contracts
In NEO3 we can't just appcall hash, as verification script has no access
to state. Instead we use `verify` method of an arbitrary contract.
2020-08-14 09:40:34 +03:00
Anna Shaleva
bcb7b9ba63 smartcontract: rename parameter ByteString to ByteArray
Debugger expects it to be ByteArray. C# compiler also compiles it
as `ByteArray` (in both manifest and debug.json).

The previous commit 6a2161207a changed
this line as C# implementation serializes Blockchain.ApplicationExecuted.Stack
as array of stackitem.Item and deserializes it as array of
smartcontract.Parameter.
2020-08-12 17:48:03 +03:00
Roman Khimov
dba248236c smartcontract: add CreateDefaultMultiSigRedeemScript
And use it where appropriate. Some of our code was just plain wrong (like the
one in GAS contract) and unification is always useful here.
2020-08-10 18:58:11 +03:00
Evgenii Stratonikov
bbae7318a5 smartcontract: adjust param types according to NEO3 2020-08-10 11:14:48 +03:00
Roman Khimov
0e2784cd2c always wrap errors when creating new ones with fmt.Errorf()
It doesn't really change anything in most of the cases, but it's a useful
habit anyway.

Fix #350.
2020-08-07 12:21:52 +03:00
Roman Khimov
5ef08f60ae remove github.com/pkg/errors from dependencies
It's not needed any more with Go 1.13 as we have wrapping/unwrapping in base
packages. All errors.Wrap calls are replaced with fmt.Errorf, some strings are
improved along the way.
2020-08-07 12:21:52 +03:00
Roman Khimov
ef53a45e7a
Merge pull request #1264 from nspcc-dev/smartcontract/manifest/supported_standards
smartcontract: add list of supported standards to manifest
2020-08-04 22:17:00 +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
Anna Shaleva
66ceaa6b75 smartcontract: add list of supported standards to manifest
Closes #1204
2020-08-04 17:29:44 +03:00
Roman Khimov
fa5ff8dd95
Merge pull request #1242 from nspcc-dev/fix/json
Implement lossless stackitem to json conversion
2020-08-04 12:59:47 +03:00
Anna Shaleva
b2aef6acbf smartcontract: calculate double-SHA256 for .nef files
Closes #1203
2020-08-03 14:25:27 +03:00
Evgenii Stratonikov
b53f0257f5 stackitem: change ByteArray type to ByteString
Adjust only string representation.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-31 16:07:16 +03:00
Evgenii Stratonikov
51ae12e4fd *: move syscall handling out of VM
Remove interop-related structures from the `vm` package.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2020-07-29 13:41:08 +03:00
Evgenii Stratonikov
685d44dbc1 *: support _initialize method in contracts
Invoke `_initialize` method on every call if present.
In NEO3 there is no entrypoint and methods are invoked by offset,
thus `Main` function is no longer required.
We still have special `Main` method in tests to simplify them.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
d2ddf7b7cb *: support invoking methods by offset
Allow to invoke methods by offset:
1. Every invoked contract must have manifest.
2. Check arguments count on invocation.
3. Change AppCall to a regular syscall.
4. Add test suite for `System.Contract.Call`.
2020-07-27 13:00:35 +03:00
Evgenii Stratonikov
a892e3ffa8 manifest: add Offset in method descriptor 2020-07-27 11:08:01 +03:00
Evgenii Stratonikov
e52c39ae7e manifest: remove EntryPoint from manifest 2020-07-27 11:08:01 +03:00
Roman Khimov
3f2f0be2c2
Merge pull request #1187 from nspcc-dev/neo3/interop/post-preview2_adjustment
interop: post-preview2 adjustment
2020-07-17 13:33:29 +03:00
Anna Shaleva
fddad0b475 core: adjust System.Contract.Create interop
Part of #1055.

It should check given scripthash against manifest groups and return the
contract state as a struct (not interop interface).
2020-07-17 09:28:52 +03:00