Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/components/Indexer/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
VersionedDDO
} from '@oceanprotocol/ddo-js'
import { checkCredentialOnAccessList } from '../../utils/credentials.js'
// import { getNonce } from '../core/utils/nonceHandler.js'
class BaseEventProcessor {
protected networkId: number

Expand Down Expand Up @@ -242,15 +243,17 @@ class BaseEventProcessor {
INDEXER_LOGGER.logMessage(
`Decrypting DDO from network: ${this.networkId} created by: ${eventCreator} encrypted by: ${decryptorURL}`
)
const nonce = Math.floor(Date.now() / 1000).toString()

const incrementedNonce = Date.now().toString()

const config = await getConfiguration()
const { keys } = config
const nodeId = keys.peerId.toString()

const wallet: ethers.Wallet = new ethers.Wallet(process.env.PRIVATE_KEY as string)

const message = String(
txId + contractAddress + keys.ethAddress + chainId.toString() + nonce
txId + contractAddress + keys.ethAddress + chainId.toString() + incrementedNonce
)
const consumerMessage = ethers.solidityPackedKeccak256(
['bytes'],
Expand All @@ -266,7 +269,7 @@ class BaseEventProcessor {
decrypterAddress: keys.ethAddress,
dataNftAddress: contractAddress,
signature,
nonce
nonce: incrementedNonce
}
const response = await axios({
method: 'post',
Expand Down Expand Up @@ -309,7 +312,7 @@ class BaseEventProcessor {
documentHash: metadataHash,
dataNftAddress: contractAddress,
signature,
nonce
nonce: incrementedNonce
}
try {
const response = await node
Expand Down Expand Up @@ -370,7 +373,7 @@ class BaseEventProcessor {
documentHash: metadataHash,
dataNftAddress: contractAddress,
signature,
nonce
nonce: incrementedNonce
}
const response = await p2pNode.sendTo(
decryptorURL,
Expand Down
6 changes: 5 additions & 1 deletion src/components/core/handler/ddoHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ export class DecryptDdoHandler extends CommandHandler {
const existingNonce = await dbNonce.retrieve(decrypterAddress)

if (existingNonce && existingNonce.nonce === nonce) {
CORE_LOGGER.logMessage(`Decrypt DDO: error ${task.nonce} duplicate nonce`, true)
CORE_LOGGER.log(
LOG_LEVELS_STR.LEVEL_ERROR,
`Decrypt DDO: duplicate nonce error decryptor addr ${decrypterAddress} nonce ${task.nonce} `,
true
)
return {
stream: null,
status: {
Expand Down
2 changes: 2 additions & 0 deletions src/components/core/utils/nonceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function getNonce(
db: AbstractNonceDatabase,
address: string
): Promise<P2PCommandResponse> {
DATABASE_LOGGER.logMessage('Retrieving nonce for address: ' + address, true)
// get nonce from db
try {
const nonceResponse = await db.retrieve(address)
Expand Down Expand Up @@ -92,6 +93,7 @@ async function updateNonce(
nonce: number
): Promise<NonceResponse> {
try {
DATABASE_LOGGER.logMessage('Updating nonce for address: ' + address, true)
// update nonce on db
// it will create if none exists yet
const resp = await db.update(address, nonce)
Expand Down
Loading