espresso-sequencer
                                
                                 espresso-sequencer copied to clipboard
                                
                                    espresso-sequencer copied to clipboard
                            
                            
                            
                        refactor: block and namespace logic
tl;dr
- Removes the generic parameter TableWord.
- Removes the TxTableEntryandTxTableEntryWord.
- Introduces a TableWordstruct using const generics with an implementation that mimics the "old"TxTableEntrybut makes room for other implementations ofTableWord(Offset, TableLen, NsId).
Direction
This PR is a proposal for the direction of block/namespace logic:
- 
Table interaction should be through appropriate methods on NamespaceTableandTxTable. FxPayloadshould not deal with this. See comment: https://github.com/EspressoSystems/espresso-sequencer/blob/6dfaebf134dbcb47a485bc937ee756ef69bde0a8/sequencer/src/block/payload.rs#L55-L58
- 
Different implementations of TableWordcan support different words types (Offset, TableLen, NsId).
 Example Below:
pub trait Table {
    type TableLenWord: TableLenTraits;
    type NsIdWord: NsIdTraits;
    fn get_table_len(&self, offset: usize) -> TableLenWord;
    ...
} 
pub struct NameSpaceTable {
    pub(super) bytes: Vec<u8>,
}
impl Table for NameSpaceTable {
    // the word of table length is 4 bytes and is represented as u32
    type TableLenWord = TableWord<u32, 4>;
    type NsIdWord = TableWord<u64, 8>;
    ...
This this PR looks like a step in the right direction. If we can achieve to implement the example shown above (see "Different implementations of TableWord can support different words types (Offset, TableLen, NsId). Example Below:") it feels to me that we would have achieved our goal of abstracting the complexity of dealing with table words.
Just had a call with Anders to discuss plans.