Skip to content

Commit

Permalink
Merge pull request #1373 from OffchainLabs/host-call-hooks-compat
Browse files Browse the repository at this point in the history
Keep arbitrator host_call_hooks format for backwards compat
  • Loading branch information
rachel-bousfield authored Dec 8, 2022
2 parents 4520bb4 + dd35716 commit 94920fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions arbitrator/prover/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ struct Module {
types: Arc<Vec<FunctionType>>,
internals_offset: u32,
names: Arc<NameCustomSection>,
host_call_hooks: Arc<Vec<(String, String)>>,
host_call_hooks: Arc<Vec<Option<(String, String)>>>,
start_function: Option<u32>,
func_types: Arc<Vec<FunctionType>>,
exports: Arc<HashMap<String, u32>>,
Expand Down Expand Up @@ -321,7 +321,7 @@ impl Module {
}
func_type_idxs.push(ty);
code.push(func);
host_call_hooks.push((import.module.into(), import.name.into()));
host_call_hooks.push(Some((import.module.into(), import.name.into())));
} else {
bail!("Unsupport import kind {:?}", import);
}
Expand Down Expand Up @@ -1445,7 +1445,11 @@ impl Machine {
caller_module,
caller_module_internals,
});
if let Some(hook) = module.host_call_hooks.get(self.pc.func()) {
if let Some(hook) = module
.host_call_hooks
.get(self.pc.func())
.and_then(|h| h.as_ref())
{
if let Err(err) = Self::host_call_hook(
&self.value_stack,
module,
Expand Down
1 change: 1 addition & 0 deletions arbitrator/prover/test-cases/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2229,6 +2229,7 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
Expand Down

0 comments on commit 94920fa

Please sign in to comment.