Skip to content

Conversation

@kwvg
Copy link
Collaborator

@kwvg kwvg commented Jun 21, 2023

Additional Notes

  • Not everything can be retained on volumes, /gnu/store and /var/guix are pre-populated when extracting the Guix archive, which is done during the image building process.
    • Guix also highly cautions against modifying the contents of the store by any means outside manipulating it through the Guix daemon (see https://guix.gnu.org/en/manual/en/guix.html#The-Store)
    • This is enforced by means of bind-mounting /gnu/store as read-only for anything that isn't the daemon
  • This container also has the Xcode SDK archive hardcoded in (see guix-start) and will need to be updated if the SDK version is updated
  • The container runs as privileged process and all operations are being done as the root user (no unprivileged user exists within the container due to its barebones nature) No longer true, as we're not inheriting the Alpine container. An unprivileged user is used for git-specific operations with a configurable UID/GID pair which should be matched with the host user.
  • This container implicitly trusts https://bordeaux.guix.gnu.org and https://ci.guix.gnu.org (see entrypoint) as it fetches substitutions from it to avoid re-building unpatched/unmodified packages by fetching them from a remote server.
    • This can be disabled at the expense of significantly longer build times (to note, a lot of build outputs are discarded in between instances of this container as not everything is or can be cached, so this is recommended against)

Motivation

@PastaPastaPasta was interested in the possibility of being able to run Guix builds as it is run by CI interactively with the fewest commands possible. Since my personal devenv is entirely defined using Docker, I had some experience with interactive containers.

We initially tried using the Alpine container (and earlier versions of this PR built upon this container) already available in develop but two problems arose:

The context problem still persisted after moving to the Ubuntu-based container (which matches the rest of our CI) but Docker implements something called "additional contexts" that allow you to do things like COPY operations with a different directory as the base.

@kwvg kwvg changed the title contrib: add ability to interactively run guix builds based on Alpine CI image build: add ability to interactively run guix builds based on Alpine CI image Jun 21, 2023
@kwvg kwvg marked this pull request as draft June 21, 2023 07:09
@kwvg
Copy link
Collaborator Author

kwvg commented Jun 25, 2023

I rebased #5426 on top of this PR and it resolved the safe.directory problem (see build for more information)

@PastaPastaPasta
Copy link
Member

Makes me sad this had to get moved over to ubuntu, instead of alpine, but probably fine. Started my build, let's make sure it works, seems good so far

@PastaPastaPasta
Copy link
Member

For some reason my arm dash-qt binary doesn't match... everything else matches

b94461d685321ea0d6add4f2b07ae3e9da434f69ef4f5be66fecce819cb32d86  guix-build-01c022e6e244/distsrc-01c022e6e244-arm-linux-gnueabihf/src/qt/dash-qt

@PastaPastaPasta
Copy link
Member

PastaPastaPasta commented Jun 27, 2023

arm-linux-gnueabihf dash-qt is non-deterministic...

CI had

b94461d685321ea0d6add4f2b07ae3e9da434f69ef4f5be66fecce819cb32d86  guix-build-01c022e6e244/distsrc-01c022e6e244-arm-linux-gnueabihf/src/qt/dash-qt

I have (twice)

ca34664ebdcaec0915dc26900131eb2a1581f3e7fef7e116e7e9cc22bdd40b9c  guix-build-01c022e6e244/distsrc-01c022e6e244-arm-linux-gnueabihf/src/qt/dash-qt

@knst
Copy link
Collaborator

knst commented Jun 27, 2023

I got 2 binaries: b94461d685321ea0d6add4f2b07ae3e9da434f69ef4f5be66fecce819cb32d86 from my build and ca34664ebdcaec0915dc26900131eb2a1581f3e7fef7e116e7e9cc22bdd40b9c from pasta.

There's difference in disassembled code of function double_conversion::FastFixedDtoa(double, int, double_conversion::Vector<char>, int*, int*)

@kittywhiskers need to backport this one: https://github.com/bitcoin/bitcoin/pull/25643/files
Otherwise builds are non-deterministic now. @PastaPastaPasta be informed

note for myself (and for further cases): need to install gcc-arm-none-eabi to make disassembler arm-none-eabi-objdump available under amd64's linux.

@PastaPastaPasta
Copy link
Member

We can probably move forward with this PR then and backport that in the next set of guix backports

Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

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

utACK for squash merge

@UdjinM6 UdjinM6 added this to the 20 milestone Jun 27, 2023
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK

@knst
Copy link
Collaborator

knst commented Jun 27, 2023

I still have couple extra comments that I accidentally put to wrong PR.

  1. can you avoid code duplication between contrib/containers/guix/scripts/guix-check and .github/workflows/guix-build.yml?
  2. instead hard-coded 32 jobs better to get environment variable: -e ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=32' \ by one of the ways: you can use $(nproc --all)" or "$(grep -c ^processor /proc/cpuinfo)" or "$(getconf _NPROCESSORS_ONLN)"

@PastaPastaPasta
Copy link
Member

Good thoughts, but I'm gonna merge this so we can move forward with guix part 3; feel free to do a PR with those changes

@PastaPastaPasta PastaPastaPasta merged commit e1e07c3 into dashpay:develop Jun 27, 2023
@kwvg
Copy link
Collaborator Author

kwvg commented Jun 27, 2023

The reason why we cannot de-duplicate is because both guix-check and guix-build are "run-anywhere" and so they cd to the workspace mount in the script, if not rely on absolute paths altogether. I feel like for an interactive instance which is supposed to be as-few-steps-as-possible (it's why I made those scripts and had a pseudo-motd printed out), we have to account for operator error and think one step ahead.

We could de-duplicate it but that would require the scripts to be modified to be relative, which defeats the point of embedding them into PATH since they won't "run-anywhere", which makes the interactive prompt harder to use.

As for binding ADDITIONAL_GUIX_COMMON_FLAGS, to nproc --all, I'm fine with it.

PastaPastaPasta pushed a commit that referenced this pull request Jun 28, 2023
…#5464)

## Additional Information

* Based on suggestions by @knst made
[here](#5449 (comment))
and
[here](#5426 (comment))
PastaPastaPasta added a commit that referenced this pull request Nov 21, 2025
…in#26257, bump to Python 3.10, mypy 0.981, fix Docker group assignment, minor housekeeping (misc. changes: part 2)

82723dc fix: don't forget to assign user to group if group exists (Kittywhiskers Van Gogh)
066d409 chore: remove outdated `boot2docker` comment (Kittywhiskers Van Gogh)
29e98e3 chore: document `USER_ID` and `GROUP_ID` in `docker-compose.yml` (Kittywhiskers Van Gogh)
6ea897a chore: drop unmaintained Guix container (Kittywhiskers Van Gogh)
6a1786c fix: resolve `test: =: unary operator expected` error (Kittywhiskers Van Gogh)
d6489f0 fix: make copy of `skip` in `GetStackFrames` to avoid clobbering (Kittywhiskers Van Gogh)
4110ff3 lint: mypy 0.981 (Kittywhiskers Van Gogh)
80a44e9 partial bitcoin#26257: python linter flake8 E275 fixup, update dependencies (Kittywhiskers Van Gogh)
7b80dfb merge bitcoin#28347: replace deprecated pkg_resources with importlib.metadata (Kittywhiskers Van Gogh)
04ac20a partial bitcoin#30527: Bump python minimum supported version to 3.10 (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * Dependency for #6988

  * Python 3.9's security support elapsed on 31st Oct '25 ([source](https://endoflife.date/python)), in response to that we are switching over to Python 3.10.
    * Due to [python/mypy#13627](python/mypy#13627) arising as a result of this bump, we also had to upgrade `mypy` to 0.981. Note that this is a divergence from upstream as they opted to upgrade to `mypy` 1.x (see [bitcoin#28009](bitcoin#28009)) but the changes needed to do so are too disruptive given this PR's larger context.

      Future backports should feel free to overwrite the mypy version and realign with upstream.

  * CI identified potential clobbering ([build](https://github.com/kwvg/dash/actions/runs/19434684086/job/55606106842#step:8:1804)) in Windows stacktraces code that started to build after [dash#6966](#6966) (see below). Additionally, C++20 has deprecated certain operators like {in,de}crementation courtesy of [P1152](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1152r3.html), which required additional adaptation.

    <details>

    <summary>Build error:</summary>

    ```
    stacktraces.cpp: In function ‘std::vector<long long unsigned int> GetStackFrames(size_t, size_t, const CONTEXT*)’:
    stacktraces.cpp:167:56: error: variable ‘skip’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
      167 | static __attribute__((noinline)) std::vector<uint64_t> GetStackFrames(size_t skip, size_t max_frames, const CONTEXT* pContext = nullptr)
          |                                                        ^~~~~~~~~~~~~~
    cc1plus: all warnings being treated as errors
    ```

    </details>

  * The `AM_CONDITIONAL` for `CRASH_HOOKS_WRAPPED_CXX_ABI` wasn't evaluated due to missing quotations (see below), this has been resolved.

    <details>

    <summary>Configure:</summary>

    ```
    checking whether the linker accepts -Wl,-export-dynamic... no
    checking whether the linker accepts -rdynamic... yes
    checking whether C++ compiler accepts -gdwarf-4... yes
    checking whether C++ compiler accepts -fno-standalone-debug... yes
    checking whether the linker accepts -Wl,-wrap=__cxa_allocate_exception... no
    ./configure: line 30603: test: =: unary operator expected
    checking for Linux getrandom syscall... no
    checking for getentropy via random.h... yes
    checking for sysctl... yes
    checking for sysctl KERN_ARND... no
    checking for fdatasync... no
    ```

    </details>

  * Currently we offer two containers for Guix builds meant for developers who aren't on Linux, one was introduced by [dash#5285](#5285) (based on [fanquake/core-review](https://github.com/fanquake/core-review)'s container, [source](https://github.com/fanquake/core-review/blob/d8cf188214879ea1b095e2ba34ca5c23dbc3ebd2/guix/imagefile)) and the other introduced by [dash#5449](#5449), the former does not seem to get much use and has been out of sync with its upstream source for a while.

    As the second container is used by some developers and is updated and maintained to fit Dash's specific needs, the first container has been dropped and documentation has been updated to reflect the same.

  * As Docker has matured with the WSL2 backend on Windows and the Apple Virtualization framework on macOS, boot2docker has been deprecated (see [boot2docker/boot2docker#1408](boot2docker/boot2docker#1408)) and the comment referencing it has been dropped.

  * To avoid permissions issues with mounting directories, containers come with `USER_ID` and `GROUP_ID` args ([source](https://github.com/dashpay/dash/blob/23de96916a8b8f97a2c408bb76da1d2149d7227c/contrib/containers/ci/ci-slim.Dockerfile#L123-L131)) that need to be specified at build time if the mount needs different permissions (as is often the case on macOS).

    To make that option more explicitly clear, it has been specified in `docker-compose.yml` with default values filled in.

  * [dash#6929](#6929) introduced a fix to prevent unexpected container build failure due to conflicting groups (most commonly GID 20 that on macOS is `staff` but on Linux is `dialout`) but the fix did _not_ assign the default user to that group, that has been resolved here.

  ## Breaking Changes

  None expected.

  ## Checklist

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK 82723dc ~with one nit~

Tree-SHA512: 0e906d1a7fea9edc52a40a6a6971fa6b2599674e97e99c65a220f99cc44be78f4290be8fb9af7782cac416bcdd2338b7f17a5c50b5fdcf727b1cf84fe44c8686
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