Skip to content

Commit

Permalink
Merge branch 'jni/1802' into jay/execution-api
Browse files Browse the repository at this point in the history
  • Loading branch information
jim380 committed Nov 20, 2024
2 parents 67842d2 + f5b501d commit 0d60d58
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ 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)

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)
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down

0 comments on commit 0d60d58

Please sign in to comment.