fluidex / circuits

GNU Affero General Public License v3.0
10 stars 5 forks source link

Update txdata encoding scheme #197

Closed noel2004 closed 2 years ago

noel2004 commented 2 years ago

The public txdata encoding scheme for data availability is updated for deposit again because the L1 contract need to access (read or encode) the pubdata so a encode / decode scheme which saves gas cost as much as possible is essential:

  1. The encoded data for deposit tx should be accommodated in 256bit bytes so the contract can manipulate the data by arithmetic ops on single data of uint256 type.
  2. The encoded amount should not be compressed to 40bit. We use 128bit uint for encoding amount field because the rust-decimal, which is widely used for expressing amount inside our code, is also a 128bit represent data type.

We also induce a version file, which would be used by rollup manager to identify each updating in circuits and cooperating with it. Commonly we just use an integer for the version, which is the id of PR which has updated the code.