Skip to content

Commit

Permalink
Updated byte management for l1txs
Browse files Browse the repository at this point in the history
  • Loading branch information
Shailu-s committed Nov 13, 2024
1 parent a0b52bd commit bd2f5e4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sequencer/common/l1tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ func (tx L1Tx) Tx() Tx {
// [ 1 bits ] empty (toBJJSign) // 1 byte
// [ 8 bits ] empty (userFee) // 1 byte
// [ 40 bits ] empty (nonce) // 5 bytes
// [ 48 bits ] toIdx // 6 bytes
// [ 48 bits ] fromIdx // 6 bytes
// [ 32 bits ] toIdx // 4 bytes
// [ 32 bits ] fromIdx // 4 bytes
// [ 16 bits ] chainId // 2 bytes
// [ 32 bits ] empty (signatureConstant) // 4 bytes
// Total bits compressed data: 225 bits // 29 bytes in *big.Int representation
Expand Down Expand Up @@ -213,7 +213,7 @@ func L1UserTxFromBytes(b []byte) (*L1Tx, error) {
pkCompB := b[20:52]
pkCompL := SwapEndianness(pkCompB)
copy(tx.FromBJJ[:], pkCompL)
fromIdx, err := AccountIdxFromBytes(b[52:58])
fromIdx, err := AccountIdxFromBytes(b[52:56])
if err != nil {
return nil, Wrap(err)
}
Expand All @@ -226,7 +226,7 @@ func L1UserTxFromBytes(b []byte) (*L1Tx, error) {
if err != nil {
return nil, Wrap(err)
}
tx.ToIdx, err = AccountIdxFromBytes(b[72:78])
tx.ToIdx, err = AccountIdxFromBytes(b[72:76])
if err != nil {
return nil, Wrap(err)
}
Expand All @@ -243,12 +243,12 @@ func L1TxFromDataAvailability(b []byte, nLevels uint32) (*L1Tx, error) {
amountBytes := b[idxLen*2 : idxLen*2+Float40BytesLength]

l1tx := L1Tx{}
fromIdx, err := AccountIdxFromBytes(ethCommon.LeftPadBytes(fromIdxBytes, 6))
fromIdx, err := AccountIdxFromBytes(ethCommon.LeftPadBytes(fromIdxBytes, 4))
if err != nil {
return nil, Wrap(err)
}
l1tx.FromIdx = fromIdx
toIdx, err := AccountIdxFromBytes(ethCommon.LeftPadBytes(toIdxBytes, 6))
toIdx, err := AccountIdxFromBytes(ethCommon.LeftPadBytes(toIdxBytes, 4))
if err != nil {
return nil, Wrap(err)
}
Expand Down Expand Up @@ -326,7 +326,7 @@ func (tx *L1Tx) BytesGeneric() ([]byte, error) {
if err != nil {
return nil, Wrap(err)
}
copy(b[52:58], fromIdxBytes[:])
copy(b[52:56], fromIdxBytes[:])

depositAmountFloat40, err := NewFloat40(tx.DepositAmount)
if err != nil {
Expand Down Expand Up @@ -355,7 +355,7 @@ func (tx *L1Tx) BytesGeneric() ([]byte, error) {
if err != nil {
return nil, Wrap(err)
}
copy(b[72:78], toIdxBytes[:])
copy(b[72:76], toIdxBytes[:])
return b[:], nil
}

Expand Down

0 comments on commit bd2f5e4

Please sign in to comment.