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

[CL][bugfix] Refactor incentives tests and fix incentive forfeiting bug #4735

Merged
merged 15 commits into from
Mar 25, 2023
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
26 changes: 26 additions & 0 deletions .github/workflows/check-broken-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check Links

on:
schedule:
- cron: '0 0 * * *' # Run daily at 00:00 UTC
workflow_dispatch: # Allow manual triggering of the workflow

jobs:
check_links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.6.1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

- name: Create Issue From File
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@v4
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue
1 change: 1 addition & 0 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
working-directory: ${{ matrix.contract.workdir }}
run: >
docker run --rm -v "$(pwd)":/code \
-e REGISTRY_CONTRACT=osmo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sq2r9g9 \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.10
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Misc Improvements

* [#4582](https://github.com/osmosis-labs/osmosis/pull/4582) Consistently generate build tags metadata, to return a comma-separated list without stray quotes. This affects the output from `version` CLI subcommand and server info API calls.
* [#4549](https://github.com/osmosis-labs/osmosis/pull/4549) Add single pool price estimate queries

### API Breaks

### API breaks

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ running an Osmosis node!

The contributing guide for Osmosis explains the branching structure, how
to use the SDK fork, and how to make / test updates to SDK branches.

## LocalOsmosis

LocalOsmosis is a containerized local Osmosis testnet used for trying out new features locally.
LocalOsmosis documentation can be found [here](https://github.com/osmosis-labs/osmosis/tree/main/tests/localosmosis)
2 changes: 1 addition & 1 deletion cmd/osmosisd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
"24841abfc8fbd401d8c86747eec375649a2e8a7e@osmosis.pbcups.org:26656", // Pbcups
"77bb5fb9b6964d6e861e91c1d55cf82b67d838b5@bd-osmosis-seed-mainnet-us-01.bdnodes.net:26656", // Blockdaemon US
"3243426ab56b67f794fa60a79cc7f11bc7aa752d@bd-osmosis-seed-mainnet-eu-02.bdnodes.net:26656", // Blockdaemon EU
"ebc272824924ea1a27ea3183dd0b9ba713494f83@osmosis-mainnet-seed.autostake.net:26716", // AutoStake
"ebc272824924ea1a27ea3183dd0b9ba713494f83@osmosis-mainnet-seed.autostake.com:26716", // AutoStake.com
"7c66126b64cd66bafd9ccfc721f068df451d31a3@osmosis-seed.sunshinevalidation.io:9393", // Sunshine Validation
}
config.P2P.Seeds = strings.Join(seeds, ",")
Expand Down
3 changes: 2 additions & 1 deletion cmd/querygen/templates/grpcTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ type GrpcTemplate struct {

type GrpcQuery struct {
QueryName string
Response string
}

func GrpcTemplateFromQueryYml(queryYml QueryYml) GrpcTemplate {
GrpcQueries := []GrpcQuery{}
for queryName := range queryYml.Queries {
GrpcQueries = append(GrpcQueries, GrpcQuery{QueryName: queryName})
GrpcQueries = append(GrpcQueries, GrpcQuery{QueryName: queryName, Response: queryYml.Queries[queryName].ProtoWrapper.Response})
}
sort.Slice(GrpcQueries, func(i, j int) bool {
return GrpcQueries[i].QueryName > GrpcQueries[j].QueryName
Expand Down
2 changes: 1 addition & 1 deletion cmd/querygen/templates/grpc_template.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ queryproto.QueryServer = Querier{}

func (q Querier) {{.QueryName}}(grpcCtx context.Context,
req *queryproto.{{.QueryName}}Request,
) (*queryproto.{{.QueryName}}Response, error) {
) ({{ if .Response }}{{.Response}}{{else}}*queryproto.{{.QueryName}}Response{{end}}, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/querygen/templates/queryyml.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type YmlQueryDescriptor struct {
type ProtoWrapperDescriptor struct {
DefaultValues map[string]string `yaml:"default_values"`
QueryFunc string `yaml:"query_func"`
Response string
Response string `yaml:"response"`
}

type CliDescriptor struct{}
Expand Down
34 changes: 24 additions & 10 deletions cosmwasm/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 cosmwasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
'contracts/*',
'packages/*'
]

[workspace.package]
Expand Down Expand Up @@ -36,3 +37,4 @@ serde-json-wasm = "0.5.0"
serde-cw-value = "0.7.0"
bech32 = "0.9.1"
cw-utils = "1.0.0"
itertools = "0.10"
11 changes: 1 addition & 10 deletions cosmwasm/contracts/crosschain-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,10 @@ cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw2 = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
thiserror = { workspace = true }
bech32 = { workspace = true }
cw-utils = { workspace = true }
serde-json-wasm = { workspace = true }
sha2 = "0.10.6"
hex = "0.4.3"
prost = {version = "0.11.2", default-features = false, features = ["prost-derive"]}
osmosis-std-derive = "0.13.2"
itertools = "0.10.5"

crosschain-swaps = { path = "../crosschain-swaps", features = ["imported"]}
registry = { path = "../../packages/registry"}

[dev-dependencies]
cw-multi-test = "0.16.2"
12 changes: 9 additions & 3 deletions cosmwasm/contracts/crosschain-registry/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use cw2::set_contract_version;
use crate::error::ContractError;
use crate::msg::{ExecuteMsg, GetAddressFromAliasResponse, InstantiateMsg, QueryMsg};
use crate::state::{Config, CONFIG, CONTRACT_ALIAS_MAP};
use crate::{execute, query, Registries};
use crate::{execute, query};
use registry::Registry;

// version info for migration
const CONTRACT_NAME: &str = "crates.io:crosschain-registry";
Expand Down Expand Up @@ -60,15 +61,17 @@ pub fn execute(
ExecuteMsg::UnwrapCoin {
receiver,
into_chain,
with_memo,
} => {
let registries = Registries::new(deps.as_ref(), env.contract.address.to_string())?;
let registries = Registry::new(deps.as_ref(), env.contract.address.to_string())?;
let coin = cw_utils::one_coin(&info)?;
let transfer_msg = registries.unwrap_coin_into(
coin,
receiver,
into_chain.as_deref(),
env.contract.address.to_string(),
env.block.time,
with_memo,
)?;
deps.api.debug(&format!("transfer_msg: {transfer_msg:?}"));
Ok(Response::new()
Expand Down Expand Up @@ -113,6 +116,9 @@ pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
QueryMsg::GetDenomTrace { ibc_denom } => {
to_binary(&query::query_denom_trace_from_ibc_denom(deps, ibc_denom)?)
}
QueryMsg::GetChainNameFromBech32Prefix { prefix } => {
to_binary(&query::query_chain_name_from_bech32_prefix(deps, prefix)?)
}
}
}

Expand Down Expand Up @@ -327,7 +333,7 @@ mod test {
new_channel_id: None,
}],
};
let result = execute(deps.as_mut(), mock_env(), info_creator.clone(), msg);
let result = execute(deps.as_mut(), mock_env(), info_creator, msg);
assert!(result.is_ok());

// Retrieve osmo<>juno link again, but this time it should be enabled
Expand Down
85 changes: 1 addition & 84 deletions cosmwasm/contracts/crosschain-registry/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,90 +1,7 @@
use cosmwasm_std::StdError;
use registry::RegistryError;
use thiserror::Error;

#[derive(Error, Debug, PartialEq)]
pub enum RegistryError {
#[error("{0}")]
Std(#[from] StdError),

// Validation errors
#[error("Invalid channel id: {0}")]
InvalidChannelId(String),

#[error("error {action} {addr}")]
Bech32Error {
action: String,
addr: String,
#[source]
source: bech32::Error,
},

#[error("serialization error: {error}")]
SerialiaztionError { error: String },

#[error("denom {denom:?} is not an IBC denom")]
InvalidIBCDenom { denom: String },

#[error("No deom trace found for: {denom:?}")]
NoDenomTrace { denom: String },

#[error("Invalid denom trace: {error}")]
InvalidDenomTrace { error: String },

#[error("Invalid path {path:?} for denom {denom:?}")]
InvalidDenomTracePath { path: String, denom: String },

#[error("Invalid transfer port {port:?}")]
InvalidTransferPort { port: String },

#[error("Invalid multihop length {length:?}. Must be >={min}")]
InvalidMultiHopLengthMin { length: usize, min: usize },

#[error("Invalid multihop length {length:?}. Must be <={max}")]
InvalidMultiHopLengthMax { length: usize, max: usize },

#[error(
"receiver prefix for {receiver} must match the bech32 prefix of the destination chain {chain}"
)]
InvalidReceiverPrefix { receiver: String, chain: String },

// Registry loading errors
#[error("contract alias does not exist: {alias:?}")]
AliasDoesNotExist { alias: String },

#[error("no authorized address found for source chain: {source_chain:?}")]
ChainAuthorizedAddressDoesNotExist { source_chain: String },

#[error("chain channel link does not exist: {source_chain:?} -> {destination_chain:?}")]
ChainChannelLinkDoesNotExist {
source_chain: String,
destination_chain: String,
},

#[error("channel chain link does not exist: {channel_id:?} on {source_chain:?} -> chain")]
ChannelChainLinkDoesNotExist {
channel_id: String,
source_chain: String,
},

#[error("channel chain link does not exist: {channel_id:?} on {source_chain:?} -> chain")]
ChannelToChainChainLinkDoesNotExist {
channel_id: String,
source_chain: String,
},

#[error("native denom link does not exist: {native_denom:?}")]
NativeDenomLinkDoesNotExist { native_denom: String },

#[error("bech32 prefix does not exist for chain: {chain}")]
Bech32PrefixDoesNotExist { chain: String },
}

impl From<RegistryError> for StdError {
fn from(e: RegistryError) -> Self {
StdError::generic_err(e.to_string())
}
}

#[derive(Error, Debug, PartialEq)]
pub enum ContractError {
#[error("{0}")]
Expand Down
Loading