Skip to content

Commit

Permalink
Merge pull request #2 from stellar/soroban-tools-migration
Browse files Browse the repository at this point in the history
soroban-rpc: Migrate Soroban Tools to Soroban RPC
  • Loading branch information
stellarsaur authored Jan 17, 2024
2 parents 31667ad + 483dc73 commit fe8d751
Show file tree
Hide file tree
Showing 295 changed files with 48,725 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -e

echo '+cargo fmt --check'
cargo fmt --check || (cargo fmt && exit 1)
20 changes: 20 additions & 0 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

set -e

echo '+cargo fmt --check'
cargo fmt --check || (cargo fmt && exit 1)

echo "unstaged changes"
echo 'git diff-index --quiet HEAD --'
git diff-index --quiet HEAD --

echo '+cargo clippy -- -Dwarnings -Dclippy::all -Dclippy::pedantic'
cargo clippy --all -- -Dwarnings

echo '+cargo test --all'
cargo build
cargo test --all || (echo "might need to rebuild make build-snapshot" && exit 1)

echo '+cargo run --bin doc-gen --features clap-markdown'
cargo run --bin doc-gen --features clap-markdown
160 changes: 160 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# paths = ["/path/to/override"] # path dependency overrides

[alias] # command aliases
md-gen = "run --bin doc-gen --features clap-markdown"
f = "fmt"
# b = "build"
# c = "check"
# t = "test"
# r = "run"
# rr = "run --release"
# recursive_example = "rr --example recursions"
# space_example = ["run", "--release", "--", "\"command list\""]

[build]
# jobs = 1 # number of parallel jobs, defaults to # of CPUs
# rustc = "rustc" # the rust compiler tool
# rustc-wrapper = "…" # run this wrapper instead of `rustc`
# rustc-workspace-wrapper = "…" # run this wrapper instead of `rustc` for workspace members
# rustdoc = "rustdoc" # the doc generator tool
# target = "triple" # build for the target triple (ignored by `cargo install`)
# target-dir = "target" # path of where to place all generated artifacts
rustflags = [
"-Wclippy::pedantic",
"-Aclippy::needless_pass_by_value",
"-Aclippy::must_use_candidate",
"-Aclippy::missing_panics_doc",
"-Aclippy::missing_errors_doc",
# "-Aclippy::missing_safety_doc",
# "-Aclippy::inline_always",
# "-Aclippy::default_trait_access",
# "-Aclippy::module_name_repetitions",
# "-Aclippy::module_name_repetitions",
# "-Aclippy::too_many_lines",
# "-Aclippy::cast_possible_truncation",
# "-Aclippy::cast_sign_loss",
# "-Aclippy::cast_possible_wrap",
# "-Aclippy::similar_names",
# "-Aclippy::doc_markdown",
# "-Aclippy::struct_excessive_bools",
# "-Aclippy::cast_lossless",
# "-Aclippy::trivially_copy_pass_by_ref",
# "-Aclippy::wrong_self_convention",
# "-Aclippy::unused_self",
# "-Aclippy::enum_glob_use",
# "-Aclippy::return_self_not_must_use",
# "-Aclippy::map_entry",
# "-Aclippy::match_same_arms",
# "-Aclippy::iter_not_returning_iterator",
# "-Aclippy::unnecessary_wraps",
# "-Aclippy::type_complexity",
] # custom flags to pass to all compiler invocations
# rustdocflags = ["…", "…"] # custom flags to pass to rustdoc
# incremental = true # whether or not to enable incremental compilation
# dep-info-basedir = "…" # path for the base directory for targets in depfiles

# [doc]
# browser = "chromium" # browser to use with `cargo doc --open`,
# # overrides the `BROWSER` environment variable

# [env]
# # Set ENV_VAR_NAME=value for any process run by Cargo
# ENV_VAR_NAME = "value"
# # Set even if already present in environment
# ENV_VAR_NAME_2 = { value = "value", force = true }
# # Value is relative to .cargo directory containing `config.toml`, make absolute
# ENV_VAR_NAME_3 = { value = "relative/path", relative = true }

# [future-incompat-report]
# frequency = 'always' # when to display a notification about a future incompat report

# [cargo-new]
# vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none')

# [http]
# debug = false # HTTP debugging
# proxy = "host:port" # HTTP proxy in libcurl format
# ssl-version = "tlsv1.3" # TLS version to use
# ssl-version.max = "tlsv1.3" # maximum TLS version
# ssl-version.min = "tlsv1.1" # minimum TLS version
# timeout = 30 # timeout for each HTTP request, in seconds
# low-speed-limit = 10 # network timeout threshold (bytes/sec)
# cainfo = "cert.pem" # path to Certificate Authority (CA) bundle
# check-revoke = true # check for SSL certificate revocation
# multiplexing = true # HTTP/2 multiplexing
# user-agent = "…" # the user-agent header

# [install]
# root = "/some/path" # `cargo install` destination directory

# [net]
# retry = 2 # network retries
# git-fetch-with-cli = true # use the `git` executable for git operations
# offline = true # do not access the network

# [net.ssh]
# known-hosts = ["..."] # known SSH host keys

# [patch.<registry>]
# # Same keys as for [patch] in Cargo.toml

# [profile.<name>] # Modify profile settings via config.
# inherits = "dev" # Inherits settings from [profile.dev].
# opt-level = 0 # Optimization level.
# debug = true # Include debug info.
# split-debuginfo = '...' # Debug info splitting behavior.
# debug-assertions = true # Enables debug assertions.
# overflow-checks = true # Enables runtime integer overflow checks.
# lto = false # Sets link-time optimization.
# panic = 'unwind' # The panic strategy.
# incremental = true # Incremental compilation.
# codegen-units = 16 # Number of code generation units.
# rpath = false # Sets the rpath linking option.
# [profile.<name>.build-override] # Overrides build-script settings.
# # Same keys for a normal profile.
# [profile.<name>.package.<name>] # Override profile for a package.
# # Same keys for a normal profile (minus `panic`, `lto`, and `rpath`).

# [registries.<name>] # registries other than crates.io
# index = "…" # URL of the registry index
# token = "…" # authentication token for the registry

# [registry]
# default = "…" # name of the default registry
# token = "…" # authentication token for crates.io

# [source.<name>] # source definition and replacement
# replace-with = "…" # replace this source with the given named source
# directory = "…" # path to a directory source
# registry = "…" # URL to a registry source
# local-registry = "…" # path to a local registry source
# git = "…" # URL of a git repository source
# branch = "…" # branch name for the git repository
# tag = "…" # tag name for the git repository
# rev = "…" # revision for the git repository

# [target.<triple>]
# linker = "…" # linker to use
# runner = "…" # wrapper to run executables
# rustflags = ["…", "…"] # custom flags for `rustc`

# [target.<cfg>]
# runner = "…" # wrapper to run executables
# rustflags = ["…", "…"] # custom flags for `rustc`

# [target.<triple>.<links>] # `links` build script override
# rustc-link-lib = ["foo"]
# rustc-link-search = ["/path/to/foo"]
# rustc-flags = ["-L", "/some/path"]
# rustc-cfg = ['key="value"']
# rustc-env = {key = "value"}
# rustc-cdylib-link-arg = ["…"]
# metadata_key1 = "value"
# metadata_key2 = "value"

# [term]
# quiet = false # whether cargo output is quiet
# verbose = false # whether cargo provides verbose output
# color = 'auto' # whether cargo colorizes output
# progress.when = 'auto' # whether cargo shows progress bar
# progress.width = 80 # width of progress bar
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.soroban/
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cargo.lock text -merge eol=lf
cmd/crates/soroban-spec-typescript/fixtures/**/* linguist-generated=true -diff
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Involve the contract committer team when making changes to the soroban
# contract build command.
/cmd/soroban-cli/src/commands/contract/build.rs @stellar/contract-committers
55 changes: 55 additions & 0 deletions .github/actions/setup-go/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: 'Setup the Go environment'
description: 'Installs go and restores/saves the build/module cache'
inputs:
go-version:
required: true
runs:
using: "composite"
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ inputs.go-version }}
stable: ${{ !(contains(inputs.go-version, 'beta') || contains(inputs.go-version, 'rc')) }}

# Restore original modification time of files based on the date of the most
# recent commit that modified them as mtimes affect the Go test cache.
- name: Restore modification time of checkout files
shell: bash
run: |
# Set a base, fixed modification time of all directories.
# git-restore-mtime doesn't set the mtime of all directories.
# (see https://github.com/MestreLion/git-tools/issues/47 for details)
touch -m -t '201509301646' $(find . -type d -not -path '.git/*')
# Restore original modification time from git. git clone sets the
# modification time to the current time, but Go tests that access fixtures
# get invalidated if their modification times change.
sudo apt-get install -y git-restore-mtime
git restore-mtime
# The PREFIX must uniquely identify the specific instance of a job executing.
- shell: bash
run: echo 'PREFIX=${{ github.workflow }}-${{ github.job }}-${{ runner.os }}-${{ inputs.go-version }}-matrix(${{ join(matrix.*,'|') }})' >> $GITHUB_ENV

