In EVM circuit, ExecutionState
are not well balanced, some are very complicated and require many lookups, some are not. But the cost of EVM circuit is determined by the worst case, this note shows how we strike the balance by folding the layout and improve the lookup usage efficiency.
For example, we want to perform 2 lookup (bitwise and and bitwise or) to the same table without too much overhead.
The pseudo code looks like:
assert subset(
input=rlc(Tag::BitwiseAnd, a1, a2, a3),
table=rlc(fixed_table),
)
assert subset(
input=rlc(Tag::BitwiseOr, a1, a2, a4),
table=rlc(fixed_table),
)
In folded layout, we try to enable the lookup by constraining the compressed input to the same column of some rotation, to reuse the same subset argument as much as possible.
This layout helps reduce the amount of lookups in EVM circuit a lot.
The pseudo code looks like:
assert a5 == rlc(Tag::BitwiseAnd, a1, a2, a3)
assert a5_w == rlc(Tag::BitwiseOr, a1, a2, a4)
assert subset(
input=a5,
table=rlc(fixed_table),
)
To argue
Obviously,