diff --git a/execution.go b/execution.go index 876addf..48662d9 100644 --- a/execution.go +++ b/execution.go @@ -145,7 +145,7 @@ func (c *EngineAPIExecutionClient) InitChain(ctx context.Context, genesisTime ti return execution_types.Hash{}, 0, fmt.Errorf("engine_getPayloadV3 failed: %w", err) } - stateRoot := common.HexToHash(payloadResult.ExecutionPayload.StateRoot.Hex()) + stateRoot := payloadResult.ExecutionPayload.StateRoot rollkitStateRoot := execution_types.Hash(stateRoot[:]) gasLimit := payloadResult.ExecutionPayload.GasLimit diff --git a/execution_test.go b/execution_test.go index c66d367..c8d9155 100644 --- a/execution_test.go +++ b/execution_test.go @@ -77,12 +77,14 @@ func TestEngineAPIExecutionClient_ExecuteTxs(t *testing.T) { defer mockEth.Close() jwtSecret := generateTestJWTSecret() + prevStateRoot := execution_types.Hash(common.Hex2Bytes("111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000")) + client, err := NewEngineAPIExecutionClient( &proxy_json_rpc.Config{}, mockEth.URL, mockEngine.URL, jwtSecret, - common.Hash{}, + common.Hash(prevStateRoot), common.Address{}, ) require.NoError(t, err) @@ -90,8 +92,6 @@ func TestEngineAPIExecutionClient_ExecuteTxs(t *testing.T) { blockHeight := uint64(1) timestamp := time.Now().UTC().Truncate(time.Second) - prevStateRoot := execution_types.Hash(common.Hex2Bytes("111122223333444455556666777788889999aaaabbbbccccddddeeeeffff0000")) - testTxBytes, err := types.NewTransaction(1, common.Address{}, big.NewInt(0), 1000, big.NewInt(875000000), nil).MarshalBinary() require.NoError(t, err) testTx := execution_types.Tx(testTxBytes) @@ -113,10 +113,8 @@ func TestEngineAPIExecutionClient_ExecuteTxs(t *testing.T) { require.Equal(t, common.BytesToHash(prevStateRoot[:]).Hex(), lastCall.FinalizedBlockHash) mockStateRoot := common.HexToHash("0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef") - var expectedStateRoot execution_types.Hash - copy(expectedStateRoot[:], mockStateRoot.Bytes()) - require.Equal(t, expectedStateRoot, stateRoot) + require.Equal(t, execution_types.Hash(mockStateRoot[:]), stateRoot) require.Equal(t, uint64(21000), gasUsed) } diff --git a/integration_test.go b/integration_test.go index 43e4135..0157e87 100644 --- a/integration_test.go +++ b/integration_test.go @@ -201,7 +201,7 @@ func TestExecutionClientLifecycle(t *testing.T) { stateroot, gasUsed, err := executionClient.ExecuteTxs(context.Background(), []rollkit_types.Tx{rollkit_types.Tx(txBytes)}, blockHeight, blockTime, rollkitGenesisStateRoot) require.NoError(t, err) assert.Greater(t, gasLimit, gasUsed) - assert.Equal(t, newStateroot.Bytes(), []byte(stateroot)) + assert.Equal(t, rollkit_types.Hash(newStateroot[:]), stateroot) }) }