Commit graph

95 commits

Author SHA1 Message Date
Evgenii Stratonikov
b12add5a78 smartcontract: rewrite trigger types for NEO3 2020-06-11 13:16:07 +03:00
Evgenii Stratonikov
61edc8705e smartcontract: start flags with 1
`iota` keyword is equal to the index of the declaration in the
corresponding block, thus AllowStates was 2 in our case.
2020-06-11 13:03:55 +03:00
Evgenii Stratonikov
532262827d smartcontract: add CallFlag.Has() helper 2020-06-11 13:03:55 +03:00
Evgenii Stratonikov
ebbf0321b2 smartcontract: add AllowStates call flag 2020-06-11 13:03:55 +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
76a2f62fbd cli: use manifest during contract deployment 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
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
783f5ecb01 vm: move StackItem to a separate package
closes #912
2020-06-08 13:27:08 +03:00
Evgenii Stratonikov
96c2cc0322 smartcontract: marshal ByteArray and Signature in base64 2020-06-08 10:27:39 +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
f445f7c602 transaction: drop Contract transaction type 2020-06-05 19:20:16 +03:00
Roman Khimov
fed95e0069 smartcontract: (un)marshal AnyType value as null
Neo 3 can emit Null in its transfer notifications in `from` or `to` fields
when minting/burning tokens (unlike Neo 2 that emitted util.Uint256{} for this
case), then it gets converted to Parameter as AnyType and we have to JSONize
it somehow for proper RPC functioning.
2020-06-05 19:20:16 +03:00
Roman Khimov
03ecab5eec smartcontract: add JSON marshal/unmarshal for InteropType
We actually have to do that in order to answer getapplicationlog requests for
transactions that leave some interop items on the stack. It follows the same
logic our binary serializer/deserializes does leaving the type and stripping
the value (whatever that is).
2020-05-25 00:27:39 +03:00
Anna Shaleva
7acf5b2841 core: add SystemFee and NetworkFee to transaction
closes #831
2020-05-20 23:26:48 +03:00
Anna Shaleva
861aca1547 rpc, smartcontract: move contract metadata to smartcontract package 2020-05-04 08:37:39 +03:00
Evgenii Stratonikov
008e6eb233 vm: implement new PUSH opcodes 2020-04-23 10:52:28 +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
Evgenii Stratonikov
25354c44f9 core: implement NativeContract support 2020-04-16 15:55:34 +03:00
Evgenii Stratonikov
dd38e3ec3b smartcontract: add smartcontract manifest
Manifest contains all of smartcontract's metadata including
parameters, return value, permissions etc.
2020-04-16 14:05:32 +03:00
Evgenii Stratonikov
6b7a57a66f smartcontract: add Any type for parameter
It is used as a wildcard for default return type of a contract and
for a Null stack item.
2020-04-02 14:15:17 +03:00
Roman Khimov
f64aa201c7
Merge pull request #819 from nspcc-dev/fix/util160_marshalling
smartcontract: fix uint160 marshalling in smartcontract.Parameter
2020-04-01 22:04:30 +03:00
Anna Shaleva
5a62eb923e smartcontract: fix uint160 marshalling in smartcontract.Parameter
There's a bug after #785: smartcontract.Parameter of type hash160 should
be marshalled in LE (as default marshaller for uint160 does) instead of
BE, so fixed.
2020-04-01 20:48:46 +03:00
Roman Khimov
25201d480d smartcontract: simplify Array JSON marshalling 2020-04-01 19:21:00 +03:00
Roman Khimov
3dbe549a61 smartcontract: store MapType Parameter as a slice of KV pairs
Fixes #809.

Basically, there are three alternative approaches to fixing it:
 * allowing both []byte and string for ByteArrayType value
   minimal invasion into existing code, but ugly as hell and will probably
   backfire at some point
 * storing string values in ByteArrayType
   incurs quite a number of type conversions (and associated data copying),
   though note that these values are not changed usually, so dynamic
   properties of []byte are almost irrelevant here
 * storing only []byte values in ByteArrayType
   makes it impossible to use them as map keys which can be solved in several
   ways:
   - via an interface (Marshalable)
     which is good, but makes testing and comparing values in general harder,
     because of keys mismatch
   - using serialized Parameter as a key (in a string)
     which will need some additional marshaling/unmarshaling
   - converting MapType from map to a slice of key-value pairs
     not a bad idea as we don't use this map as a map really, the type
     itself is all about input/output for real VM types and this approach is
     also a bit closer to JSON representation of the Map
2020-04-01 19:21:00 +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
5f876aaeda smartcontract: do not require pointer in MarshalYAML
It is a single byte anyway.
Now `contract init` works properly.
2020-03-25 16:26:39 +03:00
Roman Khimov
751e79d480
Merge pull request #785 from nspcc-dev/feature/uint160_marshalling
util: JSONify uint160 using LE instead of BE
2020-03-24 12:41:07 +03:00
Anna Shaleva
2001a40312 util: JSONify uint160 using LE instead of BE
closes #769
2020-03-23 17:38:58 +03:00
Evgenii Stratonikov
6ac69d075e smartcontract: implement io.Serializable for Parameter 2020-03-23 16:27:47 +03:00
Evgenii Stratonikov
0f17b9be1d smartcontract: use int64 for Integer parameter value 2020-03-23 16:24:57 +03:00
Evgenii Stratonikov
9666e99a17 smartcontract: marshal Integer values to JSON-strings
It is done so in C# implementation, we better be
as compatible as possible.
Closes #770.
2020-03-18 11:58:17 +03:00
Evgenii Stratonikov
1e7b47ec05 smartcontract: always use int64 for integers
It is good when internal representation is unique.
2020-03-18 11:58:17 +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
Evgenii Stratonikov
b945f4346a smartcontract: marshal Arrays properly 2020-03-05 18:22:40 +03:00
Evgenii Stratonikov
85755a4628 smartcontract: implement (*ParameterContext).GetWitness()
After all signatures were accumulated it should be possible
to extract Witness for the verifiable item.
2020-03-05 09:45:33 +03:00
Evgenii Stratonikov
cd487e3ad4 smartcontract: implement (*ParameterContext).AddSignature() 2020-03-05 09:45:11 +03:00
Evgenii Stratonikov
0d419d3899 smartcontract: implement ParameterContext 2020-03-05 09:43:14 +03:00
Evgenii Stratonikov
acea3867b2 smartcontract: implement ContextItem 2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
46db4e9d9d smartcontract: rename param_context.go to parameter.go 2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
924d920423 smartcontract: support JSON unmarshaling of Signature param 2020-03-04 20:01:26 +03:00
Evgenii Stratonikov
b4f8d66bd3 smartcontract: allow to marshal nil parameters 2020-03-04 19:55:04 +03:00
Evgenii Stratonikov
7cde58f731 smartcontract: adjust parameter value to type properly 2020-03-04 19:49:50 +03:00
Roman Khimov
f5a1b928ce pkg: fix gofmt issues 2020-03-03 17:22:15 +03:00
Roman Khimov
e41d434a49 *: move all packages from CityOfZion to nspcc-dev 2020-03-03 17:21:42 +03:00
Evgenii Stratonikov
1264b629f1 smartcontract: parse Struct item type same way as Array 2020-03-02 18:05:26 +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
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