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

CN - Fix URSM / Entity Manager short circuit logic #4005

Merged
merged 10 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 20 additions & 20 deletions creator-node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions creator-node/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,6 @@ const config = convict({
env: 'delegatePrivateKey',
default: null
},
// wallet information
oldDelegateOwnerWallet: {
doc: 'wallet address',
format: String,
env: 'oldDelegateOwnerWallet',
default: ''
},
oldDelegatePrivateKey: {
doc: 'private key string',
format: String,
env: 'oldDelegatePrivateKey',
default: ''
},
solDelegatePrivateKeyBase64: {
doc: 'Base64-encoded Solana private key created using delegatePrivateKey as the seed (auto-generated -- any input here will be overwritten)',
format: String,
Expand Down
37 changes: 20 additions & 17 deletions creator-node/src/services/URSMRegistrationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class URSMRegistrationManager {
this.nodeConfig = nodeConfig
this.audiusLibs = audiusLibs

this.delegateOwnerWallet = nodeConfig.get('delegateOwnerWallet')
this.delegateOwnerWallet = nodeConfig
.get('delegateOwnerWallet')
.toLowerCase()
this.delegatePrivateKey = nodeConfig.get('delegatePrivateKey')
this.spOwnerWallet = nodeConfig.get('spOwnerWallet')
this.oldDelegateOwnerWallet = this.nodeConfig.get('oldDelegateOwnerWallet')
this.oldDelegatePrivateKey = this.nodeConfig.get('oldDelegatePrivateKey')
this.entityManagerReplicaSetEnabled = this.nodeConfig.get(
'entityManagerReplicaSetEnabled'
)
Expand Down Expand Up @@ -112,6 +112,22 @@ class URSMRegistrationManager {
throw new Error('Failed to find valid L1 record for node')
}

if (this.delegateOwnerWallet !== delegateOwnerWalletFromSPFactory) {
jowlee marked this conversation as resolved.
Show resolved Hide resolved
throw new Error(
`Local delegateOwnerWallet config (${this.delegateOwnerWallet}) doesn't match delegateOwnerWalletFromSPFactory (${delegateOwnerWalletFromSPFactory}) for spID ${spID}`
)
}

// No further URSM checks are needed if this CN is running against Entity Manager
if (this.entityManagerReplicaSetEnabled) {
// Update config
this.nodeConfig.set('isRegisteredOnURSM', true)

this.logInfo(`When EntityManager is enabled, URSM is not applicable`)

return
}

/**
* 2. Fetch node record from L2 UserReplicaSetManager for spID
*/
Expand All @@ -124,15 +140,7 @@ class URSMRegistrationManager {
/**
* 2-a. Short-circuit if L2 record for node already matches L1 record (i.e. delegateOwnerWallets match)
*/
const activeDelegateOwnerWallet =
this.oldDelegateOwnerWallet || this.delegateOwnerWallet
this.logError(
`activeDelegateOwnerWallet: ${activeDelegateOwnerWallet.toLowerCase()} // delegateOwnerWalletFromURSM: ${delegateOwnerWalletFromURSM}`
)
if (
!this.entityManagerReplicaSetEnabled &&
activeDelegateOwnerWallet.toLowerCase() === delegateOwnerWalletFromURSM
) {
if (this.delegateOwnerWallet === delegateOwnerWalletFromURSM) {
// Update config
this.nodeConfig.set('isRegisteredOnURSM', true)

Expand All @@ -142,11 +150,6 @@ class URSMRegistrationManager {
return
}

if (this.oldDelegateOwnerWallet) {
// New node registration is disabled if using oldDelegateOwnerWallet and above URSM check failed
throw new Error('Something went wrong if we got here')
}

/**
* 3. Fetch list of all nodes registered on URSM, in order to submit requests for proposal
* a. Randomize list to minimize bias
Expand Down
4 changes: 2 additions & 2 deletions creator-node/src/services/initAudiusLibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = async ({
const entityManagerAddress = config.get('entityManagerAddress')
const dataProviderUrl = config.get('dataProviderUrl')
const delegatePrivateKey = config.get('delegatePrivateKey')
const oldDelegatePrivateKey = config.get('oldDelegatePrivateKey')

const creatorNodeIsDebug = config.get('creatorNodeIsDebug')

const discoveryProviderWhitelist = discoveryProviderWhitelistConfig
Expand Down Expand Up @@ -74,7 +74,7 @@ module.exports = async ({
// pass as array
[dataProviderUrl],
// TODO - formatting this private key here is not ideal
(oldDelegatePrivateKey || delegatePrivateKey).replace('0x', ''),
delegatePrivateKey.replace('0x', ''),
entityManagerAddress
)
: null,
Expand Down