Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BigSuggestion and Get validation fix for v6 #3559

Merged
merged 7 commits into from
Dec 19, 2024
Merged
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "8.0.0-sigma.5",
"version": "8.0.0-sigma.6",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down
23 changes: 0 additions & 23 deletions src/commands/common/validate-asset-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ERROR_TYPE,
OPERATION_ID_STATUS,
LOCAL_STORE_TYPES,
ZERO_BYTES32,
PARANET_ACCESS_POLICY,
} from '../../constants/constants.js';

Expand Down Expand Up @@ -39,35 +38,13 @@ class ValidateAssetCommand extends Command {
OPERATION_ID_STATUS.VALIDATE_ASSET_START,
);

const blockchainAssertionId =
await this.blockchainModuleManager.getKnowledgeCollectionLatestMerkleRoot(
blockchain,
contract,
tokenId,
);
if (!blockchainAssertionId || blockchainAssertionId === ZERO_BYTES32) {
return Command.retry();
}
// TODO: Validate number of triplets and other stuff we did before so it matches like we did it in v6
const cachedData = await this.operationIdService.getCachedOperationIdData(operationId);
const ual = this.ualService.deriveUAL(blockchain, contract, tokenId);

// backwards compatibility
const cachedAssertion = cachedData.datasetRoot || cachedData.public.assertionId;
const cachedDataset = cachedData.dataset || cachedData.public.assertion;
this.logger.info(
`Validating asset's public assertion with id: ${cachedAssertion} ual: ${ual}`,
);
if (blockchainAssertionId !== cachedAssertion) {
await this.handleError(
operationId,
blockchain,
`Invalid assertion id for asset ${ual}. Received value from blockchain: ${blockchainAssertionId}, received value from request: ${cachedData.public.assertionId}`,
this.errorType,
true,
);
return Command.empty();
}

// V0 backwards compatibility
if (cachedData.private?.assertionId && cachedData.private?.assertion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ class GetValidateAssetCommand extends ValidateAssetCommand {
);
// TODO: Update to validate knowledge asset index
const isValidUal = isOperationV0
? await this.validationService.validateUalV6(
blockchain,
contract,
knowledgeCollectionId,
)
? true
: await this.validationService.validateUal(blockchain, contract, knowledgeCollectionId);
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.GET.GET_VALIDATE_UAL_END,
Expand Down
1 change: 1 addition & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export const ABIs = {
ShardingTableStorage: require('dkg-evm-module/abi/ShardingTableStorage.json'),
ParanetsRegistry: require('dkg-evm-module/abi/ParanetsRegistry.json'),
ParanetKnowledgeAssetsRegistry: require('dkg-evm-module/abi/ParanetKnowledgeAssetsRegistry.json'),
Ask: require('dkg-evm-module/abi/Ask.json'),
};

export const CONTRACT_FUNCTION_PRIORITY = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ class BidSuggestionController extends BaseController {

async handleRequest(req, res) {
try {
const { blockchain, epochsNumber, assertionSize } = req.body;
const bidSuggestion =
(await this.blockchainModuleManager.getStakeWeightedAverageAsk(blockchain)) *
epochsNumber *
assertionSize;
this.returnResponse(res, 200, { bidSuggestion });
const { blockchain, epochsNumber, assertionSize } = req.query;
const bidSuggestion = (
await this.blockchainModuleManager.getStakeWeightedAverageAsk(blockchain)
)
.mul(epochsNumber)
.mul(assertionSize);
const bidSuggestionString = bidSuggestion.toString();
this.returnResponse(res, 200, { bidSuggestion: bidSuggestionString });
} catch (error) {
this.logger.error(`Unable to get bid suggestion. Error: ${error}`);
this.returnResponse(res, 500, {
Expand Down
Loading