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

IBC Rate limiting contract #2408

Merged
merged 31 commits into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0a2656c
added ibc-rate-limiting contract
nicolaslara Aug 15, 2022
a6cf294
added cosmwasm workflow
nicolaslara Aug 15, 2022
15cbcec
added doc comments
nicolaslara Aug 16, 2022
9f605fc
added migration msg
nicolaslara Aug 16, 2022
26fc15b
Update x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs
nicolaslara Aug 17, 2022
a9dd5bf
removed gitkeep
nicolaslara Aug 17, 2022
11c5765
COmments & questions
ValarDragon Aug 17, 2022
1f237e8
Merge branch 'nicolas/ibc-rate-limit-contract' of github.com:osmosis-…
ValarDragon Aug 17, 2022
73acb2f
workflow without test data checks and clippy fixes
nicolaslara Aug 17, 2022
48b19cb
renames and code fixes
nicolaslara Aug 17, 2022
6180eb8
reordered imports
nicolaslara Aug 17, 2022
82c83b1
cargo fmt
nicolaslara Aug 17, 2022
d4ace7b
added danom tracking
nicolaslara Aug 17, 2022
746daa9
cleanup
nicolaslara Aug 17, 2022
fe97ee8
refactoring
nicolaslara Aug 18, 2022
c6758f1
changes to the expiration logic so that balances are calculated based…
nicolaslara Aug 18, 2022
e1d52f4
slightly slower but considerably cleanner
nicolaslara Aug 18, 2022
7434a44
cleanup attributes and removed redundancy when not testing
nicolaslara Aug 18, 2022
727fef2
update to edition 2021
nicolaslara Aug 18, 2022
7859a55
added comments explaining the tests
nicolaslara Aug 18, 2022
628db47
removed .beaker
nicolaslara Aug 18, 2022
9facb27
unified gitignore
nicolaslara Aug 18, 2022
042f3f4
removed second gitignore
nicolaslara Aug 18, 2022
c37a968
better doc comments
nicolaslara Aug 18, 2022
e5d72d6
spelling
nicolaslara Aug 18, 2022
d658fdd
spelling
nicolaslara Aug 18, 2022
c2a72ad
added channel value cache
nicolaslara Aug 18, 2022
43d6f17
leaving the attributes hard-coded until they can be properly configur…
nicolaslara Aug 19, 2022
acc413b
cleanup and reorganization
nicolaslara Aug 22, 2022
5cc1943
lint
nicolaslara Aug 22, 2022
364e35b
Merge branch 'main' into nicolas/ibc-rate-limit-contract
ValarDragon Aug 22, 2022
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
67 changes: 67 additions & 0 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Cosmwasm Contracts
on:
pull_request:
push:


jobs:
test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
matrix:
workdir: [./x/ibc-rate-limit]
# output: [./x/ibc-rate-limit/testdata/rate_limit.wasm]

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: wasm32-unknown-unknown

- name: Build
working-directory: ${{ matrix.workdir }}
run: >
rustup target add wasm32-unknown-unknown;
cargo build --release --target wasm32-unknown-unknown

- name: Test
working-directory: ${{ matrix.workdir }}
run: >
cargo test

# - name: Check Test Data
nicolaslara marked this conversation as resolved.
Show resolved Hide resolved
# working-directory: ${{ matrix.workdir }}
# if: ${{ matrix.output != null }}
# run: >
# ls ${{ matrix.output }};
# ls ${{ matrix.output }}/artifacts;
# diff ${{ matrix.output }} ./artifacts/*.wasm


lints:
name: Cosmwasm Lints
runs-on: ubuntu-latest
strategy:
matrix:
workdir: [./x/ibc-rate-limit]

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
target: wasm32-unknown-unknown

- name: Format
working-directory: ${{ matrix.workdir }}
run: >
cargo fmt --all -- --check
1 change: 1 addition & 0 deletions x/ibc-rate-limit/.beaker/state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
nicolaslara marked this conversation as resolved.
Show resolved Hide resolved
nicolaslara marked this conversation as resolved.
Show resolved Hide resolved
21 changes: 21 additions & 0 deletions x/ibc-rate-limit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Cargo
# will have compiled files and executables
debug/
nicolaslara marked this conversation as resolved.
Show resolved Hide resolved
target/

# Generated by rust-optimizer
artifacts/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb


# Ignores local beaker state
nicolaslara marked this conversation as resolved.
Show resolved Hide resolved
**/state.local.json
16 changes: 16 additions & 0 deletions x/ibc-rate-limit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[workspace]

members = [
'contracts/*',
]

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true
panic = 'abort'
rpath = false
Empty file.
3 changes: 3 additions & 0 deletions x/ibc-rate-limit/contracts/rate-limiter/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
unit-test = "test --lib"
15 changes: 15 additions & 0 deletions x/ibc-rate-limit/contracts/rate-limiter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Build results
/target

# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327)
.cargo-ok

# Text file backups
**/*.rs.bk

# macOS
.DS_Store

# IDEs
*.iml
.idea
53 changes: 53 additions & 0 deletions x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[package]
name = "rate-limiter"
version = "0.1.0"
authors = ["Nicolas Lara <[email protected]>"]
edition = "2018"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[package.metadata.scripts]
optimize = """docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.12.6
"""

[dependencies]
cosmwasm-std = "1.0.0"
cosmwasm-storage = "1.0.0"
cw-storage-plus = "0.13.2"
cw2 = "0.13.2"
schemars = "0.8.8"
serde = { version = "1.0.137", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.31" }

[dev-dependencies]
cosmwasm-schema = "1.0.0"
cw-multi-test = "0.13.2"
Loading