Spawn-Exec composition

Hey all, I have a puzzling question for Nervos L1 brainiacs :brain:

Assumptions

Let’s assume that:

  1. There are three distinct L1 scripts: A, B and C
  2. B is referenced by type
  3. Initially A -spawn-> B (and B does not exec anything else)
  4. At a second time, B binary is updated to B -exec-> C
  5. Now A -spawn-> B -exec-> C

Violated Expectations

A was implemented without the knowledge that B would exec something else, so A expects that:

  1. A spawns B.
  2. A reads B computation result.
  3. A proceeds with its own validation.
  4. A returns its validation result.

On the other side, once B is updated to include an exec call, A assumptions fails apart as its validation goes like this:

  1. A spawns B.
  2. B exec C.
  3. Execution context is cleared due to Exec.
  4. C proceeds with its own validation.
  5. C returns validation result.

This poses an issue for A did not complete its own validation.

Questions

  1. Is the current behavior described correctly?
  2. Does spawn implementation prescribe any way to fail the validation if a spawned process tries to exec?
  3. Would it make sense to fail by default if a spawned process tries to exec?

Love & Peace, Phroi %42

1 Like

There is one miscommunication here: when A spawns B, there will be 2 VM instances created, one for A, and one for B.

When B runs exec syscall, B becomes C, there are still 2 VM instances: one for A, and one for C. The exec syscall does not affect A at all.

When C terminates, A reads the computation result returned by C, now A can continue with its validation.

2 Likes

Perfect, it makes more sense now, thank you!!

Phroi