Skip to content

Commit

Permalink
fix: BondedTokens exceeds int64 range (#300)
Browse files Browse the repository at this point in the history
## Description

Closes: #XXXX


fix bonded tokens / unbonded tokens exceeding range with int64. 
Store the value as string instead. 


---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
huichiaotsou authored Jan 6, 2022
1 parent 1bdca6c commit 210e7a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion database/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ ON CONFLICT ON CONSTRAINT unique_staking_pool_snapshot DO UPDATE SET
WHERE proposal_staking_pool_snapshot.height <= excluded.height`

_, err := db.Sql.Exec(stmt,
snapshot.ProposalID, snapshot.Pool.BondedTokens.Int64(), snapshot.Pool.NotBondedTokens.Int64(), snapshot.Pool.Height)
snapshot.ProposalID, snapshot.Pool.BondedTokens.String(), snapshot.Pool.NotBondedTokens.String(), snapshot.Pool.Height)
if err != nil {
return fmt.Errorf("error while storing proposal staking pool snapshot: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions database/schema/03-staking.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ CREATE INDEX staking_params_height_index ON staking_params (height);
CREATE TABLE staking_pool
(
one_row_id BOOLEAN NOT NULL DEFAULT TRUE PRIMARY KEY,
bonded_tokens BIGINT NOT NULL,
not_bonded_tokens BIGINT NOT NULL,
bonded_tokens TEXT NOT NULL,
not_bonded_tokens TEXT NOT NULL,
height BIGINT NOT NULL,
CHECK (one_row_id)
);
Expand Down
4 changes: 2 additions & 2 deletions database/schema/08-gov.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ CREATE INDEX proposal_tally_result_height_index ON proposal_tally_result (height
CREATE TABLE proposal_staking_pool_snapshot
(
proposal_id INTEGER REFERENCES proposal (id) PRIMARY KEY,
bonded_tokens BIGINT NOT NULL,
not_bonded_tokens BIGINT NOT NULL,
bonded_tokens TEXT NOT NULL,
not_bonded_tokens TEXT NOT NULL,
height BIGINT NOT NULL,
CONSTRAINT unique_staking_pool_snapshot UNIQUE (proposal_id)
);
Expand Down

0 comments on commit 210e7a1

Please sign in to comment.