Skip to content

Commit

Permalink
feat: allow txList with zero byte
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Dec 9, 2022
1 parent 37992fd commit 7c40868
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/contracts/L1/v1/V1Proposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ library V1Proposing {
bytes calldata txList = inputs[1];
// perform validation and populate some fields
require(
txList.length > 0 &&
txList.length >= 0 &&
txList.length <= LibConstants.K_TXLIST_MAX_BYTES &&
meta.txListHash == txList.hashTxList(),
"L1:txList"
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/contracts/libs/LibTxDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ library LibTxDecoder {
function decodeTxList(
bytes calldata encoded
) public pure returns (TxList memory txList) {
if (encoded.length == 0) {
return txList;
}
LibRLPReader.RLPItem[] memory txs = LibRLPReader.readList(encoded);

Tx[] memory _txList = new Tx[](txs.length);
Expand Down
6 changes: 5 additions & 1 deletion packages/protocol/test/libs/LibTxDecoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ describe("LibTxDecoder", function () {
const txList: string[] = []
const txListBytes = await rlpEncodeTxList(txList)

const decoded = await libTxDecoder.callStatic.decodeTxList(
let decoded = await libTxDecoder.callStatic.decodeTxList(
txListBytes
)

expect(decoded.items.length).to.be.eql(0)

decoded = await libTxDecoder.callStatic.decodeTxList([])

expect(decoded.items.length).to.be.eql(0)
})

it("should revert with random bytes", async function () {
Expand Down

0 comments on commit 7c40868

Please sign in to comment.