Skip to content
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

sfcodes harmonization for hooks #4089

Closed
wants to merge 1 commit into from

Conversation

RichardAH
Copy link
Collaborator

High Level Overview of Change

Hooks and XLS20 both require new serialised field codes in rippled. These codes are currently in conflict.
Hooks has previously had a conflict with Tickets which has caused considerable confusion.

Our ecosystem does not currently have a system for assigning codes to new amendments. This needs to be addressed.

Allowing conflicts to continue is detrimental to third party tools, applications and wallets which need to serialise and deserialise rippled's data in order to function. These include but are not limited to the ripple-binary-codec and binary visualizer tool.

This PR is an attempt to resolve the current sfcode conflicts between XLS20 and Hooks. Other pending amendments are not included.

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates
  • Release

@WietseWind
Copy link
Member

@nbougalis Hi Nik, can you + team take a good look at this and consider merging? I think we can all agree Hooks are something we do not want to rush, but is definitely something serious enough to reserve codes. We want to prevent conflicts like happened with Tickets.

@RichardAH RichardAH force-pushed the sfcode_harmonization branch 2 times, most recently from dcde02b to 3c8163f Compare February 1, 2022 11:09
RichardAH added a commit to RichardAH/xrpl-binary-visualizer that referenced this pull request Feb 1, 2022
RichardAH added a commit to RichardAH/xrpl.js that referenced this pull request Feb 1, 2022
RichardAH added a commit to RichardAH/xrpl.js that referenced this pull request Feb 1, 2022
@nbougalis
Copy link
Contributor

@scottschurr and I will review with a goal of getting this into a 1.9.0-b1; we will rebase #4101 on top of this.

@WietseWind
Copy link
Member

@scottschurr and I will review with a goal of getting this into a 1.9.0-b1; we will rebase #4101 on top of this.

Appreciate it. A lot :)

RichardAH added a commit to XRPL-Labs/xrpld-hooks that referenced this pull request Feb 18, 2022
@RichardAH
Copy link
Collaborator Author

See above referenced commit for just how annoying it can be to have your sfcodes clobbered. Reiterating that we need a better system going forward if multiple people are going to work simultaneously on amendments that change or add sfFields.

@scottschurr
Copy link
Collaborator

@RichardAH, I respect the pain you have felt as new serialization types are added to the system while you're maintaining code. I think reserving the codes that Hooks needs is a good idea.

I have two concerns with this commit as it currently stands:

  1. Visibility of field usage, and
  2. Order of operations.

Visibility of Field Usage

Hooks adds quite a number of serialized fields, and that's fine. What's not so good is that we don't see these serialized fields being used anywhere in the code base as it stands. I get why that is. But it's not uncommon for me to look in the SFields.cpp file and wonder, "Hmmm, who is using that field?" With the newly added Hooks fields if I look in the code base my answer will be nobody. But that's not actually the case. They are used, by Hooks, but I can't see that usage.

Additionally I am of the opinion that if something is not tested then it often doesn't work as expected. This commit adds Hooks fields, but does not exercise them in any way. That's probably okay? But it leaves me uneasy.

I'd like to suggest that, in addition to adding the Hooks-specific SFields, you add a Hooks stub unit test file. It doesn't need to do anything other than:

  1. Include a paragraph comment at the top saying what it represents: These are tests that exercise facilities that are reserved for when Hooks is merged in the future.

  2. Do some minimal exercising of all the newly added fields. That way if someone looks for where the fields are used they will be led to this hooks-related test file.

This solves both problems. It identifies the facility that will eventually use these fields. It also does some minimal exercising of the newly added fields.

Does that seem like a reasonable request? I'm open to other suggestions if you see other ways to address my concerns,

Order of Operations

As software engineers, we all respect that order of operations matters a lot. This pull request, as it is currently coded, would sit nicely atop the XLS20 pull request once that is merged to develop. However @nbougalis suggests that we should add this commit before XLS20 is merged. If we take that approach, then I'm uncomfortable with the pull request as it stands.

If this commit is added before XLS20 is merged, then the pull request presciently adds fields that aren't needed until XLS20 puts them to use. In effect, if this commit is merged before XLS20 is merged, then I'd like this commit to be a Hooks Only commit. Let's remove from this commit the fields that XLS20 will introduce. I'll deal with that problem when I do the rebase of XLS20 to sit atop the 1.9.0 commits.

Summary

In summary, assuming we put this commit in before XLS20 is merged, I'd like to see:

  1. Adding a test stub file that exercises the features/fields that are being added in anticipation of hooks being merged.
  2. Removing the XLS20 fields from the pull request. We'll deal with adding the XLS20 fields when that rebase happens.

Would it actually be easier for you if we merge this commit after XLS20 is merged? I'm not intending to make extra work for you (other than adding the unit tests). Thoughts? Thanks.

src/ripple/protocol/impl/SField.cpp Outdated Show resolved Hide resolved
src/ripple/protocol/SField.h Outdated Show resolved Hide resolved
@RichardAH RichardAH force-pushed the sfcode_harmonization branch from 3c8163f to bf791bc Compare March 10, 2022 12:31
@RichardAH RichardAH changed the title sfcodes harmonization for xls20 and hooks sfcodes harmonization for hooks Mar 10, 2022
@RichardAH
Copy link
Collaborator Author

I have made the changes you have requested.

Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making these changes. I think they will help with the maintenance of the code base, particularly when we look back through history.

I've left a few comments, none of which are critical. So I'm approving this pull request as it stands. But it would be nice to see the comments addressed. So I'm supplying a commit that you may use as an example of how the comments might be addressed. Or, if you prefer, you could simply cherry-pick the commit on top of your changes. You'll find the commit here: scottschurr@94f62f0

Many thanks for your on-going contributions to the XRP Ledger.

@@ -891,6 +891,7 @@ if (tests)
src/test/protocol/InnerObjectFormats_test.cpp
src/test/protocol/Issue_test.cpp
src/test/protocol/KnownFormatToGRPC_test.cpp
src/test/protocol/Hooks_test.cpp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not critical, it would be nice if this in alphabetical order like the other entries.

extern SF_UINT64 const sfHookOn;
extern SF_UINT64 const sfHookInstructionCount;
extern SF_UINT64 const sfEmitBurden;
extern SF_UINT64 const sfHookReturnCode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a distinction between the common and uncommon SFields. The common ones have a slightly more efficient encoding. I had thought that we were pretty consistent about calling out which are which in this file. But on closer inspection I see that we've not been consistent.

It would be nice to add those comments into this file in those places where they are missing. But, again, that's not critical.

Comment on lines 146 to +147
CONSTRUCT_TYPED_SFIELD(sfTicketSequence, "TicketSequence", UINT32, 41);
CONSTRUCT_TYPED_SFIELD(sfHookStateCount, "HookStateCount", UINT32, 45);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a number of places where this commit introduces gaps in the integer codes for SFields, like this jump from 41 to 45. I get where that's coming from. I also know that closing those gaps would be disruptive to maintenance of the hooks branch.

It might be nice to call out the newly introduced gaps with comments so future pull requests (like support for XLS20) can more easily fill in those gaps.

**/

void
testHookFields()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this unit test. I think it will help with future maintenance.

@manojsdoshi manojsdoshi mentioned this pull request Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants