-
Notifications
You must be signed in to change notification settings - Fork 487
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
stylus: add compilation target config, support multiple targets in wasm store #2463
Merged
Merged
Changes from all commits
Commits
Show all changes
103 commits
Select commit
Hold shift + click to select a range
564cb56
stylus: internally split compile from activate
tsahee a9c6275
update stylus function documentation
tsahee 4f52b17
stylus: introduce target_cache
tsahee 9e99245
use explicit targets and target cache
tsahee db42497
stylus compile: support non-native archs and dont panic
tsahee 035fddb
programs: add testCompileArch
tsahee 89bcd07
arbos/programs: improve code in activation
tsahee da57334
clippy
tsahee 07aebbf
testCompileArch: add load/store
tsahee b4f1c0a
fix dir permissions
tsahee e78c7b9
TesstCompileArch: add documentation
tsahee 8316508
fix arbitrator tests
tsahee a1d56a0
Merge branch 'master' into stylus_target
tsahee 9beb476
add stylus target config
magicxyyz d825279
set stylus target
magicxyyz fe2e0dc
map from target to asm
magicxyyz 35b1bd1
update geth
magicxyyz 1f3d3cb
Merge branch 'master' into stylus_target_wasm_store
magicxyyz 782366d
update geth
magicxyyz 63f03c9
Merge branch 'master' into stylus_target_wasm_store
magicxyyz 047d961
update geth pin
magicxyyz b1595d1
Merge branch 'master' into stylus_target_wasm_store
magicxyyz c061a91
Merge branch 'master' into stylus_target
magicxyyz 42faab8
Merge branch 'stylus_target' into stylus_target_wasm_store
magicxyyz c482a2a
remove leftover code from activateProgramInternal
magicxyyz 2785dfd
add wasm schema version check in init
magicxyyz 3ee75e4
fix databaseIsEmpty check
magicxyyz 5cf23fa
remove outdated comment
magicxyyz a6167df
log error when stylus_target_set fails
magicxyyz dba4f71
Merge branch 'master' into stylus_target
magicxyyz d9a420c
store wavm in the same map as native asms
magicxyyz 53b04b8
Merge branch 'stylus_target' into stylus_target_wasm_store
magicxyyz 1f44f5e
use rawdb.TargetWavm const, instead of GOARCH return LocalTargetName(…
magicxyyz 35dc700
fix supported arch check in validationEntry.ToInput
magicxyyz d6a0579
remove outdated todo comment
magicxyyz 5f776d9
remove unused struct
magicxyyz efe2b0d
Merge branch 'master' into stylus_target
magicxyyz d0f4ffb
Merge branch 'stylus_target' into stylus_target_wasm_store
magicxyyz db04fa7
fix getting wasm for local target in JitMachine.prove
magicxyyz ae5f159
record program for Wavm and local target
magicxyyz af31233
update geth
magicxyyz c3ef68b
rename wasm store schema version validation helper
magicxyyz b6c87ce
Merge branch 'master' into stylus_target
magicxyyz 2477cbe
Merge branch 'stylus_target' into stylus_target_wasm_store
magicxyyz f344e55
Merge branch 'master' into stylus_target_wasm_store
magicxyyz 1e07092
fix merge: remove DangerousConfig
magicxyyz c418f31
set DefaultStylusTargetConfig.Host to empty str
magicxyyz 631a23f
specify linux OS in stylus target config description
magicxyyz 3d0680e
add back the blank line after StylusTarget
magicxyyz e8a473d
make sure all requested stylusArchs are included in ValidationInput
magicxyyz 4f93172
use rawdb.TargetWavm constant instead of explicit string
magicxyyz cfaee08
fix typo in triple_string
magicxyyz 3c0172c
move default target description constants to programs, use them in te…
magicxyyz a7498c0
match GOARCH target naming, update geth pin
magicxyyz 00704f2
target_from_string: return default target for empty string
magicxyyz bf21950
remove repetition in target option description
magicxyyz d304823
simplify not supported stylusArch error message
magicxyyz 2d3563d
error only when WasmStoreSchemaVersion is greater then current version
magicxyyz 90358f2
update geth pin
magicxyyz 9a9b902
Merge branch 'master' into stylus_target_wasm_store
magicxyyz f5536f5
update unsupported wasm schema version error message
magicxyyz 3581af3
use rawdb.Target type
magicxyyz 2c86f27
use rawdb.TargetFromString / rawdb.Target.ToString for encoding/decod…
magicxyyz 048ae8d
change stylusArch validation
magicxyyz 883d034
use rawdb.Target.ToString in programs.SetTarget
magicxyyz 3fdc02c
update geth pin, remove rawdb.TargetFromString and rawdb.Target.ToString
magicxyyz c3502b2
handle error returned from rawdb.ReadWasmSchemaVersion
magicxyyz 49cc293
update geth pin
magicxyyz 9aef946
Merge branch 'master' into stylus_target_wasm_store
magicxyyz f84bf13
remove old wasm store entires if version 0 is detected
magicxyyz 02f1e86
add error check in TestPurgeVersion0WasmStoreEntries
magicxyyz 56544dc
update geth pin
magicxyyz 1fa3e7d
Merge branch 'master' into stylus_target_wasm_store
magicxyyz dbf169d
Merge branch 'master' into stylus_target_wasm_store
magicxyyz d1caccc
Merge branch 'master' into stylus_target_wasm_store
magicxyyz f0dcbe3
Merge branch 'master' into stylus_target_wasm_store
magicxyyz b5020a1
Merge branch 'master' into stylus_target_wasm_store
magicxyyz 4a6ef04
use dbutil.IsErrNotFound when handling ReadWasmSchemaVersion error
magicxyyz 4039007
release iterator before writing batch in purgeVersion0WasmStoreEntries
magicxyyz 1ec6cbd
check both wavm and local asms existence when rebuilding wasm store
magicxyyz ac25502
log only once when key with deprecated prefix with unexpected length …
magicxyyz 5a30b97
Revert "release iterator before writing batch in purgeVersion0WasmSto…
magicxyyz 1245d4a
test if target name is utf8 in stylus_compile
magicxyyz f0c1cf8
use InitCache::target() when deserializing in exec_wasm
magicxyyz eb17f05
don't error pre-stylus in ValidationClient.Start
magicxyyz 30060be
return empty stylusArchs for clients that does not support stylus
magicxyyz e67ae22
Revert "use InitCache::target() when deserializing in exec_wasm"
magicxyyz 7e07261
move LocalTarget() to rawdb
magicxyyz 0f8c07f
validationClient: fail if trying to validate stylus-block on non-stylus
tsahee a24315c
target_cache: move native target inside target_cache
tsahee b49a63c
clippy fix
tsahee fba31fd
compilation fix
tsahee 96fafab
use renamed DeprecatedPrefixesV0
magicxyyz f3f2d75
update geth pin
magicxyyz 57adb9d
rustfmt arbitrator/stylus/src/test/api.rs
magicxyyz 1543e98
add comment to target_cache_set
magicxyyz 1aca285
Merge branch 'master' into stylus_target_wasm_store
PlasmaPower b9c3548
remove wasmer-go, use stylus lib for wat2wasm
tsahee 0479150
wat_to_wasm clippy
tsahee 0e1b98c
cargo fmt
tsahee 3beb808
Merge remote-tracking branch 'origin/master' into stylus_target_wasm_…
tsahee eb690ee
fix merge conflict
tsahee 10516f5
Merge branch 'master' into stylus_target_wasm_store
PlasmaPower File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Copyright 2022-2024, Offchain Labs, Inc. | ||
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE | ||
|
||
use eyre::{eyre, OptionExt, Result}; | ||
use lazy_static::lazy_static; | ||
use parking_lot::RwLock; | ||
use std::{collections::HashMap, str::FromStr}; | ||
use wasmer_types::{CpuFeature, Target, Triple}; | ||
|
||
lazy_static! { | ||
static ref TARGET_CACHE: RwLock<HashMap<String, Target>> = RwLock::new(HashMap::new()); | ||
static ref TARGET_NATIVE: RwLock<Target> = RwLock::new(Target::default()); | ||
} | ||
|
||
fn target_from_string(input: String) -> Result<Target> { | ||
if input.is_empty() { | ||
return Ok(Target::default()); | ||
} | ||
let mut parts = input.split('+'); | ||
|
||
let Some(triple_string) = parts.next() else { | ||
return Err(eyre!("no architecture")); | ||
}; | ||
|
||
let triple = match Triple::from_str(triple_string) { | ||
Ok(val) => val, | ||
Err(e) => return Err(eyre!(e)), | ||
}; | ||
|
||
let mut features = CpuFeature::set(); | ||
for flag in parts { | ||
features.insert(CpuFeature::from_str(flag)?); | ||
} | ||
|
||
Ok(Target::new(triple, features)) | ||
} | ||
|
||
/// Populates `TARGET_CACHE` inserting target specified by `description` under `name` key. | ||
/// Additionally, if `native` is set it sets `TARGET_NATIVE` to the specified target. | ||
pub fn target_cache_set(name: String, description: String, native: bool) -> Result<()> { | ||
let target = target_from_string(description)?; | ||
|
||
if native { | ||
if !target.is_native() { | ||
return Err(eyre!("arch not native")); | ||
} | ||
let flags_not_supported = Target::default() | ||
.cpu_features() | ||
.complement() | ||
.intersection(*target.cpu_features()); | ||
if !flags_not_supported.is_empty() { | ||
let mut err_message = String::new(); | ||
err_message.push_str("cpu flags not supported on local cpu for: "); | ||
for item in flags_not_supported.iter() { | ||
err_message.push('+'); | ||
err_message.push_str(&item.to_string()); | ||
} | ||
return Err(eyre!(err_message)); | ||
} | ||
*TARGET_NATIVE.write() = target.clone(); | ||
} | ||
|
||
TARGET_CACHE.write().insert(name, target); | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn target_native() -> Target { | ||
TARGET_NATIVE.read().clone() | ||
} | ||
|
||
pub fn target_cache_get(name: &str) -> Result<Target> { | ||
if name.is_empty() { | ||
return Ok(TARGET_NATIVE.read().clone()); | ||
} | ||
TARGET_CACHE | ||
.read() | ||
.get(name) | ||
.cloned() | ||
.ok_or_eyre("arch not set") | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still add a comment to
target_cache_set
explaining everything this function does, because it kind of does two things in one. It both populates TARGET_CACHE, but if native is set, it also populates TARGET_NATIVE which isn't really a cache or related to TARGET_CACHE.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a following comment:
Let me know if that's good / precise enough :)