Skip to content

Commit 009fab0

Browse files
authored
refactor(x/escrow): truncate dec part during payment withdraw (#2024)
fixes issue when fractional of uakt remain in the balance after account is closed. refactor escrow testsuite to ensure funds are tracked during account operations and match expected values Signed-off-by: Artur Troian <[email protected]> Co-authored-by: Artur Troian <[email protected]>
1 parent 41aa2fe commit 009fab0

File tree

30 files changed

+2458
-409
lines changed

30 files changed

+2458
-409
lines changed

.github/workflows/tests.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ jobs:
170170
uses: ./.github/actions/setup-ubuntu
171171
- name: Setup docker user
172172
run: |
173-
DOCKER_USER=$(id -u)
174-
DOCKER_GROUP=$(id -g)
175-
echo "DOCKER_USER=$DOCKER_USER" >> $GITHUB_ENV
176-
echo "DOCKER_GROUP=$DOCKER_GROUP" >> $GITHUB_ENV
173+
DOCKER_IDU=$(id -u)
174+
DOCKER_IDG=$(id -g)
175+
echo "DOCKER_IDU=$DOCKER_IDU" >> $GITHUB_ENV
176+
echo "DOCKER_IDG=$DOCKER_IDG" >> $GITHUB_ENV
177177
- name: configure variables
178178
run: |
179179
test_required=$(./script/upgrades.sh test-required ${{ github.ref }})

app/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func NewApp(
133133
app := &AkashApp{
134134
BaseApp: bapp,
135135
App: &apptypes.App{
136+
Cdc: appCodec,
136137
Log: logger,
137138
},
138139
aminoCdc: aminoCdc,

app/types/app.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type AppKeepers struct {
121121
}
122122

123123
type App struct {
124+
Cdc codec.Codec
124125
Keepers AppKeepers
125126
Configurator module.Configurator
126127
MM *module.Manager
@@ -192,6 +193,10 @@ func (app *App) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
192193
return app.memKeys[storeKey]
193194
}
194195

196+
func (app *App) GetCodec() codec.Codec {
197+
return app.Cdc
198+
}
199+
195200
// InitSpecialKeepers initiates special keepers (crisis appkeeper, upgradekeeper, params keeper)
196201
func (app *App) InitSpecialKeepers(
197202
cdc codec.Codec,

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
google.golang.org/grpc v1.75.0
4646
gopkg.in/yaml.v3 v3.0.1
4747
gotest.tools/v3 v3.5.2
48-
pkg.akt.dev/go v0.1.5
48+
pkg.akt.dev/go v0.1.6
4949
pkg.akt.dev/go/cli v0.1.4
5050
pkg.akt.dev/go/sdl v0.1.1
5151
)

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,8 +3284,8 @@ nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0=
32843284
nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c=
32853285
pgregory.net/rapid v0.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA=
32863286
pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
3287-
pkg.akt.dev/go v0.1.5 h1:UdhU70YOzfJzzd1mT6dpnK7/5RWwV7N1zr1HRNmqtaw=
3288-
pkg.akt.dev/go v0.1.5/go.mod h1:67LZ0QbZMoCipadLNIR8HzMFcL4A4My7h9aMo516SGk=
3287+
pkg.akt.dev/go v0.1.6 h1:3wkDfEMWwe4ziUfNq6wUxRFSgYsL/uYF/uZgVfdet/U=
3288+
pkg.akt.dev/go v0.1.6/go.mod h1:GUDt3iohVNbt8yW4P5Q0D05zoMs2NXaojF2ZBZgfWUQ=
32893289
pkg.akt.dev/go/cli v0.1.4 h1:wFPegnPwimWHi0v5LN6AnWZnwtwpnD6mb7Dp1HSuzlw=
32903290
pkg.akt.dev/go/cli v0.1.4/go.mod h1:ZLqHZcq+D/8a27WTPYhmfCm2iGbNicWV1AwOhdspJ4Y=
32913291
pkg.akt.dev/go/sdl v0.1.1 h1:3CcAqWeKouFlvUSjQMktWLDqftOjn4cBX37TRFT7BRM=

make/test-upgrade.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ UPGRADE_FROM := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name
2121
GENESIS_BINARY_VERSION := $(shell cat $(ROOT_DIR)/meta.json | jq -r --arg name $(UPGRADE_TO) '.upgrades[$$name].from_binary' | tr -d '\n')
2222
UPGRADE_BINARY_VERSION ?= local
2323

24-
SNAPSHOT_SOURCE ?= sandbox1
24+
SNAPSHOT_SOURCE ?= mainnet
2525

2626
ifeq ($(SNAPSHOT_SOURCE),mainnet)
2727
SNAPSHOT_NETWORK := akashnet-2
@@ -67,6 +67,7 @@ test: init
6767
$(GO_TEST) -run "^\QTestUpgrade\E$$" -tags e2e.upgrade -timeout 180m -v -args \
6868
-cosmovisor=$(COSMOVISOR) \
6969
-workdir=$(AP_RUN_DIR)/validators \
70+
-sourcesdir=$(AKASH_ROOT) \
7071
-config=$(TEST_CONFIG) \
7172
-upgrade-name=$(UPGRADE_TO) \
7273
-upgrade-version="$(UPGRADE_BINARY_VERSION)" \
@@ -75,7 +76,7 @@ test: init
7576
.PHONY: test-reset
7677
test-reset:
7778
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) --snapshot-url=$(SNAPSHOT_URL) --chain-meta=$(CHAIN_METADATA_URL) --max-validators=$(MAX_VALIDATORS) clean
78-
#$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) --snapshot-url=$(SNAPSHOT_URL) --gbv=$(GENESIS_BINARY_VERSION) --chain-meta=$(CHAIN_METADATA_URL) bins
79+
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) --snapshot-url=$(SNAPSHOT_URL) --gbv=$(GENESIS_BINARY_VERSION) --chain-meta=$(CHAIN_METADATA_URL) bins
7980
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --uto=$(UPGRADE_TO) --snapshot-url=$(SNAPSHOT_URL) --chain-meta=$(CHAIN_METADATA_URL) keys
8081
$(ROOT_DIR)/script/upgrades.sh --workdir=$(AP_RUN_DIR) --config="$(PWD)/config.json" --state-config=$(STATE_CONFIG) --snapshot-url=$(SNAPSHOT_URL) --chain-meta=$(CHAIN_METADATA_URL) --max-validators=$(MAX_VALIDATORS) prepare-state
8182

meta.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
"skipped": false,
4545
"from_binary": "v0.38.6-rc2",
4646
"from_version": "v0.38.0"
47+
},
48+
"v1.1.0": {
49+
"skipped": false,
50+
"from_binary": "v1.0.4",
51+
"from_version": "v1.0.0"
4752
}
4853
}
4954
}

tests/upgrade/sdktypes.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package upgrade
2+
3+
import (
4+
"encoding/json"
5+
6+
upgradetypes "cosmossdk.io/x/upgrade/types"
7+
sdk "github.com/cosmos/cosmos-sdk/types"
8+
)
9+
10+
// These files defines sdk specific types necessary to perform upgrade simulation.
11+
// we're not using SDK generated types to prevent import of different types of cosmos sdk
12+
13+
type nodeStatus struct {
14+
SyncInfo struct {
15+
LatestBlockHeight string `json:"latest_block_height"`
16+
CatchingUp bool `json:"catching_up"`
17+
} `json:"sync_info"`
18+
}
19+
20+
type votingParams struct {
21+
VotingPeriod string `json:"voting_period"`
22+
}
23+
24+
type depositParams struct {
25+
MinDeposit sdk.Coins `json:"min_deposit"`
26+
}
27+
28+
type govParams struct {
29+
VotingParams votingParams `json:"voting_params"`
30+
DepositParams depositParams `json:"deposit_params"`
31+
}
32+
33+
type proposalResp struct {
34+
ID string `json:"id"`
35+
Title string `json:"title"`
36+
}
37+
38+
type proposalsResp struct {
39+
Proposals []proposalResp `json:"proposals"`
40+
}
41+
42+
type SoftwareUpgradeProposal struct {
43+
Type string `json:"@type"`
44+
Authority string `json:"authority"`
45+
Plan upgradetypes.Plan `json:"plan"`
46+
}
47+
48+
type ProposalMsg struct {
49+
// Msgs defines an array of sdk.Msgs proto-JSON-encoded as Anys.
50+
Messages []json.RawMessage `json:"messages,omitempty"`
51+
Metadata string `json:"metadata"`
52+
Deposit string `json:"deposit"`
53+
Title string `json:"title"`
54+
Summary string `json:"summary"`
55+
Expedited bool `json:"expedited"`
56+
}

tests/upgrade/test-cases.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2+
"v1.1.0": {
3+
"modules": {
4+
},
5+
"migrations": {
6+
}
7+
},
28
"v1.0.0": {
39
"modules": {
410
"added": [
@@ -15,7 +21,8 @@
1521
{
1622
"from": "3",
1723
"to": "4"
18-
}, {
24+
},
25+
{
1926
"from": "4",
2027
"to": "5"
2128
}
@@ -164,7 +171,8 @@
164171
{
165172
"from": "2",
166173
"to": "3"
167-
}, {
174+
},
175+
{
168176
"from": "3",
169177
"to": "4"
170178
},

tests/upgrade/test-config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"chain-id": "localakash",
33
"validators": [
4-
".akash0",
5-
".akash1"
4+
".akash0"
65
],
76
"work": {
87
"home": ".akash0",

0 commit comments

Comments
 (0)