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

On-demand module compile #2739

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

On-demand module compile #2739

wants to merge 15 commits into from

Conversation

magicxyyz
Copy link
Contributor

Resolves NIT-2633

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Oct 15, 2024
@magicxyyz magicxyyz changed the title Ondemand module compile On-demand module compile Oct 15, 2024
@magicxyyz magicxyyz marked this pull request as ready for review October 24, 2024 14:58
@eljobe
Copy link
Member

eljobe commented Oct 25, 2024

I'm afraid I cannot realistically review this with everything going on with BoLD. Sorry. Removing myself as a reviewer for now.

@eljobe eljobe removed their request for review October 25, 2024 12:56
// we know program is activated, so it must be in correct version and not use too much memory
info, asmMap, err := activateProgramInternal(statedb, addressForLogging, codeHash, wasm, pagelimit, program.version, zeroArbosVersion, debugMode, &zeroGas)
moduleActivationMandatory := 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.

we might need to set moduleActivationMandatory here to true and activate the module each time we need to recompile to get the activationInfo (here info) to check info.moduleHash against moduleHash.

alternatively, we can skip the check if info is nil, so we'd have:

if info != nil && info.moduleHash != moduleHash {
	log.Error("failed to reactivate program", "address", addressForLogging, "expected moduleHash", moduleHash, "got", info.moduleHash)
	return nil, fmt.Errorf("failed to reactivate program. address: %v, expected ModuleHash: %v", addressForLogging, moduleHash)
}

Copy link
Contributor Author

@magicxyyz magicxyyz Nov 8, 2024

Choose a reason for hiding this comment

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

there is also a question how it should work in context of the later code:

currentHoursSince := hoursSinceArbitrum(time)
if currentHoursSince > program.activatedAt {
	// stylus program is active on-chain, and was activated in the past
	// so we store it directly to database
	batch := statedb.Database().WasmStore().NewBatch()
	rawdb.WriteActivation(batch, moduleHash, asmMap)
	if err := batch.Write(); err != nil {
		log.Error("failed writing re-activation to state", "address", addressForLogging, "err", err)
	}
} else {
	// program activated recently, possibly in this eth_call
	// store it to statedb. It will be stored to database if statedb is commited
	statedb.ActivateWasm(info.moduleHash, asmMap)
}

can we just use moduleHash instead of info.moduleHash here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants