Skip to content

Conversation

@endersonmaia
Copy link
Contributor

Using the post_start docker compose hook, we can create the snapshot directory and copy the snapshot using the root user and start the container with cartesi unprivileged user.

Requires compose plugin 2.30.0

See: https://docs.docker.com/compose/how-tos/lifecycle/


This pull request includes several updates to the @cartesi/cli package, focusing on improving security and updating dependencies. The most important changes include running the validator container with an unprivileged user and updating the minimum required Docker Compose version.

Security improvements:

Dependency updates:

Documentation:

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: 61ab946

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@endersonmaia endersonmaia requested a review from tuler February 4, 2025 14:15
@endersonmaia endersonmaia self-assigned this Feb 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2025

Coverage Report for ./apps/cli

Status Category Percentage Covered / Total
🔵 Lines 31% 293 / 945
🔵 Statements 31.13% 298 / 957
🔵 Functions 36.95% 51 / 138
🔵 Branches 27.88% 121 / 434
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/cli/src/commands/doctor.ts 0% 0% 0% 0% 6-137
Generated in workflow #268 for commit 61ab946 by the Vitest Coverage Report Action

Using the post_start docker compose hook, we can create the snapshot
directory and copy the snapshot using the root user and start the
container with cartesi unprivileged user.

Requires compose plugin 2.30.0

See: https://docs.docker.com/compose/how-tos/lifecycle/
@endersonmaia endersonmaia force-pushed the feature/run-validator-with-unprivileged-user branch from 49bd116 to 61ab946 Compare February 25, 2025 14:50
- |
mkdir -p "$CARTESI_SNAPSHOT_DIR"
cp --recursive /tmp/snapshot/* "$CARTESI_SNAPSHOT_DIR"
while ! stat "$CARTESI_SNAPSHOT_DIR" &>/dev/null; do
Copy link
Member

Choose a reason for hiding this comment

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

This busy wait and coordination between the command and post_start is not very elegant.
Does it really need to be this way? What if the post_start fails for whatever reason?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add some timeout to ensure it fails.

Does it really need to be this way?

It's my approach to run the validator with an unprivileged user leveraging compose.

There are other approaches, for sure, would have to test some alternatives.

Copy link
Member

Choose a reason for hiding this comment

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

How about we first see how the start + deploy would work. Because it will be different in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, we can put this on-hold

if the rollups-node container image release already has this in-place, this process or preparing a directory should just be unnecessary

@tuler
Copy link
Member

tuler commented Feb 25, 2025

In any case, if we move forward with a system-wide cartesi start we will need to revisit how the node get access to the cartesi machine of a specific project.

@endersonmaia endersonmaia force-pushed the feature/cli-run-v2 branch 2 times, most recently from a82afdd to a7e55c5 Compare February 27, 2025 13:18
@tuler tuler force-pushed the feature/cli-run-v2 branch 5 times, most recently from 39558cf to d496299 Compare March 6, 2025 18:31
@tuler tuler force-pushed the feature/cli-run-v2 branch 5 times, most recently from b999336 to 24ad87e Compare March 17, 2025 14:09
Base automatically changed from feature/cli-run-v2 to prerelease/v2-alpha March 17, 2025 14:23
@tuler
Copy link
Member

tuler commented Mar 17, 2025

Is there still a reason for this PR?

@endersonmaia
Copy link
Contributor Author

Is there still a reason for this PR?

No, since rollups-node doesn't have a container image release anymore.

Se could aim to run all services with unorivileged users, on another 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.

3 participants