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

Code before:
        // }

        //set keys for code hashes if we have them on app data
        if (appData.codeHashes != null && appData.codeHashes.length > 0) {
          //setting this may be useless seems like we never needed to do anything with codebytes in
          //getRelevantData before
          for (const codeHashObj of appData.codeHashes) {
            const shardusAddr = toShardusAddressWithKey(
              codeHashObj.contractAddress,
              codeHashObj.codeHash,
              AccountType.ContractCode
            )
            result.codeHashKeys.push(shardusAddr)
            shardusAddressToEVMAccountInfo.set(shardusAddr, {
              evmAddress: codeHashObj.codeHash,
              contractAddress: codeHashObj.contractAddress,
              type: AccountType.ContractCode,
            })
          }
        }

        // make sure the receipt address is in the get keys from transaction..
        // This will technically cause an empty account to get created but this will get overriden with the
        // correct values as a result of apply().  There are several ways we could optimize this in the future
        // If a transactions knows a key is for an account that will be created than it does not need to attempt to aquire and share the data
        const additionalAccounts = []
        if (ShardeumFlags.EVMReceiptsAsAccounts) {
          const txHash = bytesToHex(transaction.hash())
          const shardusReceiptAddress = toShardusAddressWithKey(txHash, '', AccountType.Receipt)
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          /* prettier-ignore */ if (ShardeumFlags.VerboseLogs) console.log(`getKeyFromTransaction: adding tx receipt key: ${shardusReceiptAddress} ts:${(tx as any).timestamp}`)
          additionalAccounts.push(shardusReceiptAddress)
        }

        // insert target keys first. first key in allkeys list will define the execution shard
        // for smart contract calls the contract will be the target.  For simple coin transfers it wont matter
        // insert otherAccountKeys second, because we need the CA addres at the front of the list for contract deploy
        // There wont be a target key in when we deploy a contract

        // update: looks like POQ-LS work switched source key to be first, and thus the execution group
        // center.
        // TODO ARCH-6.  as mentioned in other post we should move to an explicit key for picking the execution group
        result.allKeys = result.allKeys.concat(
          result.sourceKeys,
          result.targetKeys,
          otherAccountKeys,
          result.storageKeys,
          additionalAccounts,
          result.codeHashKeys
        )
        if (ShardeumFlags.VerboseLogs) console.log('running getKeyFromTransaction', txId, result)

Review comment (suggestion):
its seems like there is more commented code from the prev merge that did not come back.

we should bring that code back too as it is vital for smart contract support in the future.  

lmk if there is some reason it can't come back

Code after:
        //       result.storageKeys = result.storageKeys.concat(storageKeys)
        //     }
        //   }
        // }
        /***
         DO NOT REMOVE - END
         ***/

        //set keys for code hashes if we have them on app data
        if (appData.codeHashes != null && appData.codeHashes.length > 0) {
          //setting this may be useless seems like we never needed to do anything with codebytes in
          //getRelevantData before
          for (const codeHashObj of appData.codeHashes) {
            const shardusAddr = toShardusAddressWithKey(
              codeHashObj.contractAddress,
              codeHashObj.codeHash,
              AccountType.ContractCode
            )
            result.codeHashKeys.push(shardusAddr)
            shardusAddressToEVMAccountInfo.set(shardusAddr, {
              evmAddress: codeHashObj.codeHash,
              contractAddress: codeHashObj.contractAddress,
              type: AccountType.ContractCode,
            })
          }
        }

        // make sure the receipt address is in the get keys from transaction..
        // This will technically cause an empty account to get created but this will get overriden with the
        // correct values as a result of apply().  There are several ways we could optimize this in the future
        // If a transactions knows a key is for an account that will be created than it does not need to attempt to aquire and share the data
        const additionalAccounts = []
        if (ShardeumFlags.EVMReceiptsAsAccounts) {
          const txHash = bytesToHex(transaction.hash())
          const shardusReceiptAddress = toShardusAddressWithKey(txHash, '', AccountType.Receipt)
          // eslint-disable-next-line @typescript-eslint/no-explicit-any
          /* prettier-ignore */ if (ShardeumFlags.VerboseLogs) console.log(`getKeyFromTransaction: adding tx receipt key: ${shardusReceiptAddress} ts:${(tx as any).timestamp}`)
          additionalAccounts.push(shardusReceiptAddress)
        }

        // insert target keys first. first key in allkeys list will define the execution shard
        // for smart contract calls the contract will be the target.  For simple coin transfers it wont matter
        // insert otherAccountKeys second, because we need the CA addres at the front of the list for contract deploy
        // There wont be a target key in when we deploy a contract

        // update: looks like POQ-LS work switched source key to be first, and thus the execution group
        // center.
        // TODO ARCH-6.  as mentioned in other post we should move to an explicit key for picking the execution group
        result.allKeys = result.allKeys.concat(
          result.sourceKeys,
          result.targetKeys,