Parcourir la source

zkas/compiler: Place CONSTANT_NAME as last in the declaration.

parazyd il y a 4 ans
Parent
commit
431f95dbb6
2 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 5 5
      book/src/zkas/bincode.md
  2. 1 1
      zkas/src/compiler.rs

+ 5 - 5
book/src/zkas/bincode.md

@@ -18,8 +18,8 @@ The compiled binary blob has the following layout:
 
 ```
 .constant
-CONSTANT_NAME CONSTANT_TYPE STACK_INDEX
-CONSTANT_NAME CONSTANT_TYPE STACK_INDEX
+CONSTANT_TYPE STACK_INDEX CONSTANT_NAME 
+CONSTANT_TYPE STACK_INDEX CONSTANT_NAME 
 ...
 .contract
 WITNESS_TYPE STACK_INDEX
@@ -35,9 +35,9 @@ TBD
 
 ## `.constant`
 
-The constants in the `.constant` section are declared with their name
-and type, so that the VM knows how to search for the builtin constant
-and add it to the stack.
+The constants in the `.constant` section are declared with their type
+stack index, and name, so that the VM knows how to search for the
+builtin constant and add it to the stack.
 
 ## `.contract`
 

+ 1 - 1
zkas/src/compiler.rs

@@ -40,9 +40,9 @@ impl Compiler {
         bincode.extend_from_slice(b".constant");
         for i in &self.constants {
             tmp_stack.push(i.name.as_str());
-            bincode.extend_from_slice(i.name.as_bytes());
             bincode.push(i.typ as u8);
             bincode.extend_from_slice(&stack_idx.to_le_bytes());
+            bincode.extend_from_slice(i.name.as_bytes());
             stack_idx += 1;
         }