Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/publish-soldeer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Publish to Soldeer
on:
push:
tags:
- "v*"
jobs:
publish:
uses: rainlanguage/rainix/.github/workflows/publish-soldeer.yaml@main
secrets: inherit
48 changes: 3 additions & 45 deletions .github/workflows/rainix.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
name: Rainix CI
name: rainix
on: [push]

jobs:
rainix:
strategy:
matrix:
os: [ubuntu-latest]
task: [rainix-sol-test, rainix-sol-static, rainix-sol-legal]
fail-fast: false
runs-on: ${{ matrix.os }}
env:
DEPLOYMENT_KEY: ${{ github.ref == 'refs/heads/main' && secrets.PRIVATE_KEY || secrets.PRIVATE_KEY_DEV }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- uses: nixbuild/nix-quick-install-action@v30
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
# restore and save a cache using this key
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }}
# if there's no cache hit, restore a cache by this prefix
restore-prefixes-first-match: nix-${{ runner.os }}-
# collect garbage until the Nix store size (in bytes) is at most this number
# before trying to save a new cache
# 1G = 1073741824
gc-max-store-size-linux: 1G

- run: nix develop --command rainix-sol-prelude
- name: Run ${{ matrix.task }}
env:
ETH_RPC_URL: ${{ secrets.CI_DEPLOY_SEPOLIA_RPC_URL || vars.CI_DEPLOY_SEPOLIA_RPC_URL }}
ETHERSCAN_API_KEY: ${{ secrets.EXPLORER_VERIFICATION_KEY }}
DEPLOY_BROADCAST: ''
DEPLOY_VERIFIER: ''
DEPLOY_METABOARD_ADDRESS: ${{ vars.CI_DEPLOY_SEPOLIA_METABOARD_ADDRESS }}
CI_FORK_SEPOLIA_BLOCK_NUMBER: ${{ vars.CI_FORK_SEPOLIA_BLOCK_NUMBER }}
CI_FORK_SEPOLIA_DEPLOYER_ADDRESS: ${{ vars.CI_FORK_SEPOLIA_DEPLOYER_ADDRESS }}
CI_DEPLOY_SEPOLIA_RPC_URL: ${{ secrets.CI_DEPLOY_SEPOLIA_RPC_URL || vars.CI_DEPLOY_SEPOLIA_RPC_URL }}
run: nix develop --command ${{ matrix.task }}
uses: rainlanguage/rainix/.github/workflows/rainix-sol.yaml@main
secrets: inherit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
out
cache
dependencies
result
.env
meta
target
docs
.DS_Store
.pre-commit-config.yaml

# This is for our deploy scripts that report the addresses of deployed contracts
deployments
deployments
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

29 changes: 29 additions & 0 deletions .soldeerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.DS_Store
.coderabbitai.yaml
.gas-snapshot
.git
.github
.gitignore
.gitmodules
.pre-commit-config.yaml
.soldeerignore
.vscode
CLAUDE.md
/audit
/cache
/dependencies
/deployments
/docs
/flake.lock
/flake.nix
/foundry.lock
/foundry.toml
/lib
/meta
/out
/remappings.txt
/result
/slither.config.json
/soldeer.lock
/target
/test
78 changes: 40 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
# rain.string

Tools for working with strings that we've found useful to build Rainlang.
Low-level string and parsing primitives used to build Rainlang. Specialised
parsing logic lives in dedicated Rainlang repos; this is the broadly-applicable,
gas-efficient base.

More specialised and complex parsing logic exists in other Rainlang repos, but
this stuff is broadly applicable and low level enough to be gas efficient enough
to do what needs to be done.
Parsing in Rainlang works like a bloom filter over individual characters. Read a
byte from memory, bit-shift, compare against a 32-byte mask representing
characters of interest (e.g. `0-9`, or `a-zA-Z0-9`). No regexes, in-memory sets,
or loops — every ASCII char fits unambiguously in a single 32-byte EVM word.

