Comments (4)
Can we use UNPACK
?
from neo-vm.
Very goooooood Shargon! Now it's better... we just use CONVERT
and then use UNPACK
.
But that will work? Because unpack puts a lot of elements in stack... we would need to somehow unpack [0x01,0x02,0x03]
into 0x010203
. But you gave me an idea, perhaps we could reuse PACK
, if a bytearray is on stack then it just converts it to array, byte to byte:
https://github.com/neo-project/neo-vm/blob/master/src/neo-vm/ExecutionEngine.cs#L699
The thing is, we would need to check the type, to make sure it's a biginteger and not a byte array, and since many codes do PUSH1 - PACK, is this "1" a bytearray with a single element, or number 1?
from neo-vm.
Can we use
UNPACK
?
Now I got your point Shargon!! I think UNPACK
is good to work as a conversor from ByteArray to Array:
neo-vm/src/neo-vm/ExecutionEngine.cs
Lines 713 to 719 in 94a91ae
So, it could be:
PUSH10 ababababab...
UNPACK # (new UNPACK function) converts byte[] to Array (of byte) on stack [ab,ab,ab...]
DUP # duplicates Array on stack
REVERSE # reverse and drop array
??? # convert Array back to byte[] on stack
Now we need to "really unpack" and apply several concats here, to merge them in a single byte array.
======
GOT IT!! Now we use PACK
again hahaah but PACK receives an integer usually, if it receives an Array, then it know it has to merge to a single byte[] ;)
PUSH10 ababababab...
UNPACK # (new UNPACK functionality) converts byte[] to Array (of byte) on stack [ab,ab,ab...]
DUP # duplicates Array on stack
REVERSE # reverse and drop array
PACK # (new PACK functionality) convert Array back to byte[] on stack
No need for CONVERT xD
from neo-vm.
Now I think this breaks semantics, and we have much better options for Neo3.
from neo-vm.
Related Issues (20)
- Add 'utf8Size' opcode HOT 4
- Script checks are incomplete
- Can I integrate this vm in to my custom projects? HOT 1
- Efficient way to pass Map type to contract method? OpCode.PACKMAP? HOT 1
- Adapt code documentation of UNPACK opcode
- ReferenceCounter can become negative HOT 18
- Is this `MEMCPY` expected to push nothing to the stack?
- ScriptBuilder should have an emitPush overload that takes a ReadOnlySpan<byte>
- How to customize an interface in interoperation service layer HOT 3
- Presssure test on v3.3.0 cause execution failed HOT 1
- v3.3.0 need more than 30 hours for syncing mainnet even it's just about 1.7million blocks HOT 2
- What is the purpose of the second assert of this test? HOT 1
- Instruction pointer reading PUSHDATA4 operand size as *signed* int32 HOT 1
- Missing push in APPEND?
- EmitPush(bool) should convert stackitem to right type
- Buffer to Integer conversion inconsistency HOT 1
- Override GetString for Buffer/ByteString ? HOT 4
- Set Operation in a Get Function HOT 2
- Add Equatable for StackItem
- Problem trying to PICKITEM from ByteString and then CAT ByteString and a single Byte picked from ByteString HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo-vm.