Proposal:NxtScriptOpcode

From Nxt Wiki
Jump to: navigation, search

Come-from-Beyond's proposal:


https://bitcointalk.org/index.php?topic=345619.msg4954500#msg4954500

Regarding Scripts:

  • Every script will reserve a chunk of memory (subject to fee charging).
  • Every memory cell will be a signed 64-bit integer.
  • Scripts won't be able to modify themselves nor other scripts, so JIT-compilation could be easily used.
  • Scripts will run in a sandbox by a byte-code interpretator.
  • Each operation will require the same amount of NXT, if an account runs out of coins then interpretation is halted.
  • Scripts will be able to read block and transaction data in format-agnostic manner, they will also be able to "send" transaction. Such the transactions won't require to be signed, they will be able to spend money from the original account only.
  • Forgers won't "interpret" scripts, interpretation will occur during pushing the block.

Only pure logic, block/transaction handling will be added later. All numbers r signed 64-bit integers when accessing Data and signed 32-bit integers when referring to Code.


Anyone can include a script into the script blockchain by sending it as a transaction to a forger. Scripts are executed when blocks are added to the blockchain.

https://bitcointalk.org/index.php?topic=345619.msg4959340#msg4959340

 Legend: C - constant, M - memory
 M = C
 M = M
 M = M + M
 M = M - M
 M = M * M
 M = M / M
 M = M % M
 M = ~M
 M = M & M
 M = M | M
 M = M ^ M (XOR)
 M = M << M
 M = M >> M
 M = M >>> M (signed shift)
 M == M @ C (this is read as "if M1 equals M2 then jump to instruction at position C")
 M != M @ C
 M <  M @ C
 M <= M @ C
 M >  M @ C
 M >= M @ C
 @ M (this is an unconditional jump, needed for subroutines)

Code will be read-only and without ability to jump somewhere in the middle of instruction bytes that would lead to morphing of the code.

[C] or [M] accesses the memory at that location.