Skip to content

Commit

Permalink
Patch staging CN delegateOwnerWallet (#3933)
Browse files Browse the repository at this point in the history
  • Loading branch information
SidSethi committed Sep 24, 2022
1 parent d662e84 commit 36884df
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
13 changes: 13 additions & 0 deletions creator-node/src/config.js
Expand Up @@ -294,6 +294,19 @@ 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
16 changes: 15 additions & 1 deletion creator-node/src/services/URSMRegistrationManager.js
Expand Up @@ -28,6 +28,8 @@ class URSMRegistrationManager {
this.delegateOwnerWallet = nodeConfig.get('delegateOwnerWallet')
this.delegatePrivateKey = nodeConfig.get('delegatePrivateKey')
this.spOwnerWallet = nodeConfig.get('spOwnerWallet')
this.oldDelegateOwnerWallet = this.nodeConfig.get('oldDelegateOwnerWallet')
this.oldDelegatePrivateKey = this.nodeConfig.get('oldDelegatePrivateKey')

if (
!this.audiusLibs ||
Expand Down Expand Up @@ -119,7 +121,14 @@ class URSMRegistrationManager {
/**
* 2-a. Short-circuit if L2 record for node already matches L1 record (i.e. delegateOwnerWallets match)
*/
if (delegateOwnerWalletFromSPFactory === delegateOwnerWalletFromURSM) {
const activeDelegateOwnerWallet =
this.oldDelegateOwnerWallet || this.delegateOwnerWallet
this.logError(
`activeDelegateOwnerWallet: ${activeDelegateOwnerWallet.toLowerCase()} // delegateOwnerWalletFromURSM: ${delegateOwnerWalletFromURSM}`
)
if (
activeDelegateOwnerWallet.toLowerCase() === delegateOwnerWalletFromURSM
) {
// Update config
this.nodeConfig.set('isRegisteredOnURSM', true)

Expand All @@ -129,6 +138,11 @@ 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
3 changes: 2 additions & 1 deletion creator-node/src/services/initAudiusLibs.js
Expand Up @@ -33,6 +33,7 @@ module.exports = async ({
const dataRegistryAddress = config.get('dataRegistryAddress')
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 @@ -72,7 +73,7 @@ module.exports = async ({
// pass as array
[dataProviderUrl],
// TODO - formatting this private key here is not ideal
delegatePrivateKey.replace('0x', '')
(oldDelegatePrivateKey || delegatePrivateKey).replace('0x', '')
)
: null,
discoveryProviderConfig: enableDiscovery
Expand Down

0 comments on commit 36884df

Please sign in to comment.