Skip to content

Commit

Permalink
Merge pull request #2078 from oasisprotocol/mz/removeValidatorNodeAdd…
Browse files Browse the repository at this point in the history
…ress

Use entity address to handle validators fallback
  • Loading branch information
buberdds authored Nov 5, 2024
2 parents 8871626 + 9b96cc7 commit ed76ae6
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 84 deletions.
1 change: 1 addition & 0 deletions .changelog/2078.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use entity address to handle validators fallback
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"@ledgerhq/hw-transport-webusb": "6.28.5",
"@metamask/browser-passworder": "=3.0.0",
"@metamask/jazzicon": "2.0.0",
"@oasisprotocol/client": "0.1.1-alpha.2",
"@oasisprotocol/client-rt": "0.2.1-alpha.2",
"@oasisprotocol/client": "1.1.0",
"@oasisprotocol/client-rt": "1.1.0",
"@oasisprotocol/ionic-ledger-hw-transport-ble": "6.0.0",
"@oasisprotocol/ledger": "1.0.0",
"@reduxjs/toolkit": "1.9.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('<ActiveDelegationList />', () => {
rank: 1,
status: 'active',
name: 'test-validator',
nodeAddress: 'oasis1qq7pgk9v8l3hu2aenjtflezy5vajc2cz3y4d96rj',
escrow: 1000n.toString(),
},
},
Expand Down Expand Up @@ -73,7 +72,6 @@ describe('<ActiveDelegationList />', () => {
rank: 1,
status: 'active',
name: 'test-validator1',
nodeAddress: 'oasis1qq7pgk9v8l3hu2aenjtflezy5vajc2cz3y4d96rj',
escrow: 1000n.toString(),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('<DebondingDelegationList />', () => {
rank: 1,
status: 'active',
name: 'test-validator',
nodeAddress: 'oasis1qq7pgk9v8l3hu2aenjtflezy5vajc2cz3y4d96rj',
escrow: 1000n.toString(),
},
},
Expand Down Expand Up @@ -82,7 +81,6 @@ describe('<DebondingDelegationList />', () => {
rank: 1,
status: 'active',
name: 'test-validator1',
nodeAddress: 'oasis1qq7pgk9v8l3hu2aenjtflezy5vajc2cz3y4d96rj',
escrow: 1000n.toString(),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jest.mock('@oasisprotocol/client/dist/client')

const activeValidator: Validator = {
address: 'oasis1qpc4ze5zzq3aa5mu5ttu4ku4ctp5t6x0asemymfz',
nodeAddress: 'oasis1qpwrtzadlddfuvdhjlta85268ju7dj0flsrfgg5x',
current_rate: 0.1,
rank: 0,
status: 'active',
Expand All @@ -30,7 +29,6 @@ const activeValidator: Validator = {
}
const inactiveValidator: Validator = {
address: 'oasis1qzyqaxestzlum26e2vdgvkerm6d9qgdp7gh2pxqe',
nodeAddress: 'oasis1qrdlqcv3tnv7qzuucnq0fncua52n66x7n5pm3n93',
current_rate: 0.2,
rank: 1,
status: 'inactive',
Expand All @@ -40,7 +38,6 @@ const inactiveValidator: Validator = {
}
const unknownValidator: Validator = {
address: 'oasis1qrfe9n26nq3t6vc9hlu9gnupwf4rm6wr0uglh3r7',
nodeAddress: 'oasis1qq672rjh7mldhaj35mlf4w34m8jtl9vu2c8qspkz',
current_rate: 0.2,
rank: 2,
status: 'unknown',
Expand Down
2 changes: 2 additions & 0 deletions src/app/state/staking/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ describe('Staking Sagas', () => {
}
nic.schedulerGetValidators.mockResolvedValue([
{
// oasis1qq3xrq0urs8qcffhvmhfhz4p0mu7ewc8rscnlwxe
entity_id: oasis.misc.fromHex('799b9a717cb9b37fe7a2507f137805e2fa9461dbdf3a555a6815c67d9706c0a7'),
// oasis1qrg52ccz4ts6cct2qu4retxn7kkdlusjh5pe74ar
id: oasis.misc.fromHex('91e7768ae47cd1641d6f883b97e3ea6d0286240bc3e3e2953c5c2e0dce6753a3'),
voting_power: 1,
Expand Down
8 changes: 4 additions & 4 deletions src/app/state/staking/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,17 @@ function* getFallbackValidators(network: NetworkType, errorApi: Error) {
}

// Fall back to dump_validators with refreshed validators' status from RPC
const activeNodes: { [nodeAddress: string]: true } = {}
const activeNodes: { [address: string]: true } = {}
for (const rpcValidator of rpcActiveValidators) {
const nodeAddress = yield* call(publicKeyToAddress, rpcValidator.id)
activeNodes[nodeAddress] = true
const address = yield* call(publicKeyToAddress, rpcValidator.entity_id)
activeNodes[address] = true
}
fallbackValidators = {
...fallbackValidators,
list: fallbackValidators.list.map(v => {
return {
...v,
status: activeNodes[v.nodeAddress] ? ('active' as const) : ('inactive' as const),
status: activeNodes[v.address] ? ('active' as const) : ('inactive' as const),
}
}),
}
Expand Down
1 change: 0 additions & 1 deletion src/app/state/staking/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { StringifiedBigInt } from 'types/StringifiedBigInt'
export interface Validator {
address: string
name?: string
nodeAddress: string
escrow: StringifiedBigInt
status: 'active' | 'inactive' | 'unknown'
rank: number
Expand Down
3 changes: 0 additions & 3 deletions src/vendors/__tests__/__snapshots__/monitor.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ exports[`monitor parse validators 1`] = `
"website_link": "https://s.f",
},
"name": "s",
"nodeAddress": "oasis1qrg52ccz4ts6cct2qu4retxn7kkdlusjh5pe74ar",
"rank": 1,
"status": "active",
},
Expand All @@ -255,7 +254,6 @@ exports[`monitor parse validators 1`] = `
"website_link": "https://www.b.com",
},
"name": "b",
"nodeAddress": "oasis1qqp0h2h92eev7nsxgqctvuegt8ge3vyg0qyluc4k",
"rank": 2,
"status": "inactive",
},
Expand All @@ -269,7 +267,6 @@ exports[`monitor parse validators 1`] = `
"website_link": "https://staking.fund",
},
"name": "Staking Fund",
"nodeAddress": "oasis1qq93qrvrcfl8rpjm354h5yrjcredcvt7qclumsju",
"rank": 3,
"status": "active",
},
Expand Down
3 changes: 0 additions & 3 deletions src/vendors/__tests__/__snapshots__/oasisscan.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ exports[`oasisscan parse validators 1`] = `
"website_link": "https://s.f",
},
"name": "s",
"nodeAddress": "oasis1qrg52ccz4ts6cct2qu4retxn7kkdlusjh5pe74ar",
"rank": 1,
"status": "active",
},
Expand All @@ -280,7 +279,6 @@ exports[`oasisscan parse validators 1`] = `
"website_link": "https://www.b.com",
},
"name": "b",
"nodeAddress": "oasis1qqp0h2h92eev7nsxgqctvuegt8ge3vyg0qyluc4k",
"rank": 2,
"status": "inactive",
},
Expand All @@ -295,7 +293,6 @@ exports[`oasisscan parse validators 1`] = `
"website_link": "https://staking.fund",
},
"name": "Staking Fund",
"nodeAddress": "oasis1qp0lt6y2kq8g7ffzy49acga2l8uefngz0yf9v0jk",
"rank": 3,
"status": "active",
},
Expand Down
1 change: 0 additions & 1 deletion src/vendors/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export function parseValidatorsList(validators: ValidatorRow[]): Validator[] {
const parsed: Validator = {
address: v.account_id,
name: v.account_name,
nodeAddress: v.node_id,
escrow: BigInt(v.escrow_balance).toString(),
current_rate: computeCurrentRate(v.current_epoch!, v.commission_schedule?.rates ?? []),
status: v.status,
Expand Down
1 change: 0 additions & 1 deletion src/vendors/oasisscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export function parseValidatorsList(validators: ValidatorRow[]): Validator[] {
const parsed: Validator = {
address: v.entityAddress,
name: v.name ?? undefined,
nodeAddress: v.nodeAddress,
escrow: parseRoseStringToBaseUnitString(v.escrow),
current_rate: v.commission,
status: v.status ? 'active' : 'inactive',
Expand Down
108 changes: 46 additions & 62 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1929,32 +1929,40 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@oasisprotocol/client-rt@0.2.1-alpha.2":
version "0.2.1-alpha.2"
resolved "https://registry.yarnpkg.com/@oasisprotocol/client-rt/-/client-rt-0.2.1-alpha.2.tgz#acbf9fafdbe0d68e910be3f90c33992086a567f6"
integrity sha512-BZHx4OhIg+gFCo6x/RvAPN2iLCp0OeEwQTIoCszvU8V4ZlhcNn3gHZi8mcCPC//HKuTR3awkbG8VRWfWyN7Fqg==
dependencies:
"@oasisprotocol/client" "^0.1.1-alpha.1"
deoxysii "^0.0.2"
elliptic "^6.5.3"
js-sha512 "^0.8.0"
"@oasisprotocol/client-rt@1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@oasisprotocol/client-rt/-/client-rt-1.1.0.tgz#e7e708584302ccca817264e971f5a8358384b15b"
integrity sha512-lC5KbAD+NLsZaNmEacM8HFJQ1w+C6ZGo2/zHhJJCnaGoaBoijq+LctkBe33Eq0ChuQDd6jD31FvTo8egGa1TQA==
dependencies:
"@oasisprotocol/client" "^1.1.0"
"@oasisprotocol/deoxysii" "^0.0.5"
elliptic "^6.5.5"
js-sha512 "^0.9.0"
randombytes "^2.0.1"
sha3 "^2.1.4"
tweetnacl "^1.0.3"

"@oasisprotocol/client@0.1.1-alpha.2", "@oasisprotocol/client@^0.1.1-alpha.1":
version "0.1.1-alpha.2"
resolved "https://registry.yarnpkg.com/@oasisprotocol/client/-/client-0.1.1-alpha.2.tgz#0b5807253bc138710528eeaaec0233607aec00c7"
integrity sha512-iKFOjMvBWVs7eVSd+H/wWthuYeXXCcJZ0AxX4anLu+UQvmaXUzzbGwiM1YH3XkpJsYhrIDebU/L8WUr7C21LuA==
"@oasisprotocol/[email protected].0", "@oasisprotocol/client@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@oasisprotocol/client/-/client-1.1.0.tgz#2aaec2a05323911485243d029e8adfb14a4e28ff"
integrity sha512-8zHGXCOY66NPNM5rL7hP0WjZh0a6sSfF7YttGvXbl2uMljWzu1134veiOTye4GIuKzwnyoHEHUZcoteVCWdRNQ==
dependencies:
bech32 "^2.0.0"
bip39 "^3.0.4"
cborg "^1.9.5"
grpc-web "^1.4.1"
js-sha512 "^0.8.0"
protobufjs "~7.1.2"
bip39 "^3.1.0"
cborg "^2.0.3"
grpc-web "^1.5.0"
js-sha512 "^0.9.0"
protobufjs "~7.2.6"
tweetnacl "^1.0.3"

"@oasisprotocol/deoxysii@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@oasisprotocol/deoxysii/-/deoxysii-0.0.5.tgz#82d1146e0effe9d0974ef2361461bc0be4409961"
integrity sha512-a6wYPjk8ALDIiQW/971AKOTSTY1qSdld+Y05F44gVZvlb3FOyHfgbIxXm7CZnUG1A+jK49g5SCWYP+V3/Tc75Q==
dependencies:
bsaes "0.0.2"
uint32 "^0.2.1"

"@oasisprotocol/[email protected]":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@oasisprotocol/ionic-ledger-hw-transport-ble/-/ionic-ledger-hw-transport-ble-6.0.0.tgz#39ae549397405116fb916bcc4eea06f6251b5668"
Expand Down Expand Up @@ -3922,7 +3930,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==

[email protected], bip39@^3.0.4:
[email protected], bip39@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.1.0.tgz#c55a418deaf48826a6ceb34ac55b3ee1577e18a3"
integrity sha512-c9kiwdk45Do5GL0vJMe7tS95VjCii65mYAH7DfWl3uW8AVzXKQVUm64i3hzVybBDMp9r7j9iNxR85+ul8MdN/A==
Expand Down Expand Up @@ -4164,10 +4172,10 @@ caseless@~0.12.0:
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==

cborg@^1.9.5:
version "1.10.0"
resolved "https://registry.yarnpkg.com/cborg/-/cborg-1.10.0.tgz#0fe157961dd47b537ccb84dc9ba681de8b699013"
integrity sha512-/eM0JCaL99HDHxjySNQJLaolZFVdl6VA0/hEKIoiQPcQzE5LrG5QHdml0HaBt31brgB9dNe1zMr3f8IVrpotRQ==
cborg@^2.0.3:
version "2.0.5"
resolved "https://registry.yarnpkg.com/cborg/-/cborg-2.0.5.tgz#b5393c8b1843d5c1a61f2b79b4c9f752052a4d44"
integrity sha512-xVW1rSIw1ZXbkwl2XhJ7o/jAv0vnVoQv/QlfQxV8a7V5PlA4UU/AcIiXqmpyybwNWy/GPQU1m/aBVNIWr7/T0w==

[email protected], chalk@^4.0.0, chalk@^4.1.0:
version "4.1.2"
Expand Down Expand Up @@ -4749,14 +4757,6 @@ delayed-stream@~1.0.0:
resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz"
integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk=

deoxysii@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/deoxysii/-/deoxysii-0.0.2.tgz#bfdb65ed7808a03fb88622595b5a4ba682b6778b"
integrity sha512-mMob/2wDZBatPC48g188hFt5xxrbfYMl9L+XQGOZuHPU4ScCHpAKkbZiAU1yg/kROj6nPKZp5eItuNI3LdU7vA==
dependencies:
bsaes "0.0.2"
uint32 "^0.2.1"

dequal@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be"
Expand Down Expand Up @@ -4885,10 +4885,10 @@ elementtree@^0.1.7:
dependencies:
sax "1.1.4"

elliptic@^6.5.3:
version "6.5.4"
resolved "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz"
integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==
elliptic@^6.5.5:
version "6.6.0"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.0.tgz#5919ec723286c1edf28685aa89261d4761afa210"
integrity sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==
dependencies:
bn.js "^4.11.9"
brorand "^1.1.0"
Expand Down Expand Up @@ -5926,10 +5926,10 @@ [email protected]:
markdown-to-jsx "^7.2.0"
prop-types "^15.8.1"

grpc-web@^1.4.1:
version "1.4.2"
resolved "https://registry.yarnpkg.com/grpc-web/-/grpc-web-1.4.2.tgz#86995f76471ce6b2119106ec26f909b7b69e7d43"
integrity sha512-gUxWq42l5ldaRplcKb4Pw5O4XBONWZgz3vxIIXnfIeJj8Jc3wYiq2O4c9xzx/NGbbPEej4rhI62C9eTENwLGNw==
grpc-web@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/grpc-web/-/grpc-web-1.5.0.tgz#154e4007ab59a94bf7726b87ef6c5bd8815ecf6e"
integrity sha512-y1tS3BBIoiVSzKTDF3Hm7E8hV2n7YY7pO0Uo7depfWJqKzWE+SKr0jvHNIJsJJYILQlpYShpi/DRJJMbosgDMQ==

gulp-sort@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -7041,10 +7041,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840"
integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==

js-sha512@^0.8.0:
version "0.8.0"
resolved "https://registry.npmjs.org/js-sha512/-/js-sha512-0.8.0.tgz"
integrity sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==
js-sha512@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/js-sha512/-/js-sha512-0.9.0.tgz#ed569aa1e4bdaf0b83363c29db1ab87b1192d9ae"
integrity sha512-mirki9WS/SUahm+1TbAPkqvbCiCfOAAsyXeHxK1UkullnJVVqoJG2pL9ObvT05CN+tM7fxhfYm0NbXn+1hWoZg==

"js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0:
version "4.0.0"
Expand Down Expand Up @@ -8362,7 +8362,7 @@ prop-types@^15.7.2, prop-types@^15.8.1:
object-assign "^4.1.1"
react-is "^16.13.1"

[email protected], protobufjs@~7.1.2:
[email protected], protobufjs@~7.2.6:
version "7.2.5"
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-7.2.5.tgz#45d5c57387a6d29a17aab6846dcc283f9b8e7f2d"
integrity sha512-gGXRSXvxQ7UiPgfw8gevrfRWcTlSbOFg+p/N+JVJEK5VhueL2miT6qTymqAmjr1Q5WbOCyJbyrk6JfWKwlFn6A==
Expand Down Expand Up @@ -9196,16 +9196,7 @@ string-natural-compare@^3.0.1:
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -9278,14 +9269,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down

0 comments on commit ed76ae6

Please sign in to comment.