# Cache the Go Modules downloaded during the job.
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ env.PREFIX }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ env.PREFIX }}-go-mod-

# Cache any build and test artifacts during the job, which will speed up
# rebuilds and cause test runs to skip tests that have no reason to rerun.
- uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ env.PREFIX }}-go-build-${{ github.ref }}-${{ hashFiles('**', '!.git') }}
restore-keys: |
${{ env.PREFIX }}-go-build-${{ github.ref }}-
${{ env.PREFIX }}-go-build-
# Reset the cache for master/protected branches, to ensure they build and run the tests from zero
# and that the module cache is cleaned (otherwise it accumulates orphan dependencies over time).
- if: github.ref_protected
shell: bash
run: sudo rm -rf ~/.cache/go-build ~/go/pkg/mod
61 changes: 61 additions & 0 deletions .github/actions/setup-integration-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: 'Set up integration tests'
description: 'Set up Go & Rust, build artifacts, work around cache issues and Ubuntu quirks'
inputs:
go-version:
required: true
runs:
using: "composite"
steps:
- uses: ./.github/actions/setup-go
with:
go-version: ${{ matrix.go }}
- uses: stellar/actions/rust-cache@main
- name: Build soroban contract fixtures
shell: bash
run: |
rustup update
rustup target add wasm32-unknown-unknown
make build_rust
make build-test-wasms
- name: Install Captive Core
shell: bash
run: |
# Workaround for https://github.com/actions/virtual-environments/issues/5245,
# libc++1-8 won't be installed if another version is installed (but apt won't give you a helpful
# message about why the installation fails)
sudo apt-get remove -y libc++1-10 libc++abi1-10 || true
sudo wget -qO - https://apt.stellar.org/SDF.asc | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=true sudo apt-key add -
sudo bash -c 'echo "deb https://apt.stellar.org focal unstable" > /etc/apt/sources.list.d/SDF-unstable.list'
sudo apt-get update && sudo apt-get install -y stellar-core="$PROTOCOL_20_CORE_DEBIAN_PKG_VERSION"
echo "Using stellar core version $(stellar-core version)"
# Docker-compose's remote contexts on Ubuntu 20 started failing with an OpenSSL versioning error.
# See https://stackoverflow.com/questions/66579446/error-executing-docker-compose-building-webserver-unable-to-prepare-context-un
- name: Work around Docker Compose problem
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
# Install docker apt repo
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install docker-compose v2 from apt repo
sudo apt-get update
sudo apt-get remove -y moby-compose
sudo apt-get install -y docker-compose-plugin
echo "Docker Compose Version:"
docker-compose version
- name: Build libpreflight
shell: bash
run: make build-libpreflight
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### What

[TODO: Short statement about what is changing.]

### Why

[TODO: Why this change is being made. Include any context required to understand the why.]

### Known limitations

[TODO or N/A]
43 changes: 43 additions & 0 deletions .github/workflows/bindings-ts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

name: bindings typescript

on:
push:
branches: [main, release/**]
pull_request:

jobs:
test:
name: test generated libraries
runs-on: ubuntu-22.04
services:
rpc:
image: stellar/quickstart:soroban-dev@sha256:0ad51035cf7caba2fd99c7c1fad0945df6932be7d5c893e1520ccdef7d6a6ffe
ports:
- 8000:8000
env:
ENABLE_LOGS: true
NETWORK: local
ENABLE_SOROBAN_RPC: true
options: >-
--health-cmd "curl --no-progress-meter --fail-with-body -X POST \"http://localhost:8000/soroban/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}' && curl --no-progress-meter \"http://localhost:8000/friendbot\" | grep '\"invalid_field\": \"addr\"'"
--health-interval 10s
--health-timeout 5s
--health-retries 50
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: rustup update
- run: cargo build
- run: rustup target add wasm32-unknown-unknown
- run: make build-test-wasms
- run: npm ci && npm run test
working-directory: cmd/crates/soroban-spec-typescript/ts-tests
15 changes: 15 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Bump Version

on:
workflow_dispatch:
inputs:
version:
description: 'Version to bump to'
required: true

jobs:

bump-version:
uses: stellar/actions/.github/workflows/rust-bump-version.yml@main
with:
version: ${{ inputs.version }}
Loading

0 comments on commit fe8d751

Please sign in to comment.