Generally parsing in rainlang works like a bloom filter on individual characters.
We read characters from memory one byte at a time then bit shift to compare it
against a bitmap mask that represents characters of interest. For example we
might need to know if a character is numeric `0-9` or alphanumeric `a-zA-Z0-9`,
and we cannot rely on regexes, in-memory sets, or even loops, that might be
easily at hand for similar tasks in other languages.
## Install

Luckily, EVM values are 32 bytes and so we can fit all posssible ASCII characters
in a single value as a bloom without any ambiguity.
Via [soldeer](https://soldeer.xyz):

## Dev stuff

### Local environment & CI
```sh
forge soldeer install rain-string~<version>
```

Uses nixos.
## Develop

Install `nix develop` - https://nixos.org/download.html.
This repo uses [nix](https://nixos.org/download.html). The default shell is the
slim `sol-shell` from [rainix](https://github.com/rainlanguage/rainix).

Run `nix develop` in this repo to drop into the shell. Please ONLY use the nix
version of `foundry` for development, to ensure versions are all compatible.
```sh
nix develop # enter the shell
forge soldeer install # install deps declared in foundry.toml
forge test
```

Read the `flake.nix` file to find some additional commands included for dev and
CI usage.
Tasks:

## Legal stuff
- `rainix-sol-test` — `forge test`
- `rainix-sol-static` — slither
- `rainix-sol-legal` — `reuse lint`

Everything is under DecentraLicense 1.0 (DCL-1.0) which can be found in `LICENSES/`.
Use the nix-pinned `forge` for all development.

This is basically `CAL-1.0` which is an open source license
https://opensource.org/license/cal-1-0
## Publish

The non-legal summary of DCL-1.0 is that the source is open, as expected, but
also user data in the systems that this code runs on must also be made available
to those users as relevant, and that private keys remain private.
Tag `v<x.y.z>` on `main`. The
[`Publish to Soldeer`](.github/workflows/publish-soldeer.yaml) wrapper delegates
to rainix's reusable workflow, which derives the package name from the repo name
(`rain.string` → `rain-string`).

Roughly it's "not your keys, not your coins" aware, as close as we could get in
legalese.
## License

This is the default situation on permissionless blockchains, so shouldn't require
any additional effort by dev-users to adhere to the license terms.
DecentraLicense 1.0 (DCL-1.0) — full text in
[`LICENSES/`](LICENSES/LicenseRef-DCL-1.0.txt). Roughly `CAL-1.0`
([opensource.org](https://opensource.org/license/cal-1-0)) plus user-data
disclosure obligations consistent with permissionless-blockchain assumptions.

This repo is REUSE 3.2 compliant https://reuse.software/spec-3.2/ and compatible
with `reuse` tooling (also available in the nix shell here).
This repo is [REUSE 3.2](https://reuse.software/spec-3.2/) compliant. Verify
locally:

```
```sh
nix develop -c rainix-sol-legal
```

## Contributions

Contributions are welcome **under the same license** as above.

Contributors agree and warrant that their contributions are compliant.
Welcome under the same license. Contributors warrant that their contributions
are compliant.
29 changes: 16 additions & 13 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ version = 1

[[annotations]]
path = [
".gas-snapshot",
".github/workflows/**/",
".vscode/**/",
".gitignore",
".gitmodules",
"audit/**/",
"README.md",
"flake.lock",
"flake.nix",
"foundry.toml",
"slither.config.json",
"REUSE.toml",
"foundry.lock",
".gas-snapshot",
".github/workflows/**/",
".vscode/**/",
".gitignore",
".gitmodules",
".soldeerignore",
"audit/**/",
"README.md",
"flake.lock",
"flake.nix",
"foundry.toml",
"remappings.txt",
"slither.config.json",
"REUSE.toml",
"foundry.lock",
"soldeer.lock",
]
SPDX-FileCopyrightText = "Copyright (c) 2020 Rain Open Source Software Ltd"
SPDX-License-Identifier = "LicenseRef-DCL-1.0"
Loading
Loading