soroban-cli icon indicating copy to clipboard operation
soroban-cli copied to clipboard

Add testing of protocol features to CI

Open ifropc opened this issue 9 months ago • 2 comments

What problem does your feature solve?

We currently don't test protocol features (version_ge_23) in CI

What would you like to see?

Adding tests to CI

What alternatives are there?

Alternatively, we could use a separate branch for future releases. In this case we wouldn't need to maintain protocol features

ifropc avatar Feb 22 '25 03:02 ifropc

💯

leighmcculloch avatar Feb 22 '25 10:02 leighmcculloch

A bit more on this issue: Currently, we don't have any tests in place for version_ge_23 and the way I see it we either need to add support for testing protocol features, or remove features support and use branches instead.

Both approaches have pros and cons, and the way I see it is the following:

Protocol features pros:

  • Extensible to other features we may bring to our codebase in the future
  • Single branch resulting in no unexpected merge conflicts long term
  • Every change is automatically tested against p22 and p23 (once we have necessary pipelines in place)

Protocol features cons:

  • Reduced code readability (I think code is less readable with introduction of features, see sample in #1887 )
  • Longer testing time -- on each PR we need to test both p22 and p23 changes
  • More bug prone IMO (due to protocol number branching rules)

Branch pros:

  • Easier to read the code + code separation
  • Follows git workflow

Branch cons:

  • Potential big merge conflicts
  • Need to frequently forward changes from main into develop/p23
  • Changes merged into main branch are not tested on p23 until PR from main -> develop/p23

I personally think that protocol features bring quite a bit complexity to the project (mainly, because it's harder to follow the logic in the code, but maybe we adopt some kind of simple rules, e.g. styling code as following):

// Main function doesn't contain branching logic makes it easier to follow
fn some_func() {
 ...
 do_stuff(params);
 ...
}

// Function with just branching logic
fn do_stuff(params) {
  #[cfg(feature = "version_lt_23")]
  do_stuff_p22(params);
  #[cfg(feature = "version_gte_23")]
  do_stuff_p23(params);
}

// Functions that performs the task, only for one protocol version
#[cfg(feature = "version_lt_23")]
fn do_stuff_p22(params) {
   ...
}

do_stuff_p23(params) {
   ...
}

Any suggestions are welcome

ifropc avatar Feb 25 '25 00:02 ifropc