Skip to content

Commit

Permalink
Remove fixAccountUint8Arrays from the scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jairajdev committed Jul 22, 2024
1 parent 30ee7bc commit bb5d992
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
12 changes: 1 addition & 11 deletions scripts/validate_archiver_receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { overrideDefaultConfig, config } from '../src/Config'
import * as Crypto from '../src/Crypto'
import * as Utils from '../src/Utils'
import * as Receipt from '../src/dbstore/receipts'
import { AccountType, accountSpecificHash, fixAccountUint8Arrays } from '../src/shardeum/calculateAccountHash'
import { AccountType, accountSpecificHash } from '../src/shardeum/calculateAccountHash'
import { ShardeumReceipt } from '../src/shardeum/verifyAppReceiptData'

// Add the full receipt data here
Expand Down Expand Up @@ -243,16 +243,6 @@ export const verifyAccountHash = (receipt: Receipt.ArchiverReceipt): boolean =>
try {
if (receipt.globalModification && config.skipGlobalTxReceiptVerification) return true // return true if global modification
for (const account of receipt.accounts) {
if (account.data.accountType === AccountType.Account) {
fixAccountUint8Arrays(account.data.account)
// console.dir(acc, { depth: null })
} else if (
account.data.accountType === AccountType.ContractCode ||
account.data.accountType === AccountType.ContractStorage
) {
fixAccountUint8Arrays(account.data)
// console.dir(acc, { depth: null })
}
const calculatedAccountHash = accountSpecificHash(account.data)
const indexOfAccount = receipt.appliedReceipt.appliedVote.account_id.indexOf(account.accountId)
if (indexOfAccount === -1) {
Expand Down
12 changes: 1 addition & 11 deletions scripts/verify_account_hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as dbstore from '../src/dbstore'
import * as AccountDB from '../src/dbstore/accounts'
import { startSaving } from '../src/saveConsoleOutput'
import * as Logger from '../src/Logger'
import { AccountType, fixAccountUint8Arrays, accountSpecificHash } from '../src/shardeum/calculateAccountHash'
import { AccountType, accountSpecificHash } from '../src/shardeum/calculateAccountHash'
import { addSigListeners } from '../src/State'
import { Utils as StringUtils } from '@shardus/types'

Expand Down Expand Up @@ -48,16 +48,6 @@ const runProgram = async (): Promise<void> => {
if (accountHash1 !== accountHash2) {
console.log(account.accountId, 'accountHash', accountHash1, 'accountHash2', accountHash2)
}
if (account.data.accountType === AccountType.Account) {
fixAccountUint8Arrays(account.data.account)
// console.dir(acc, { depth: null })
} else if (
account.data.accountType === AccountType.ContractCode ||
account.data.accountType === AccountType.ContractStorage
) {
fixAccountUint8Arrays(account.data)
// console.dir(acc, { depth: null })
}
const calculatedAccountHash = accountSpecificHash(account.data)

if (accountHash1 !== calculatedAccountHash) {
Expand Down
8 changes: 6 additions & 2 deletions src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,17 @@ export function initSocketClient(node: NodeList.ConsensusNodeInfo): void {
if (newData.responses && newData.responses.ACCOUNT) {
if (getCurrentCycleCounter() > GENESIS_ACCOUNTS_CYCLE_RANGE.endCycle) {
Logger.mainLogger.error(
'Account data is not meant to be received after the genesis cycle',
'Account data is not meant to be received after the genesis accounts cycle range',
getCurrentCycleCounter()

Check warning

Code scanning / CodeQL

Log injection Medium

Log entry depends on a
user-provided value
.
)
unsubscribeDataSender(sender.nodeInfo.publicKey)
return
}
if (NodeList.byPublicKey.size > 1 || !NodeList.byPublicKey.has(sender.nodeInfo.publicKey)) {
if (
Cycles.currentNetworkMode !== 'forming' ||
NodeList.byPublicKey.size > 1 ||
!NodeList.byPublicKey.has(sender.nodeInfo.publicKey)
) {
Logger.mainLogger.error(
'Account data is not meant to be received by the first validator',
`Number of nodes in the network ${NodeList.byPublicKey.size}`
Expand Down

0 comments on commit bb5d992

Please sign in to comment.