lf-lang / lingua-franca

Intuitive concurrent programming in any language
https://www.lf-lang.org
Other
220 stars 57 forks source link

Authentication inheritance consistency when importing a reactor in a federated execution #2326

Open ChadliaJerad opened 1 week ago

ChadliaJerad commented 1 week ago

In a federated program that does not enable authentication (using auth C target property), importing a reactor from a file where authentication is required will cause the program to fail.

To reproduce, consider the following 2 lf programs: R1.lf:

target C {
  auth: true
}
reactor R1 {
  input in: int
  reaction(in) {=
    lf_print("R1 reacted to input %d", in->value);
  =}
}

And IssueAuth.lf:

target C
import R1 from "R1.lf"
reactor R0 {
  output out: int
  state s: int = 0
  timer t(0, 100 ms)
  reaction(t) -> out {=
    self->s ++ ;
    lf_set(out, self->s);
    lf_print("R0 is sending %d.", self->s);
  =}
}

federated reactor {
  r1 = new R1()
  r0 = new R0()
  r0.out -> r1.in
}

Executing IssueAuth says:

DEBUG: RTI sending MSG_TYPE_REJECT.
ERROR: RTI expected a MSG_TYPE_FED_IDS message. Got 100 (see net_common.h).
Fed 0 (r1): WARNING: Failed to read RTI response.
Fed 0 (r1): Trying RTI again on port 15046.
Fed 0 (r1): Trying RTI again on port 15047.
Fed 0 (r1): Trying RTI again on port 15048.
Fed 0 (r1): Trying RTI again on port 15049.
...

The reason is that r1 wants to proceed with authentication (Message id 100), while the RTI is not expecting such a message, but rather the neighborhood structure.

edwardalee commented 1 week ago

It seems to me correct for this to fail, though I suppose it could generate a better error message.