polymerdao / monomer

Build Cosmos SDK applications on the OP Stack.
http://monomer.nethermind.io/
Apache License 2.0
20 stars 13 forks source link

Use protobuf marshaling instead of json marshaling for L1BlockInfo #233

Closed natebeauregard closed 3 weeks ago

natebeauregard commented 1 month ago

Currently, we use json marshaling when adding L1BlockInfo to the x/rollup store.

To improve marshal size and performance we should create a new proto message for L1BlockInfo and use protobuf marshaling to marshal the block info to binary.

Jesserc commented 4 weeks ago

@natebeauregard when creating the proto message, should we use proto default types? i.e, bytes for common.Address, bytes for big.Int

Something like this:

message L1BlockInfo {
  uint64 number = 1;
  uint64 time = 2;
  bytes base_fee = 3; // big.Int
  bytes block_hash = 4; // common.Hash
  uint64 sequence_number = 5; // Number of L2 blocks since the start of the epoch
  bytes batcher_addr = 6; // common.Address, version 0 is just the address with 0 padding to the left
  bytes l1_fee_overhead = 7; // eth.Bytes32, ignored after Ecotone upgrade
  bytes l1_fee_scalar = 8; // eth.Bytes32, ignored after Ecotone upgrade
  bytes blob_base_fee = 9; // big.Int, added by Ecotone upgrade
  uint32 base_fee_scalar = 10; // added by Ecotone upgrade
  uint32 blob_base_fee_scalar = 11; // added by Ecotone upgrade
}
natebeauregard commented 4 weeks ago

@Jesserc Thanks for taking this on. Yeah let's just use scalars where they match up or bytes if there isn't a scalar to represent the value.