Skip to content

Commit

Permalink
Support RLP encoded response for executionWitness
Browse files Browse the repository at this point in the history
  • Loading branch information
chunter-cb committed Jan 31, 2025
1 parent a565781 commit cbeb6b0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion op-proposer/proposer/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
)

Expand Down Expand Up @@ -166,8 +167,24 @@ func (e *ethClient) GetProof(ctx context.Context, address common.Address, hash c
}

func (e *ethClient) ExecutionWitness(ctx context.Context, hash common.Hash) (*stateless.ExecutionWitness, error) {
var rawWitness []byte
err := e.client.Client().CallContext(ctx, &rawWitness, "debug_executionWitness", hash)
if err != nil {
return nil, err
}

// If the response is RLP encoded (non-null and non-empty), decode it
if len(rawWitness) > 0 {
var witness stateless.ExecutionWitness
if err := rlp.DecodeBytes(rawWitness, &witness); err != nil {
return nil, err
}
return &witness, nil
}

// Fallback to JSON decoding
var witness stateless.ExecutionWitness
err := e.client.Client().CallContext(ctx, &witness, "debug_executionWitness", hash)
err = e.client.Client().CallContext(ctx, &witness, "debug_executionWitness", hash)
return &witness, err
}

Expand Down

0 comments on commit cbeb6b0

Please sign in to comment.