Skip to content

Commit 00da166

Browse files
github-actions[bot]danflo27brendaloya
authored
fix: prevent reporter self switching, other tiny cleanup (#995) (#1001)
* fix script for lvm/start chain * remove one-time fix in preblock from height 1062219 * mark deposits claimed only after funds move * check snapshot limit before creating snapshots * prevent reporter self switching * import cleanup from removing one time preblocker math --------- (cherry picked from commit c13040d) Co-authored-by: Dan F <florentinodc@outlook.com> Co-authored-by: brendaloya <35778124+brendaloya@users.noreply.github.com>
1 parent e6c50ed commit 00da166

10 files changed

Lines changed: 549 additions & 113 deletions

File tree

app/app.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import (
6363
"cosmossdk.io/client/v2/autocli"
6464
"cosmossdk.io/core/appmodule"
6565
"cosmossdk.io/log"
66-
"cosmossdk.io/math"
6766
storetypes "cosmossdk.io/store/types"
6867
"cosmossdk.io/x/evidence"
6968
evidencekeeper "cosmossdk.io/x/evidence/keeper"
@@ -893,31 +892,6 @@ func (app *App) preBlocker(ph *ProposalHandler) func(ctx sdk.Context, _ *abci.Re
893892
if err != nil {
894893
return nil, err
895894
}
896-
if ctx.BlockHeight() == 1062219+1 {
897-
bondedPoolBal := app.BankKeeper.GetBalance(ctx, authtypes.NewModuleAddress(stakingtypes.BondedPoolName), "loya")
898-
vals, err := app.StakingKeeper.GetValidators(ctx, 7) // only 6 validators exist
899-
if err != nil {
900-
return nil, err
901-
}
902-
bondedtotal := math.ZeroInt()
903-
notbondedtotal := math.ZeroInt()
904-
for _, v := range vals {
905-
if v.IsBonded() {
906-
bondedtotal = bondedtotal.Add(v.Tokens)
907-
} else {
908-
notbondedtotal = notbondedtotal.Add(v.Tokens)
909-
}
910-
}
911-
// transfer amount should be 1950000000
912-
// "spendable balance 97171770000loya is smaller than 99121770000loya
913-
transferAmt := bondedPoolBal.Amount.Sub(bondedtotal)
914-
if transferAmt.Equal(math.NewInt(1950000000)) { // manually checked amount
915-
err = app.BankKeeper.SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, sdk.NewCoins(sdk.NewCoin("loya", transferAmt)))
916-
if err != nil {
917-
return nil, err
918-
}
919-
}
920-
}
921895

922896
changed := res.ConsensusParamsChanged
923897

start_scripts/start_a_chain.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ jq '.app_state.gov.params.min_deposit[0].denom = "loya"' $HOME_DIR/bill/config/g
9494
jq '.app_state.gov.params.min_deposit[0].amount = "100"' $HOME_DIR/bill/config/genesis.json > temp.json && mv temp.json $HOME_DIR/bill/config/genesis.json
9595
jq '.app_state.gov.params.expedited_voting_period = "30s"' $HOME_DIR/bill/config/genesis.json > temp.json && mv temp.json $HOME_DIR/bill/config/genesis.json
9696

97+
# Add TRBBridgeV2 data spec to genesis so local bridge tests work without runtime registration
98+
echo "Adding TRBBridgeV2 data spec to genesis..."
99+
echo "main..."
100+
jq --slurpfile trbbridgev2_spec start_scripts/test_jsons/trbbridgev2_ds.json 'if any((.app_state.registry.dataspec // [])[]; (.query_type | ascii_downcase) == "trbbridgev2") then . else .app_state.registry.dataspec = ((.app_state.registry.dataspec // []) + [$trbbridgev2_spec[0]]) end' $HOME_DIR/config/genesis.json > temp.json && mv temp.json $HOME_DIR/config/genesis.json
101+
echo "$KEY_NAME..."
102+
jq --slurpfile trbbridgev2_spec start_scripts/test_jsons/trbbridgev2_ds.json 'if any((.app_state.registry.dataspec // [])[]; (.query_type | ascii_downcase) == "trbbridgev2") then . else .app_state.registry.dataspec = ((.app_state.registry.dataspec // []) + [$trbbridgev2_spec[0]]) end' $HOME_DIR/$KEY_NAME/config/genesis.json > temp.json && mv temp.json $HOME_DIR/$KEY_NAME/config/genesis.json
103+
echo "bill..."
104+
jq --slurpfile trbbridgev2_spec start_scripts/test_jsons/trbbridgev2_ds.json 'if any((.app_state.registry.dataspec // [])[]; (.query_type | ascii_downcase) == "trbbridgev2") then . else .app_state.registry.dataspec = ((.app_state.registry.dataspec // []) + [$trbbridgev2_spec[0]]) end' $HOME_DIR/bill/config/genesis.json > temp.json && mv temp.json $HOME_DIR/bill/config/genesis.json
105+
97106
# Create a tx to give alice loyas to stake
98107
echo "Adding genesis accounts..."
99108
echo "$KEY_NAME..."
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"document_hash": "TRBBridgeV2",
3+
"query_type": "TRBBridgeV2",
4+
"response_value_type": "address, string, uint256, uint256",
5+
"abi_components": [
6+
{
7+
"name": "toLayer",
8+
"field_type": "bool"
9+
},
10+
{
11+
"name": "depositId",
12+
"field_type": "uint256"
13+
}
14+
],
15+
"aggregation_method": "weighted-mode",
16+
"registrar": "tellor1alcefjzkk37qmfrnel8q4eruyll0pc8arxhxxw",
17+
"report_block_window": 2000
18+
}

0 commit comments

Comments
 (0)