Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engine-api support #5

Merged

Conversation

MoonShiesty
Copy link

@MoonShiesty MoonShiesty commented Sep 20, 2023

This PR adds support to specular-geth to support deterministic execution of transactions via the engine-api.

To support this we need to make a few changes to geth:

  • extend PayloadAttributes with Transactions, a list of transaction to force include in the block
  • extend PayloadAttributes with NoTxPool, if true no transactions are taken out of the tx-pool, only transactions from the above Transactions list will be included. to validate existing blocks we will exclude transactions from the mempool, to sequence new blocks we will include transactions from the mempool.
  • allow proposers to reorg their own chain

Specular changes differ from optimism/superchain engine-api spec, because we don't use deposit/system transactions:

https://op-geth.optimism.io/

https://github.com/ethereum-optimism/optimism/blob/develop/specs/exec-engine.md#engine-api

@MoonShiesty MoonShiesty force-pushed the engine-api branch 3 times, most recently from d5ae9f3 to eaf968a Compare September 29, 2023 22:36
@MoonShiesty MoonShiesty marked this pull request as ready for review September 30, 2023 00:11
@MoonShiesty
Copy link
Author

@ujvl ready for review

I added an L2EngineApi param to the ChainConfig, which enables our L2 engine ap modifications. This change really helped reduce the specular diff.

Right now, L2EngineApi can be enabled/disabled with the genesis.json file. If it makes more sense to use a cli flag, it looks like we need to move this parameter to a different config.

I also cleaned up how we disable the ConsensusAPI heartbeat.

Copy link

@LEAFERx LEAFERx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What does Optimism's RollupComputePendingBlock option mean? Why don't we need it?
  2. Can you explain several inconsistent changes w/ optimism:
    1. missing changes in https://github.com/ethereum-optimism/op-geth/blob/optimism/miner/worker.go#L559
    2. missing changes in https://github.com/ethereum-optimism/op-geth/blob/optimism/miner/worker.go#L1059
  3. The signature of getSealingBlock is different. Is this caused by different geth versions?

Random common.Hash `json:"prevRandao" gencodec:"required"`
SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"`
// <specular modification>
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty" gencodec:"optional"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why it is marked as optional?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have the same q

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added this by mistake, fixed

if err != nil {
return nil, err
}
// Construct a payload object for return.
payload := newPayload(empty, args.Id())
// <specular modification>
if args.NoTxPool { // don't start the background payload updating job if there is no tx pool to pull from
return payload, nil
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

miner/worker.go Outdated
header.Extra = w.extra
}
// <specular modification>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing /

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

params/config.go Outdated
@@ -304,6 +304,9 @@ type ChainConfig struct {
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
IsDevMode bool `json:"isDev,omitempty"`
// <specular modification>
L2EngineApi bool `json:"l2EngineApi,omitempty"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit rename to

Suggested change
L2EngineApi bool `json:"l2EngineApi,omitempty"`
EnableL2EngineAPI bool `json:"l2EngineApi,omitempty"`

@@ -468,7 +470,9 @@ func testGetSealingWork(t *testing.T, chainConfig *params.ChainConfig, engine co
// This API should work even when the automatic sealing is enabled
w.start()
for _, c := range cases {
block, _, err := w.getSealingBlock(c.parent, timestamp, c.coinbase, c.random, nil, false)
// <specular modification>
block, _, err := w.getSealingBlock(c.parent, timestamp, c.coinbase, c.random, nil, false, nil, nil)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be misreading but is this setting a bool to nil (2nd to last param)

Copy link
Author

@MoonShiesty MoonShiesty Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was actually passing an extra param. I did run make test to confirm all the tests pass but it must not have built this file. I'll look into how to actually build and run this test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we update to the latest geth, the new getSealingBlock api means we can eliminate the specular diff in this file.

Random common.Hash `json:"prevRandao" gencodec:"required"`
SuggestedFeeRecipient common.Address `json:"suggestedFeeRecipient" gencodec:"required"`
// <specular modification>
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty" gencodec:"optional"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have the same q

@MoonShiesty MoonShiesty changed the title [draft] engine-api support engine-api support Oct 2, 2023
@MoonShiesty
Copy link
Author

  1. What does Optimism's RollupComputePendingBlock option mean? Why don't we need it?

  2. Can you explain several inconsistent changes w/ optimism:

    1. missing changes in https://github.com/ethereum-optimism/op-geth/blob/optimism/miner/worker.go#L559
    2. missing changes in https://github.com/ethereum-optimism/op-geth/blob/optimism/miner/worker.go#L1059
  3. The signature of getSealingBlock is different. Is this caused by different geth versions?

  1. RollupComputePendingBlock determines whether the miner computes a pending block: i.e. whether eth.getBlock('pending') returns the 'latest' block or a 'pending' block using the mempool. This shouldn't affect the engine-api payload/engine_forkchoiceUpdatedV1 changes in the PR.

  2. https://github.com/ethereum-optimism/op-geth/blob/optimism/miner/worker.go#L559 I didn't implement RollupComputePendingBlock in this PR.
    https://github.com/ethereum-optimism/op-geth/blob/optimism/miner/worker.go#L1059
    Optimism passes a GasLimit as a part of the engine-api payload, I didn't implement the GasLimit parameter or make any changes to calculating a block's GasLimit as part of this PR.

  3. op-geth updated to a later version of geth since I opened this PR. it might be easier to review these changes if I update to the latest geth.

EnableL2EngineApiFlag = &cli.BoolFlag{
Name: "enableL2EngineApi",
Usage: "Enable L2 Engine API",
Category: flags.EthCategory,
Copy link
Author

@MoonShiesty MoonShiesty Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't sure if this should go in the miner catagory instead

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eth is good for now

@MoonShiesty MoonShiesty force-pushed the engine-api branch 2 times, most recently from 5d76f54 to 8e35e3a Compare October 4, 2023 18:44
@MoonShiesty MoonShiesty force-pushed the engine-api branch 4 times, most recently from 8e35e3a to ebc427e Compare October 9, 2023 16:33
@MoonShiesty MoonShiesty changed the base branch from specular to rebase-geth-1.13.2 October 9, 2023 19:57
@MoonShiesty MoonShiesty merged this pull request into fabriqnetwork:rebase-geth-1.13.2 Oct 10, 2023
@MoonShiesty MoonShiesty deleted the engine-api branch October 10, 2023 20:22
@MoonShiesty MoonShiesty restored the engine-api branch October 10, 2023 20:24
@MoonShiesty MoonShiesty mentioned this pull request Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants