Skip to content

Commit

Permalink
refactor(core): move address logic to crate (#1802)
Browse files Browse the repository at this point in the history
## Summary
Breaks out address related logic in `astria_core::primitive::v1` to
`astria-core-address`

## Background
One needs to import the entire kitchensink that is `astria-core` even if
one only wants to use a fraction of its types. That leads to extremely
long compilation times because all of its dependencies need to be
compiled.

This patch is the start to breaking out parts of `astria-core` into
their own free standing crates, which `astria-core` then reexports.


## Changes
- Move address related types out of `astria_core::primitive::v1` into
`astria-core-address`
- Reexport all moved types under the same module (aliasing, where
necessary)
- Remove the serde `Serialize` and `Deserialize` impls on the domain
type `Address` (breaking because one needs to explicitly construct
protobuf/wire type `Address`; not breaking on the wire, json format
stays the same)
- Implement the `Protobuf` ("domain type") trait for `Address`, removing
its inherent constructors and methods to move from/to raw protobuf types
("wire types"); decouples `astria-core-address` from `astria-core`
(specifically, the generated protobuf types) (breaking for consumers
because they now need to import the `Protobuf` trait)
- Create a thin crate `astria-core-consts` that only contains the const
`ADDRESS_LENGTH` to allow decoupling of address and crypto logic
(addressed in a separate patch)
- Removed `AddressBuilder::with_iter` from the public interface (only
used inside the crate and not outside) (breaking for consumers of that
method)

## Testing
Tests were shuffled around but not removed. Snapshot tests stay in place
in astria core for now (because they are required for wire/protobuf
types).

## Changelogs
Changelogs updated.

## Breaking Changelist
- These changes leave all services untouched.
- If astria-core gave stability guarantees, this would be a breaking
change for consumers of `astria-core` because some inherent methods were
removed from its public API.
 
## Related Issues
Part of #1798
  • Loading branch information
SuperFluffy authored Nov 20, 2024
1 parent 401dfb5 commit 3e85e8d
Show file tree
Hide file tree
Showing 17 changed files with 585 additions and 573 deletions.
11 changes: 10 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"crates/astria-conductor",
"crates/astria-config",
"crates/astria-core",
"crates/astria-core-address",
"crates/astria-core-consts",
"crates/astria-core-crypto",
"crates/astria-eyre",
Expand All @@ -36,6 +37,7 @@ default-members = [
"crates/astria-conductor",
"crates/astria-config",
"crates/astria-core",
"crates/astria-core-address",
"crates/astria-core-consts",
"crates/astria-core-crypto",
"crates/astria-grpc-mock",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use astria_core::{
Action,
TransactionBody,
},
Protobuf as _,
};
use astria_eyre::eyre::{
self,
Expand Down
14 changes: 14 additions & 0 deletions crates/astria-core-address/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- markdownlint-disable no-duplicate-heading -->

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Initial release. [#1802](https://github.com/astriaorg/astria/pull/1802)
14 changes: 14 additions & 0 deletions crates/astria-core-address/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "astria-core-address"
version = "0.1.0"
edition = "2021"

[dependencies]
astria-core-consts = { path = "../astria-core-consts" }

thiserror = { workspace = true }

bech32 = "0.11.0"

[features]
unchecked-constructor = []
Loading

0 comments on commit 3e85e8d

Please sign in to comment.