go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

Stateless witness builder

Open jwasinger opened this issue 1 year ago • 2 comments

Rebase of the witness builder on top of https://github.com/ethereum/go-ethereum/pull/29519 . Apparently I cannot re-open a closed pull request whose branch has been force pushed to.

This PR introduces necessary functionality to construct block witnesses. It doesn't include construction in block building, or cross-validation.

Only the blockchain test suite is modified with the introduction a stateless test. The test executes blockchain tests, constructing and verifying a proof for each block.

jwasinger avatar May 07 '24 04:05 jwasinger

This adds a new test suite TestStatelessBlockchain which adds a large amount of running time to CI. We may consider disabling it as a last step before merging this when it is approved.

jwasinger avatar May 14 '24 12:05 jwasinger

Converted back to draft while I address remaining TODOs (parts of the code are confusing rn).

jwasinger avatar May 14 '24 18:05 jwasinger

@karalabe this still fails 2 tests:

go test -run=StatelessBlockchain -timeout=20m
--- FAIL: TestStatelessBlockchain (0.34s)
    --- FAIL: TestStatelessBlockchain/InvalidBlocks/bcUncleHeaderValidity/gasLimitTooLowExactBound.json (0.01s)
        --- FAIL: TestStatelessBlockchain/InvalidBlocks/bcUncleHeaderValidity/gasLimitTooLowExactBound.json/gasLimitTooLowExactBound_Cancun (0.00s)
--- FAIL: TestStatelessBlockchain (0.51s)
    --- FAIL: TestStatelessBlockchain/InvalidBlocks/bcUncleHeaderValidity/gasLimitTooLowExactBound2.json (0.01s)
        --- FAIL: TestStatelessBlockchain/InvalidBlocks/bcUncleHeaderValidity/gasLimitTooLowExactBound2.json/gasLimitTooLowExactBound2_Cancun (0.00s)
panic: runtime error: index out of range [0] with length 0 [recovered]
	panic: runtime error: index out of range [0] with length 0

I need to fix those and double-check and clean up the diff (parts are still a bit messy). Overall, I think it's getting close though.

jwasinger avatar Jun 13 '24 04:06 jwasinger

@jwasinger @rjl493456442 @fjl @holiman PTAL, the PR is ready for review/merge.

karalabe avatar Jun 21 '24 11:06 karalabe

FWIW, I'd appreciate a merge commit vs. squash merge to retain ownership of my massive cleanup commit.

karalabe avatar Jun 21 '24 11:06 karalabe

One thing I want to change. Replace the pre-root hash with the parent header. In the current shape of the code the pre-root is trusted, which allows the block being verified to be malicious (i.e. unverified pre-root == unverified starting state == arbitrary post state). By adding the parent header we are proving the link between the validated block and the pre-root state (via the parent header).

karalabe avatar Jun 21 '24 13:06 karalabe

There are some wonkyness left in, but I have a followup PR which does the live integration and that does further cleanups. Better to have the witness stuff in here and then have the mushing into our live codebase separately. Also a lot of stuff gets deleted that will not be needed any more with a live hook.

karalabe avatar Jun 25 '24 11:06 karalabe

d86b650e54b037024f7b073379c267b0719e252a

immense055 avatar Jul 02 '24 21:07 immense055