13 个版本 (4 个破坏性更新)

0.6.0 2021 年 5 月 6 日
0.4.0 2021 年 4 月 14 日
0.2.0 2021 年 3 月 11 日
0.1.4 2021 年 3 月 30 日
0.0.8 2020 年 12 月 29 日

#47 in #rollup

每月 31 次下载

MIT 许可证

665KB
81

包含 (ELF exe/lib, 330KB) build/validator_log, (ELF exe/lib, 310KB) build/generator, (ELF exe/lib, 315KB) build/generator_log, (ELF exe/lib, 325KB) build/validator

Godwoken polyjuice

Godwoken rollup 框架的兼容 Ethereum 后端。它包含生成器和验证器实现。

特性

  • 所有操作码
  • 值传输
  • 预编译合约
    • ecrecover
    • sha256hash
    • ripemd160hash
    • dataCopy
    • bigModExp
    • bn256AddIstanbul
    • bn256ScalarMulIstanbul
    • bn256PairingIstanbul (性能问题)
    • blake2F

数据结构

Polyjuice 参数

header     : [u8; 8]  (header[0]    = 0xff, 
                       header[1]    = 0xff, 
                       header[2]    = 0xff, 
                       header[3..7] = "POLY"
                       header[7]    = call_kind { 0: CALL, 3: CREATE })
gas_limit  : u64      (little endian)
gas_price  : u128     (little endian)
value      : u128     (little endian)
input_size : u32      (little endian)
input_data : [u8; input_size]   (input data)

每个 Polyjuice 参数字段必须按顺序序列化并放入 godwoken RawL2Transaction.args,以便 Polyjuice 读取。如果 input_data 有 56 个字节,则序列化数据大小为 8 + 8 + 16 + 16 + 4 + 56 = 108 字节。

创建者账户脚本

code_hash: polyjuice_validator_type_script_hash
hash_type: type
args:
    rollup_type_hash : [u8; 32]
    sudt_id          : u32          (little endian, the token id)

Polyjuice 创建者账户是用于创建 Polyjuice 合约账户的 Godwoken 账户。此账户只能由 元合约 创建,账户 ID 用作 Polyjuice 中的链 ID。脚本参数中的 sudt_id 字段是当前 Polyjuice 实例绑定的 sudt 代币。

普通合约账户脚本

code_hash: polyjuice_validator_type_script_hash
hash_type: type
args:
    rollup_type_hash   : [u8; 32]
    creator_account_id : u32        (little endian, also chain id, and for reading 'sudt_id' from creator account script)
    sender_account_id  : u32        (little endian)
    sender_nonce       : u32        (little endian)

通过 CREATE 调用类型或操作码在 Polyjuice 中创建的 Polyjuice 合约账户。

Create2 合约账户脚本

code_hash: polyjuice_validator_type_script_hash
hash_type: type
args:
    rollup_type_hash   : [u8; 32]
    creator_account_id : u32        (little endian, also chain id, and for reading 'sudt_id' from creator account script)
    special_byte       : u8         (value is '0xff', refer to ethereum)
    sender_account_id  : u32        (little endian)
    create2_salt       : [u8; 32]   (create2 salt)
    init_code_hash     : [u8; 32]   (keccak256(init_code))

通过 CREATE2 操作码在 Polyjuice 中创建的 Polyjuice 合约账户。

依赖

~0.4–1.5MB
~17K SLoC