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

replace MessageRunMode with a struct #373

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

magicxyyz
Copy link
Contributor

@magicxyyz magicxyyz commented Nov 8, 2024

This PR:

  • replaces MessageRunMode enum with MessageRunContext struct, that apart from run mode now contains wasm cache tag and wasm targets list
  • Refactors passing of wasm targets and wasm cache tag, so they are no longer wired through cachingDB and ethdb.Database

Resolves NIT-2827

@cla-bot cla-bot bot added the s CLA signed label Nov 8, 2024
@@ -213,7 +213,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
rejectedTxs = append(rejectedTxs, &rejectedTx{i, errMsg})
continue
}
msg, err := core.TransactionToMessage(tx, signer, pre.Env.BaseFee, core.MessageCommitMode)
msg, err := core.TransactionToMessage(tx, signer, pre.Env.BaseFee, core.NewMessageCommitContext(nil)) // TODO: do we need to specify wasm targets here if chainConfig.IsArbitrum == false?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we need to specify wasm targets here if chainConfig.IsArbitrum == false?

Copy link
Contributor

Choose a reason for hiding this comment

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

per other comments, I think we should allow init with nil to mean localTarget
Also, if stylus isn't active, it should't be a problem to really have nil there

@magicxyyz magicxyyz marked this pull request as ready for review November 15, 2024 15:05
@@ -1167,19 +1167,19 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
}

// Arbitrum: a tx can schedule another (see retryables)
result, err = runScheduledTxes(ctx, b, state, header, blockCtx, core.MessageGasEstimationMode, result)
result, err = runScheduledTxes(ctx, b, state, header, blockCtx, core.NewMessageGasEstimationContext(), result) // TODO: why do we use GasEstimationMode here?
Copy link
Contributor

Choose a reason for hiding this comment

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

flagging this TODO question

Copy link
Contributor

Choose a reason for hiding this comment

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

@PlasmaPower it seems that here we set it to GasEstimationMode because in the function runScheduledTxes (just below this one) we only run scheduled Txes for gas estimation mode.. but I don't understand that condition itself (currently, we call runScheduledTxes from two places I found, both set runmode argument to GasEstimation so this condition isn't really doing anything)

wasmTargets []rawdb.WasmTarget
}

func NewMessageCommitContext(wasmTargets []rawdb.WasmTarget) *MessageRunContext {
Copy link
Contributor

Choose a reason for hiding this comment

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

we always need loclaTarget.
Maybe make the argument extraWasmTargets, and then the function adds local if not already in there, and in most invocations you can just pass nil?

Copy link
Contributor

Choose a reason for hiding this comment

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

another option is to special case len(wasmTargets) == 0 and in that case add localTarget

@@ -213,7 +213,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
rejectedTxs = append(rejectedTxs, &rejectedTx{i, errMsg})
continue
}
msg, err := core.TransactionToMessage(tx, signer, pre.Env.BaseFee, core.MessageCommitMode)
msg, err := core.TransactionToMessage(tx, signer, pre.Env.BaseFee, core.NewMessageCommitContext(nil)) // TODO: do we need to specify wasm targets here if chainConfig.IsArbitrum == false?
Copy link
Contributor

Choose a reason for hiding this comment

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

per other comments, I think we should allow init with nil to mean localTarget
Also, if stylus isn't active, it should't be a problem to really have nil there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s CLA signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants