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

feat: transfer cl position to new owner #6623

Merged
merged 36 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
efc7fba
transer cl position
czarcas7ic Oct 3, 2023
3c0dbd4
Auto: update go.mod after push to adam/transfer-position-cl that modi…
invalid-email-address Oct 3, 2023
bca1533
changelog
czarcas7ic Oct 3, 2023
dff2315
remove commented out logic
czarcas7ic Oct 3, 2023
231ada1
Update CHANGELOG.md
czarcas7ic Oct 3, 2023
5cfe3bf
add godoc and test for ParseUint64SliceToString
czarcas7ic Oct 3, 2023
198cf74
add godoc
czarcas7ic Oct 3, 2023
21195ee
add incentives and spread rewards to message server test
czarcas7ic Oct 3, 2023
39bac77
expand message server test
czarcas7ic Oct 3, 2023
07be722
further expand test
czarcas7ic Oct 3, 2023
4346b86
godoc
czarcas7ic Oct 3, 2023
2528e96
Auto: update go.mod after push to adam/transfer-position-cl that modi…
invalid-email-address Oct 3, 2023
0dc9123
use helper methods
czarcas7ic Oct 3, 2023
febb5d4
modify array diff method
czarcas7ic Oct 3, 2023
16e9829
Auto: update go.mod after push to adam/transfer-position-cl that modi…
invalid-email-address Oct 3, 2023
920b1a4
address test
czarcas7ic Oct 3, 2023
1b04c86
last test fix
czarcas7ic Oct 4, 2023
5d6f510
Update x/concentrated-liquidity/client/cli/tx.go
czarcas7ic Oct 8, 2023
bb936a1
Update osmoutils/compare.go
czarcas7ic Oct 8, 2023
9cd487e
rename all uses
czarcas7ic Oct 8, 2023
3ab50f1
sort the result, add tests for both sorted and unsorted
czarcas7ic Oct 8, 2023
56eea8d
extend tests
czarcas7ic Oct 8, 2023
0254345
unrelated lint
czarcas7ic Oct 8, 2023
57fe3ca
Merge branch 'main' into adam/transfer-position-cl
czarcas7ic Oct 8, 2023
b17bd2c
add testing invariants comment to TestTransferPositions
czarcas7ic Oct 8, 2023
c96b505
add why actual amount should be less than expected
czarcas7ic Oct 8, 2023
c9ecd14
Auto: update go.mod after push to adam/transfer-position-cl that modi…
invalid-email-address Oct 8, 2023
bb9706c
regen docs
czarcas7ic Oct 8, 2023
2ac0230
comment explaining trasferPosition in proto
czarcas7ic Oct 8, 2023
ad2b3c3
add fixed gas consumption
czarcas7ic Oct 9, 2023
fd24b80
fix scaling gas charge and add parser test case
AlpinYukseloglu Oct 11, 2023
e68d661
Auto: update go.mod after push to adam/transfer-position-cl that modi…
invalid-email-address Oct 11, 2023
04a3a68
remove incorrect comment
czarcas7ic Oct 11, 2023
710bd89
Merge branch 'main' into adam/transfer-position-cl
czarcas7ic Oct 11, 2023
a6d8092
tidy osmomath
czarcas7ic Oct 11, 2023
0b8367a
transfer random position
czarcas7ic Oct 11, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#6468](https://github.com/osmosis-labs/osmosis/pull/6468) feat: remove osmo multihop discount
* [#6420](https://github.com/osmosis-labs/osmosis/pull/6420) feat[CL]: Creates a governance set whitelist of addresses that can bypass the normal pool creation restrictions on concentrated liquidity pools
* [#6623](https://github.com/osmosis-labs/osmosis/pull/6420) feat: transfer cl positions to new owner

### State Breaking

Expand Down
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ require (
github.com/mattn/go-sqlite3 v1.14.17
github.com/ory/dockertest/v3 v3.10.0
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230924192433-36cf2950dca4
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230929193736-aae32321cac7
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230911120014-b14342e08daf
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230911120014-b14342e08daf
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231003223742-febb5d40fc1d
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231003223742-febb5d40fc1d
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20231003223742-febb5d40fc1d
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20231003223742-febb5d40fc1d
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.1
Expand Down Expand Up @@ -57,7 +57,7 @@ require (
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/butuzov/mirror v1.1.0 // indirect
github.com/ccojocar/zxcvbn-go v1.0.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/cosmos/gogoproto v1.4.11 // indirect
github.com/cosmos/iavl v0.19.7 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
Expand All @@ -81,6 +81,7 @@ require (
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/timonwong/loggercheck v0.9.4 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/xen0n/gosmopolitan v1.2.1 // indirect
github.com/ykadowak/zerologlint v0.1.3 // indirect
github.com/zimmski/go-mutesting v0.0.0-20210610104036-6d9217011a00 // indirect
Expand Down
22 changes: 8 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ github.com/butuzov/ireturn v0.2.0/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacM
github.com/butuzov/mirror v1.1.0 h1:ZqX54gBVMXu78QLoiqdwpl2mgmoOJTk7s4p4o+0avZI=
github.com/butuzov/mirror v1.1.0/go.mod h1:8Q0BdQU6rC6WILDiBM60DBfvV78OLJmMmixe7GF45AE=
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
Expand All @@ -222,10 +220,7 @@ github.com/charithe/durationcheck v0.0.10/go.mod h1:bCWXb7gYRysD1CU3C+u4ceO49LoG
github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 h1:W9o46d2kbNL06lq7UNDPV0zYLzkrde/bjIqO02eoll0=
github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8/go.mod h1:gakxgyXaaPkxvLw1XQxNGK4I37ys9iBRzNUx/B7pUCo=
github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA=
github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo=
github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down Expand Up @@ -964,14 +959,14 @@ github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230922030206-734f99fba785 h1:
github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230922030206-734f99fba785/go.mod h1:toI9Pf+e5C4TuWAFpXfkxnkpr1RVFMK2qr7QMdkFrY8=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230924192433-36cf2950dca4 h1:venI3u6DjxKcQbjiCO3V8s0ww/jx+cAZRkpwLHadms8=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230924192433-36cf2950dca4/go.mod h1:IlCTpM2uoi8SUAigc9r9kAaoz7K5H9O84u7CwaTLDdY=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230929193736-aae32321cac7 h1:E5rwhxKEt6XOIfLkoLNiqCCFNCymJjiwMYIP+0ABMKM=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230929193736-aae32321cac7/go.mod h1:YT53hlXr54D4MVKp3eoBxigiiYvy3F+h+xTZuGPW5R8=
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230911120014-b14342e08daf h1:8lkIsAj3L7zxvOZbqVLNJRpSdDxaYhYfAIG7XjPaJiU=
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230911120014-b14342e08daf/go.mod h1:C0Uqe6X4N5ASA+1xZ6guaaJyUVKLcaVJIQa4Q4LG9Vk=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230911120014-b14342e08daf h1:ZEi+yJJPgpYtmNwZ1bMiP5cMBDQ83FK/YGgmTnWmoAI=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230911120014-b14342e08daf/go.mod h1:pqkAsS04Er1kFM41gg3aWTSaYHyLe8C9Dw3Sj8KMXk8=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231003223742-febb5d40fc1d h1:YU32IlPwa1CsnXXxJKnX9e0n4p8MC6txKp5RsyhC0Ec=
github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20231003223742-febb5d40fc1d/go.mod h1:YEMUPuI9gBUATC4tp2MiW0oWRlShli0K95JqgNKJh9c=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231003223742-febb5d40fc1d h1:eQK6rkHA6bkP7Hq9huFtx8Fz/attOyKN7++ITam0p7U=
github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20231003223742-febb5d40fc1d/go.mod h1:Zmyx5zMUBN2KV94booSFn2v8KQcUKeCHqyWpKZ4PRMo=
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20231003223742-febb5d40fc1d h1:2xfs4Pfzcp0qSRihbja0unfLPfHxueDmaQSplZz4FCM=
github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20231003223742-febb5d40fc1d/go.mod h1:h2bGT8MCtEYdWk1Qg530P2quh29jVGefDsT94vSJ0ck=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20231003223742-febb5d40fc1d h1:9uCwV3qXRjchR6Yzshmgrh0+6f7wrcUhWbz/C/i2WYM=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20231003223742-febb5d40fc1d/go.mod h1:nEvp/Hj2TChJuKBokDyDy7dkvDufu0JAKdpJCUe1EZ0=
github.com/osmosis-labs/wasmd v0.31.0-osmo-v16 h1:X747cZYdnqc/+RV48iPVeGprpVb/fUWSaKGsZUWrdbg=
github.com/osmosis-labs/wasmd v0.31.0-osmo-v16/go.mod h1:Rf8zW/GgBQyFRRB4s62VQHWA6sTlMFSjoDQQpoq64iI=
github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw=
Expand Down Expand Up @@ -1332,7 +1327,6 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.5.0 h1:jpGode6huXQxcskEIpOCvrU+tzo81b6+oFLUYXWtH/Y=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down
11 changes: 5 additions & 6 deletions osmomath/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/osmosis-labs/osmosis/osmomath
go 1.20

require (
cosmossdk.io/math v1.1.3-rc.0
cosmossdk.io/math v1.1.3-rc.1
github.com/cosmos/cosmos-sdk v0.47.5
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230911115719-1d5a34978fe1
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -53,11 +53,10 @@ require (
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
Expand Down
16 changes: 5 additions & 11 deletions osmomath/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs=
cosmossdk.io/math v1.1.3-rc.0/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0=
cosmossdk.io/math v1.1.3-rc.1 h1:NebCNWDqb1MJRNfvxr4YY7d8FSYgkuB3L75K6xvM+Zo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
Expand Down Expand Up @@ -315,31 +314,26 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU=
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4=
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM=
github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4=
github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
Expand Down
39 changes: 39 additions & 0 deletions osmoutils/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,42 @@ func Max(values ...interface{}) interface{} {
}
return max
}

// DifferenceBetweenUint64Arrays takes two slices of uint64, 'a' and 'b', as input.
// It returns a new slice containing the elements that are unique to either 'a' or 'b'.
// The function uses two maps for efficient lookup of elements.
//
// Example:
// a := []uint64{1, 2, 3, 4, 5}
// b := []uint64{4, 5, 6, 7, 8}
// result := DifferenceBetweenUint64Arrays(a, b)
// result will be []uint64{1, 2, 3, 6, 7, 8}
//
// Note: This function does not preserve the order of the elements.
func DifferenceBetweenUint64Arrays(a, b []uint64) []uint64 {
m1 := make(map[uint64]bool)
m2 := make(map[uint64]bool)

for _, item := range a {
m1[item] = true
}

for _, item := range b {
m2[item] = true
}

var result []uint64
for item := range m1 {
if !m2[item] {
result = append(result, item)
}
}

for item := range m2 {
if !m1[item] {
result = append(result, item)
}
}

return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to sort the result before returning because map iterations are non-deterministic.

Please also make sure that unsorting is caught by tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good call, sorted the results and added both sorted and unsorted tests 3ab50f1

}
36 changes: 36 additions & 0 deletions osmoutils/compare_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package osmoutils_test

import (
"reflect"
"sort"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -38,3 +40,37 @@ func TestMax(t *testing.T) {
})
}
}

func TestDifferenceBetweenUint64Arrays(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add tests:

  • each of the inputs is empty
  • both empty
  • no overlap - returns everything
  • all overlap - returns none
  • one of unsorted
  • both are unsorted

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests extended here 56eea8d

tests := []struct {
name string
a []uint64
b []uint64
want []uint64
}{
{
name: "Test 1",
a: []uint64{1, 2, 3, 4, 5},
b: []uint64{4, 5, 6, 7, 8},
want: []uint64{1, 2, 3, 6, 7, 8},
},
{
name: "Test 2",
a: []uint64{10, 20, 30},
b: []uint64{20, 30, 40},
want: []uint64{10, 40},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := osmoutils.DifferenceBetweenUint64Arrays(tt.a, tt.b)
sort.Slice(got, func(i, j int) bool { return got[i] < got[j] })
sort.Slice(tt.want, func(i, j int) bool { return tt.want[i] < tt.want[j] })

if !reflect.DeepEqual(got, tt.want) {
t.Errorf("DifferenceBetweenUint64Arrays() = %v, want %v", got, tt.want)
}
})
}
}
10 changes: 5 additions & 5 deletions osmoutils/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/osmosis-labs/osmosis/osmoutils
go 1.20

require (
cosmossdk.io/math v1.1.3-rc.0
cosmossdk.io/math v1.1.3-rc.1
github.com/cosmos/cosmos-sdk v0.47.5
github.com/cosmos/iavl v0.19.7
github.com/cosmos/ibc-go/v4 v4.3.1
Expand Down Expand Up @@ -97,10 +97,10 @@ require (
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
Expand Down
Loading