Просмотр исходного кода

zkas/bincode: Don't write STACK_INDEX for constants.

We're keeping everything on the same stack so this is redundant.
parazyd 4 лет назад
Родитель
Сommit
a1e73c7f62
2 измененных файлов с 5 добавлено и 6 удалено
  1. 5 5
      book/src/zkas/bincode.md
  2. 0 1
      zkas/src/compiler.rs

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

@@ -20,8 +20,8 @@ The compiled binary blob has the following layout:
 MAGIC_BYTES
 MAGIC_BYTES
 BINARY_VERSION
 BINARY_VERSION
 .constant
 .constant
-CONSTANT_TYPE STACK_INDEX CONSTANT_NAME 
-CONSTANT_TYPE STACK_INDEX CONSTANT_NAME 
+CONSTANT_TYPE CONSTANT_NAME 
+CONSTANT_TYPE CONSTANT_NAME 
 ...
 ...
 .contract
 .contract
 WITNESS_TYPE
 WITNESS_TYPE
@@ -56,9 +56,9 @@ potential different formats in the future.
 
 
 ## `.constant`
 ## `.constant`
 
 
-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.
+The constants in the `.constant` section are declared with their type
+and name, so that the VM knows how to search for the builtin constant
+and add it to the stack.
 
 
 
 
 ## `.contract`
 ## `.contract`

+ 0 - 1
zkas/src/compiler.rs

@@ -50,7 +50,6 @@ impl Compiler {
         for i in &self.constants {
         for i in &self.constants {
             tmp_stack.push(i.name.as_str());
             tmp_stack.push(i.name.as_str());
             bincode.push(i.typ as u8);
             bincode.push(i.typ as u8);
-            bincode.extend_from_slice(&serialize(&VarInt(stack_idx)));
             bincode.extend_from_slice(&serialize(&i.name));
             bincode.extend_from_slice(&serialize(&i.name));
             stack_idx += 1;
             stack_idx += 1;
         }
         }