LCS port to python and ruby

We release the python and ruby implementaion for the Libra Canonical Serialization (LCS) Spec.

LCS for pythoner

LCS for rubyer

Feedback is welcome.

5 Likes

LCS for python canoser-python is updated from version 0.3.x to version 0.4, with following updates:

  • Support optional type. Optional type is needed in ledger_info verification, because next_validator_set field of ledger_info is optional, and the hash of ledger_info is computed from its LCS bytes.
  • Support rust tuple struct in python with ‘canoser.DelegateT’ type.
  • Pretty printing

We implemented all libra test cases, even those in the libra readme document.
Libra Canonical Serialization Readme Test

1 Like

During writting test cases for the LCS Readme document, we found some mismatches between the document and the libra code. For example:

Program in document:

{
sender: 3a24a61e05d129cace9e0efc8bc9e33831fec9a9be66f50fd352a2638a49b9ee,
sequence_number: 32,
payload: Program {
code: “move”,
args: [{STRING: CAFE D00D}, {STRING: cafe d00d}],
modules: [[CA][FED0][0D]],
} ,
max_gas_amount: 10000,
gas_unit_price: 20000,
expiration_time: 86400 seconds
}

Real code output:

{
sender: 3a24a61e05d129cace9e0efc8bc9e33831fec9a9be66f50fd352a2638a49b9ee,
sequence_number: 32,
payload: Program(
Program {
code: “move”,
args: [
{STRING: CAFE D00D},
{STRING: cafe d00d},
],
},
),
max_gas_amount: 10000,
gas_unit_price: 20000,
expiration_time: 86400s,
}

The modules fields is missing.
The WriteSet has even more mismatches.

2 Likes