ChainSafe / ChainSafe/canton-middleware

test(e2e): unskip eth_getBlockByNumber and eth_getBlockByHash RPC tests

Open
#225 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
1
Forks
1
Avg merge
40m
Merged PRs (30d)
1

Description

## Background

Two E2E tests in `tests/e2e/tests/api/rpc_test.go` are currently hard-skipped:

- `TestRPC_GetBlockByNumber`
- `TestRPC_GetBlockByHash`

Both are skipped with the same reason:

```
t.Skip("api-server /eth facade returns blocks without uncle metadata; ethclient uncle-list validation fails")
```

## Root Cause

The api-server's `/eth` JSON-RPC facade returns synthetic blocks assembled from Canton ledger state. The block struct (`ethrpc.RPCBlock`) populates:

- `Sha3Uncles: common.Hash{}` — the zero hash
- `Uncles: []common.Hash{}` — empty slice

The go-ethereum `ethclient` deserialises the raw JSON response and validates that `sha3Uncles` matches the actual SHA3 of the uncle list. The zero hash (`0x000...`) does **not** match the SHA3 of an empty uncle list (`0x1dcc4de8dec75d7aab85b567b6ccd41a...` — the well-known empty uncle hash). This causes `ethclient.BlockByNumber` / `ethclient.BlockByHash` to return an error, failing the test.

The fix is in `pkg/ethrpc/service/service.go` `GetBlockByNumber`: set `Sha3Uncles` to the correct empty-uncle SHA3 constant rather than the zero hash:

```go
// types.EmptyUncleHash is keccak256(rlp([]))
Sha3Uncles: types.EmptyUncleHash,
```

Once that change is made, the two test `t.Skip` calls can be removed and the tests should pass against the live devstack.

## Acceptance Criteria

- [ ] `pkg/ethrpc/service/service.go`: `Sha3Uncles` set to `types.EmptyUncleHash` (not `common.Hash{}`)
- [ ] `TestRPC_GetBlockByNumber` unskipped and passing in CI
- [ ] `TestRPC_GetBlockByHash` unskipped and passing in CI
- [ ] Existing unit test in `pkg/ethrpc/service/eth_api_test.go` updated to assert the correct `Sha3Uncles` value

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in pkg/ethrpc/service/service.go at GetBlockByNumber and inspect the block fields described in the issue. Update the existing unit coverage in pkg/ethrpc/service/eth_api_test.go, remove the skips from tests/e2e/tests/api/rpc_test.go, and run the unit and E2E RPC tests. Done means both block lookup tests pass and Sha3Uncles matches the empty-uncle value.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.