diff --git a/rvgo/fast/evm.go b/rvgo/fast/evm.go index 696a0fc1..f90ed3d5 100644 --- a/rvgo/fast/evm.go +++ b/rvgo/fast/evm.go @@ -3,7 +3,7 @@ package fast import "github.com/ethereum/go-ethereum/crypto" var ( - StepBytes4 = crypto.Keccak256([]byte("step(bytes,bytes)"))[:4] + StepBytes4 = crypto.Keccak256([]byte("step(bytes,bytes,bytes32)"))[:4] CheatBytes4 = crypto.Keccak256([]byte("cheat(uint256,bytes32,bytes32,uint256)"))[:4] LoadKeccak256PreimagePartBytes4 = crypto.Keccak256([]byte("loadKeccak256PreimagePart(uint256,bytes)"))[:4] ) diff --git a/rvgo/fast/witness.go b/rvgo/fast/witness.go index 549005b8..9b6538c7 100644 --- a/rvgo/fast/witness.go +++ b/rvgo/fast/witness.go @@ -5,9 +5,12 @@ import ( "errors" "fmt" - "github.com/ethereum-optimism/optimism/op-preimage" + preimage "github.com/ethereum-optimism/optimism/op-preimage" + "github.com/ethereum/go-ethereum/common" ) +type LocalContext common.Hash + type StepWitness struct { // encoded state witness State []byte @@ -27,19 +30,25 @@ func uint64ToBytes32(v uint64) []byte { func (wit *StepWitness) EncodeStepInput() []byte { abiStatePadding := (32 - (uint64(len(wit.State)) % 32)) % 32 + abiProofPadding := (32 - (uint64(len(wit.MemProof)) % 32)) % 32 var input []byte input = append(input, StepBytes4...) - input = append(input, uint64ToBytes32(32*2)...) // state data offset in bytes - input = append(input, uint64ToBytes32(32*2+32+uint64(len(wit.State))+abiStatePadding)...) // proof data offset in bytes - // TODO pad state data to multiple of 32 bytes - // TODO also pad proof data - - input = append(input, uint64ToBytes32(uint64(len(wit.State)))...) // state data length in bytes + // state data offset in bytes + input = append(input, uint64ToBytes32(32*3)...) + // proof data offset in bytes + input = append(input, uint64ToBytes32(32*3+32+uint64(len(wit.State))+abiStatePadding)...) + // dummy localContext + input = append(input, make([]byte, 32)...) + + // state data length in bytes + input = append(input, uint64ToBytes32(uint64(len(wit.State)))...) input = append(input, wit.State[:]...) input = append(input, make([]byte, abiStatePadding)...) - input = append(input, uint64ToBytes32(uint64(len(wit.MemProof)))...) // proof data length in bytes + // proof data length in bytes + input = append(input, uint64ToBytes32(uint64(len(wit.MemProof)))...) input = append(input, wit.MemProof[:]...) + input = append(input, make([]byte, abiProofPadding)...) return input }