Skip to content

Commit

Permalink
Merge pull request #39 from hadronlabs-org/feat/LIDO-95-unbonding-fin…
Browse files Browse the repository at this point in the history
…alisation

Unbonding finalisation
  • Loading branch information
oldremez authored Mar 13, 2024
2 parents ce3623e + f89dfde commit 8720bd9
Show file tree
Hide file tree
Showing 22 changed files with 2,216 additions and 2,146 deletions.
191 changes: 106 additions & 85 deletions contracts/core/src/contract.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum ContractError {
#[error("Non Native rewards denom not found {denom}")]
NonNativeRewardsDenomNotFound { denom: String },

#[error("Puppereer balance is outdated: ICA balance height {ica_height}, puppeteer balance height {puppeteer_height}")]
#[error("Puppeteer balance is outdated: ICA balance height {ica_height}, puppeteer balance height {puppeteer_height}")]
PuppeteerBalanceOutdated {
ica_height: u64,
puppeteer_height: u64,
Expand Down
13 changes: 8 additions & 5 deletions contracts/core/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use cosmwasm_std::{
from_json,
testing::{mock_env, mock_info, MockApi, MockQuerier, MockStorage},
to_json_binary, Coin, ContractResult, CosmosMsg, Decimal, Empty, Order, OwnedDeps, Querier,
QuerierResult, QueryRequest, StdResult, SystemError, SystemResult, Uint128, WasmMsg, WasmQuery,
QuerierResult, QueryRequest, StdResult, SystemError, SystemResult, Timestamp, Uint128, WasmMsg,
WasmQuery,
};

use lido_puppeteer_base::msg::QueryMsg as PuppeteerBaseQueryMsg;
Expand Down Expand Up @@ -72,9 +73,10 @@ impl WasmMockQuerier {
amount: Uint128::new(150),
}],
},
10,
10u64,
Timestamp::from_nanos(20),
);
to_json_binary(&(data.0, data.1))
to_json_binary(&data)
}
QueryExtMsg::Balances {} => {
let data = (
Expand All @@ -84,9 +86,10 @@ impl WasmMockQuerier {
amount: Uint128::new(200),
}],
},
10,
10u64,
Timestamp::from_nanos(20),
);
to_json_binary(&(data.0, data.1))
to_json_binary(&data)
}
_ => todo!(),
},
Expand Down
9 changes: 5 additions & 4 deletions contracts/puppeteer/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use cosmos_sdk_proto::cosmos::{
};
use cosmwasm_std::{
attr, ensure_eq, entry_point, to_json_binary, Addr, CosmosMsg, Deps, Order, Reply, StdError,
SubMsg, Uint128, WasmMsg,
SubMsg, Timestamp, Uint128, WasmMsg,
};
use cosmwasm_std::{Binary, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::set_contract_version;
Expand Down Expand Up @@ -98,6 +98,7 @@ pub fn instantiate(
},
},
0,
Timestamp::default(),
),
)?;
Puppeteer::default().instantiate(deps, config)
Expand Down Expand Up @@ -141,16 +142,16 @@ fn query_fees(deps: Deps<NeutronQuery>) -> ContractResult<Binary> {

fn query_delegations(deps: Deps<NeutronQuery>) -> ContractResult<Binary> {
let data = DELEGATIONS_AND_BALANCE.load(deps.storage)?;
to_json_binary(&(data.0.delegations, data.1)).map_err(ContractError::Std)
to_json_binary(&(data.0.delegations, data.1, data.2)).map_err(ContractError::Std)
}

fn query_balances(deps: Deps<NeutronQuery>) -> ContractResult<Binary> {
let data = DELEGATIONS_AND_BALANCE.load(deps.storage)?;
to_json_binary(&(data.0.balances, data.1)).map_err(ContractError::Std)
to_json_binary(&(data.0.balances, data.1, data.2)).map_err(ContractError::Std)
}
fn query_non_native_rewards_balances(deps: Deps<NeutronQuery>) -> ContractResult<Binary> {
let data = NON_NATIVE_REWARD_BALANCES.load(deps.storage)?;
to_json_binary(&(data.0, data.1)).map_err(ContractError::Std)
to_json_binary(&(data.0, data.1, data.2)).map_err(ContractError::Std)
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down
5 changes: 3 additions & 2 deletions contracts/strategy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cosmwasm_schema::cw_serde;
use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
use cosmwasm_std::{
to_json_binary, Addr, Attribute, Binary, Decimal, Deps, Empty, Env, Event, Response, StdResult,
Uint128,
Timestamp, Uint128,
};
use cw_multi_test::{custom_app, App, Contract, ContractWrapper, Executor};
use lido_puppeteer_base::error::ContractError as PuppeteerContractError;
Expand Down Expand Up @@ -95,7 +95,8 @@ fn puppeteer_query(
Delegations {
delegations: delegations_amount,
},
0,
0u64,
Timestamp::default(),
);
Ok(to_json_binary(&delegations)?)
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/withdrawal-manager/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ fn execute_receive_nft_withdraw(
)?;
ensure_eq!(
unbond_batch.status,
UnbondBatchStatus::Unbonded,
ContractError::BatchIsNotUnbonded {}
UnbondBatchStatus::Withdrawn,
ContractError::BatchIsNotWithdrawn {}
);
let slashing_effect = unbond_batch
.slashing_effect
Expand Down
4 changes: 2 additions & 2 deletions contracts/withdrawal-manager/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub enum ContractError {
#[error("Unauthorized")]
Unauthorized {},

#[error("Batch is not unbonded yet")]
BatchIsNotUnbonded {},
#[error("Batch is not withdrawn yet")]
BatchIsNotWithdrawn {},

#[error("Missing unbonded amount in batch")]
BatchAmountIsEmpty {},
Expand Down
31 changes: 15 additions & 16 deletions integration_tests/dockerfiles/gaia/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@
DIR="$(dirname $0)"
cd $DIR
VERSION=$(cat ../../package.json | jq -r '.version')
git clone https://github.com/cosmos/gaia.git -b v14.1.0
cp ./Dockerfile ./gaia
if [[ "$CI" == "true" ]]; then
VERSION="_$VERSION"
ORG=neutronorg/lionco-contracts:
else
VERSION=":$VERSION"
new_replace="github.com/cosmos/ibc-go/v4 v4.4.2 => github.com/ratik/ibc-go/v4 v4.4.3-0.20231115171220-5c22b66cfa8c"
gomod_file="gaia/go.mod"
cp "$gomod_file" "$gomod_file.bak"
awk -v new_replace="$new_replace" '
BEGIN { replace_block=0; added=0 }
/replace[[:space:]]*\(/ { replace_block=1 }
/^[[:space:]]*\)/ { if(replace_block) { print new_replace; added=1; replace_block=0 } }
{ print }
END { if(!added) { print "replace ("; print new_replace; print ")" } }
' "$gomod_file.bak" > "$gomod_file"
cd gaia
go mod tidy
cd ..
fi
git clone https://github.com/cosmos/gaia.git -b v14.1.0
cp ./Dockerfile ./gaia

new_replace="github.com/cosmos/ibc-go/v4 v4.4.2 => github.com/ratik/ibc-go/v4 v4.4.3-0.20231115171220-5c22b66cfa8c"
gomod_file="gaia/go.mod"
cp "$gomod_file" "$gomod_file.bak"
awk -v new_replace="$new_replace" '
BEGIN { replace_block=0; added=0 }
/replace[[:space:]]*\(/ { replace_block=1 }
/^[[:space:]]*\)/ { if(replace_block) { print new_replace; added=1; replace_block=0 } }
{ print }
END { if(!added) { print "replace ("; print new_replace; print ")" } }
' "$gomod_file.bak" > "$gomod_file"
cd gaia
go mod tidy
cd ..
docker build gaia -t ${ORG}gaia-test${VERSION}
rm -rf ./gaia
4 changes: 2 additions & 2 deletions integration_tests/dockerfiles/neutron-query-relayer/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
DIR="$(dirname $0)"
cd $DIR
git clone https://github.com/neutron-org/neutron-query-relayer
git clone -b foxpy/low-submission-margin-period https://github.com/neutron-org/neutron-query-relayer
VERSION=$(cat ../../package.json | jq -r '.version')
if [[ "$CI" == "true" ]]; then
VERSION="_$VERSION"
Expand All @@ -15,4 +15,4 @@ COMMIT=$(git log -1 --format='%H')
ldflags="-X github.com/neutron-org/neutron-query-relayer/internal/app.Version=$GVERSION -X github.com/neutron-org/neutron-query-relayer/internal/app.Commit=$COMMIT"
docker build --build-arg LDFLAGS="$ldflags" . -t ${ORG}neutron-query-relayer-test${VERSION}
cd ..
rm -rf ./neutron-query-relayer
rm -rf ./neutron-query-relayer
3 changes: 1 addition & 2 deletions integration_tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lido-cosmos-integration-tests",
"version": "1.0.0",
"version": "1.0.1",
"main": "vitest",
"license": "MIT",
"scripts": {
Expand All @@ -9,7 +9,6 @@
"test:poc-provider-proposals": "vitest --run poc-provider-proposals.test --bail 1",
"test:poc-proposal-votes": "vitest --run poc-proposal-votes.test --bail 1",
"test:core": "vitest --run core.test.ts --bail 1",
"test:core:fsm": "vitest --run core.fsm --bail 1",
"test:pump": "vitest --run pump --bail 1",
"test:pump-multi": "vitest --run pump-multi --bail 1",
"test:puppeteer": "vitest --run puppeteer.test --bail 1",
Expand Down
Loading

0 comments on commit 8720bd9

Please sign in to comment.