Repository: shardeum/shardeum
File: src/index.ts (TypeScript)

Code before:
        }

        const latestVersion = AccountsStorage.cachedNetworkAccount.current.latestVersion

        if (
          latestVersion &&
          appJoinData.version &&
          !isEqualOrOlderVersion(latestVersion, appJoinData.version)
        ) {
          /* prettier-ignore */ if (ShardeumFlags.VerboseLogs) console.log(`validateJoinRequest fail: version number is newer than latest`)
          return {
            success: false,
            reason: `version number is newer than latest. The latest allowed app version is ${latestVersion}. Join request node app version is ${appJoinData.version}`,
            fatal: true,
          }
        }

        const numActiveNodes = latestCycle.active
        const numTotalNodes = latestCycle.active + latestCycle.syncing // total number of nodes in the network

        // Staking is only enabled when flag is on and
        const stakingEnabled =
          ShardeumFlags.StakingEnabled && numActiveNodes >= ShardeumFlags.minActiveNodesForStaking

        //Checks for golden ticket
        if (appJoinData.adminCert?.goldenTicket === true || appJoinData.mustUseAdminCert === true) {
          const adminCert: AdminCert = appJoinData.adminCert
          /* prettier-ignore */ nestedCountersInstance.countEvent('shardeum-mode', 'validateJoinRequest: Golden ticket is enabled, node about to enter processing check')

          const currentTimestamp = Date.now()
          if (!adminCert || adminCert.certExp < currentTimestamp) {
            /* prettier-ignore */ nestedCountersInstance.countEvent('shardeum-mode', 'validateJoinRequest fail: !adminCert || adminCert.certExp < currentTimestamp')
            return {
              success: false,
              reason: 'No admin cert found in mode: ' + mode,
              fatal: false,
            }
          }
          /* prettier-ignore */ if (ShardeumFlags.VerboseLogs) console.log(`validateJoinRequest: adminCert ${Utils. safeStringify(adminCert)}`)

          // check for adminCert nominee
          const nodeAcc = data.sign.owner
          if (nodeAcc !== adminCert.nominee) {
            /* prettier-ignore */ nestedCountersInstance.countEvent('shardeum-mode', 'validateJoinRequest fail: nodeAcc !== adminCert.nominee')
            return {
              success: false,
              reason: 'Nominator mismatch',
              fatal: true,
            }
          }
          const pkClearance = shardus.getDevPublicKey(adminCert.sign.owner)

Review comment (suggestion):
We can eliminate the else section because adding the goldenTicket automatically sets the other parameter to true. However, if we retain the 2nd check and the goldenTicket is absent, the behavior remains unchanged, allowing admin cert nodes (without golden tickets) to join during processing mode.

Code after:
        }

        const latestVersion = AccountsStorage.cachedNetworkAccount.current.latestVersion

        if (
          latestVersion &&
          appJoinData.version &&
          !isEqualOrOlderVersion(latestVersion, appJoinData.version)
        ) {
          /* prettier-ignore */ if (ShardeumFlags.VerboseLogs) console.log(`validateJoinRequest fail: version number is newer than latest`)
          return {
            success: false,
            reason: `version number is newer than latest. The latest allowed app version is ${latestVersion}. Join request node app version is ${appJoinData.version}`,
            fatal: true,
          }
        }

        const numActiveNodes = latestCycle.active
        const numTotalNodes = latestCycle.active + latestCycle.syncing // total number of nodes in the network

        // Staking is only enabled when flag is on and
        const stakingEnabled =
          ShardeumFlags.StakingEnabled && numActiveNodes >= ShardeumFlags.minActiveNodesForStaking

        //Checks for golden ticket
        if (appJoinData.adminCert?.goldenTicket === true) {
          const adminCert: AdminCert = appJoinData.adminCert
          /* prettier-ignore */ nestedCountersInstance.countEvent('shardeum-mode', 'validateJoinRequest: Golden ticket is enabled, node about to enter processing check')

          const currentTimestamp = Date.now()
          if (!adminCert || adminCert.certExp < currentTimestamp) {
            /* prettier-ignore */ nestedCountersInstance.countEvent('shardeum-mode', 'validateJoinRequest fail: !adminCert || adminCert.certExp < currentTimestamp')
            return {
              success: false,
              reason: 'No admin cert found in mode: ' + mode,
              fatal: false,
            }
          }
          /* prettier-ignore */ if (ShardeumFlags.VerboseLogs) console.log(`validateJoinRequest: adminCert ${Utils. safeStringify(adminCert)}`)

          // check for adminCert nominee
          const nodeAcc = data.sign.owner
          if (nodeAcc !== adminCert.nominee) {
            /* prettier-ignore */ nestedCountersInstance.countEvent('shardeum-mode', 'validateJoinRequest fail: nodeAcc !== adminCert.nominee')
            return {
              success: false,
              reason: 'Nominator mismatch',
              fatal: true,
            }
          }
          const pkClearance = shardus.getDevPublicKey(adminCert.sign.owner)