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

Implement a hard fork to normalize claim names #159

Closed
wants to merge 11 commits into from

Conversation

lbrynaut
Copy link
Contributor

@lbrynaut lbrynaut commented Jun 12, 2018

This is a complete re-write of #102 and replaces it since it's much more complete and handles situations that the other does not handle.

This PR contains a lot of changes and I expect a detailed review will take some time to ensure correctness. I also expect the reproducible_build script will need further modification (likely won't work as-is again due to the added ICU dependency).

@kaykurokawa The "claimtriebranching_hardfork_disktest" unit test does not seem to work with this PR, if you have a second to see what's going on there, it would help. It came up after things were working and then I rebased to latest, so it's commented out for now.

EDIT: @kaykurokawa This last comment is no longer true, so can be ignored now.

@lbrynaut lbrynaut force-pushed the normalization-rewrite branch 2 times, most recently from 8a3c999 to 5b6dfe0 Compare June 12, 2018 15:28
@lbrynaut lbrynaut force-pushed the normalization-rewrite branch 5 times, most recently from 2a7ba31 to 41921dd Compare June 21, 2018 01:19
@lbrynaut lbrynaut mentioned this pull request Jun 26, 2018
@lbrynaut
Copy link
Contributor Author

lbrynaut commented Jun 26, 2018

Addresses #65

WIP regarding travis/dependency addition.

Updated.

@lbrynaut lbrynaut force-pushed the normalization-rewrite branch 18 times, most recently from 1f8358c to f32b48d Compare June 28, 2018 00:34
@lbryio lbryio deleted a comment from bvbfan Oct 22, 2018
@lbryio lbryio deleted a comment from bvbfan Oct 22, 2018
@BrannonKing
Copy link
Member

@bvbfan , excellent analysis. With our work on #44 it appears that we achieved independence from methods taking a name in rpc/claimtrie.cpp. I think that is critical to your suggestion that we don't do string normalization in the CClaimTrie (instead, we do it all in the "cache"). I really like the suggestion! I think that puts a high priority on getting #44 merged and rebasing our normalization on top of that.

return removeClaim(newName, outPoint, nHeight, throwaway, false);
}

bool CClaimTrieCache::spendClaim(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight) const
bool CClaimTrieCache::spendClaim(std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight) const
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see a reason to make param in/out.

Copy link
Member

@BrannonKing BrannonKing Oct 30, 2018

Choose a reason for hiding this comment

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

The out parameter is used in mining.cpp and main.cpp (to avoid duplicate work on that name). Out parameter usage is not very obvious, though. I'm open to other suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, i see now. The right approach, to me, is to call normalize before spend, we can prevent double work if we have function like isNormlized before real normalization. But i don't think double call will slow down significantly.

lbrynaut and others added 6 commits November 2, 2018 14:32
Apply (self) review feedback
Clean deps required for boost to rebuild with icu support (for now)
Normalization bug fixes and improvements
Clang-formatting
where normalization is enabled and the claim no longer exists (due to
normalization related narrowing)
also includes code to validate incoming utf8
also fixed a few post-merge issues
also rearranged unit test code to avoid some spurious errors
reproducible_build.sh Outdated Show resolved Hide resolved
@@ -2819,3 +2859,49 @@ bool CClaimTrieCache::forkForExpirationChange(bool increment) const
return true;
}

bool CClaimTrieCache::shouldNormalize() const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Function opening brace goes to the new line, that's tidy expectation.

Copy link
Member

Choose a reason for hiding this comment

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

I haven't ran the formatter on this yet. I assume that would pick this up?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it will.

return nCurrentHeight > Params().GetConsensus().nNormalizedNameForkHeight;
}

std::string CClaimTrieCache::normalizeClaimName(const std::string& name, bool force) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Opening brace on new line.

@BrannonKing
Copy link
Member

BrannonKing commented Nov 8, 2018

I did finally get a green on the Linux compilation again. Some notes on my issues with the reproducible_build.sh:

  1. The ICU_PREFIX was being exported to the child makefiles but wasn't always set to a real value when relying on pkg-config. This was causing issues. I changed the child makefiles to rely wholly upon ICU_LIBS and ICU_CPPFLAGS, which should be always set.
  2. I could not get ICU v55 to compile statically. I upped it to v57. Our current version of Boost (v59) would not compile with newer versions of ICU.
  3. The script sets "-e", or maybe it's "-u", which makes it exit whenever any command returns nonzero. It also sets pipeline, which makes it keep the worst result from any method. The flag handling in the wait method was always returning 1 on my machine, causing the whole script to exit. I ditched the flag usage there in favor of a sub-terminal.
  4. The parameters for the boost b2 command weren't getting grouped appropriately. I put in quotes. This made it so that I could not make that call from the "background" function. I'm hoping someone else has a solution for that. The background function seems to run it fine, it just doesn't find the ICU deps when called from there. I could not figure that out. I did add a grep check to ensure that the ICU deps are found.
  5. Because I'm now compiling Boost without the background minute message, TravisCI times out at 10 minutes when compiling Boost afresh. I don't have a solution for this yet. It wants output every 10 minutes. It's ridiculous that the timeout is not configurable. Instead, we push the output to a log file for each dependency build. I'm not sure that's actually a desirable feature. The other side affect of that is how we hide any error reported by our script with a postdump of 200 or 1000 lines of the log file.
  6. The TravisCI caching keeps the build folder around. Our script was checking to see if the dependency's parent folder existed there. If it did exist, it would not run make on that dependency. Hence, if you fail on a dependency it won't get rebuilt because of the TravisCI cache. Not only that, but build/boost was always there -- even if I deleted the cached file from TravisCI. I had to change the script to always build dependencies, which is fast for all except openssl who thinks it's cool to rewrite a whole bunch of source code files with every configure call.
  7. The OSX build now fails with this error: "Too many levels of symbolic links" while compiling openssl a second time. I don't have a solution for that yet.
  8. Statically linking in ICU requires fPIC. I had to add that to the build of ICU.
  9. The "clone" flag that didn't do anything is now gone.
  10. The reproducible_build originally used pkg-config to find ICU, but it would possibly return a system installation. It's now hard-coded to the one pulled by the script.

The advantage of Docker is that you don't have to recompile the dependencies every time. We can stop wasting time on that. I feel strongly like we need to move that direction.

@BrannonKing
Copy link
Member

#235 supersedes this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants