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

Expose class hashing functionality #2505

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Expose class hashing functionality #2505

merged 1 commit into from
Jan 22, 2025

Conversation

t00ts
Copy link
Contributor

@t00ts t00ts commented Jan 21, 2025

This PR exposes the requested class hash functionality in the simplest way possible *

  • Moves the class hashing functionality from starknet-gateway-types to a publicly accessible crate.
  • Adds a CI job to publish dependent crates (crypto, common, serde) and the new class hash crate itself class-hash to crates.io on every pathfinder release.

Closes #2466

* Ideally our common crate should be refactored to expose a more organized API/types with cleaner docs. I attempted this a couple times but our macros make it hard to organize types based on their domain/concerns. It's still a WIP, but didn't want to drag this further, so I'll continue some other time.

@t00ts t00ts requested a review from a team as a code owner January 21, 2025 10:35
@t00ts t00ts force-pushed the t00ts/class-hash-crate branch 2 times, most recently from 2a5841b to e7468b0 Compare January 21, 2025 10:53
@t00ts t00ts force-pushed the t00ts/class-hash-crate branch from e7468b0 to 6068ca2 Compare January 22, 2025 08:38
@t00ts t00ts force-pushed the t00ts/class-hash-crate branch from 6068ca2 to cdc6d15 Compare January 22, 2025 08:46
Copy link
Member

@CHr15F0x CHr15F0x left a comment

Choose a reason for hiding this comment

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

LGTM 👍

I really like the docs 🦾

Comment on lines 24 to 33
VERSION=${{ inputs.version }}
# Update version in each Cargo.toml
for crate in common crypto serde class-hash; do
# Update the package version
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" "crates/$crate/Cargo.toml"
# Also update any internal dependencies to use the same version
sed -i "s/{ path = \"..\/common\" }/{ version = \"$VERSION\" }/" "crates/$crate/Cargo.toml"
sed -i "s/{ path = \"..\/crypto\" }/{ version = \"$VERSION\" }/" "crates/$crate/Cargo.toml"
sed -i "s/{ path = \"..\/serde\" }/{ version = \"$VERSION\" }/" "crates/$crate/Cargo.toml"
done
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is good practice. In general, this would lead to the published versions to be different compared to what we have in git.

Can't we just verify this instead of changing stuff in Cargo.toml files? Although by the time this runs it's already fairly late, we should just make sure that the release action fails completely in case publishing the crates fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracking this in a new issue: #2509

.github/workflows/publish-crates.yml Outdated Show resolved Hide resolved
Comment on lines 67 to 80
# First publish crypto as it has no internal dependencies
publish_with_retry pathfinder-crypto
sleep 30

# Publish common which depends on crypto
publish_with_retry pathfinder-common
sleep 30

# Publish serde which depends on common and crypto
publish_with_retry pathfinder-serde
sleep 30

# Finally publish class-hash which depends on common, crypto and serde
publish_with_retry pathfinder-class-hash
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just publish all packages with a single cargo publish command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracking this in a new issue: #2509

Comment on lines 50 to 64

publish-crates:
name: Publish crates to crates.io
needs: upload-assets
runs-on: ubuntu-latest
steps:
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT

- uses: ./.github/workflows/publish-crates.yml
with:
version: ${{ steps.version.outputs.version }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we publish these crates we can't really update them, right? If so, then this "publish crates" job should be executed only when we publish the actual release on GitHub?

Otherwise it's possible that:

  • we tag a new release in git
  • this workflow creates the draft release and builds binary assets, then goes on to publish the crates
  • the Docker build however fails and we won't be able to fix it properly because these crates can't be re-published

So I this step should only be done after we've actually published the release in a separate workflow triggered by a new release being published:

on:
  release:
    types: [published]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracking this in a new issue: #2509

@t00ts t00ts force-pushed the t00ts/class-hash-crate branch from cdc6d15 to 8f5f4c2 Compare January 22, 2025 12:36
@t00ts t00ts merged commit cb88dd2 into main Jan 22, 2025
8 checks passed
@t00ts t00ts deleted the t00ts/class-hash-crate branch January 22, 2025 12:50
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.

feat: Expose private class hashing functionality
4 participants