Skip to content

State changes#1532

Closed
stefangutica wants to merge 82 commits into
developmentfrom
state-changes
Closed

State changes#1532
stefangutica wants to merge 82 commits into
developmentfrom
state-changes

Conversation

@stefangutica
Copy link
Copy Markdown
Collaborator

No description provided.

@stefangutica stefangutica marked this pull request as draft September 10, 2025 08:08
@stefangutica stefangutica marked this pull request as ready for review November 4, 2025 08:30
@bogdan-rosianu bogdan-rosianu self-requested a review November 4, 2025 08:35
imports: [ApiConfigModule],
inject: [ApiConfigService],
useFactory: (apiConfigService: ApiConfigService) => ({
uri: apiConfigService.getDatabaseUrl().replace(":27017", ''), // TODO: remove this hack
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed?

import { DeepHistoryInterceptor } from 'src/interceptors/deep-history.interceptor';
import { AccountFetchOptions } from './entities/account.fetch.options';
import { NoCache } from '@multiversx/sdk-nestjs-cache';
@Controller('')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new line

const value = parseInt(hexStr, 16);
return {
// codeMetadata: hexStr, // TODO: debugging purpose, remove for production
isGuarded: (value & GUARDED) !== 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed in prod


- run: npm ci
- run: npm run init
- run: cat src/common/indexer/entities/account.ts
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed (only used for debugging)

Comment thread config/config.devnet.yaml Outdated
chunkSize: 16384 No newline at end of file
chunkSize: 16384
pubSubListener:
enabled: true No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add empty line at the end of the file

}

isStateChangesFeatureActive(): boolean {
const isStateChangesActive = this.configService.get<boolean>('features.stateChanges.enabled');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified to

return this.configService.get<boolean>('features.stateChanges.enabled') ?? false;

}

getStateChangesUrl(): string {
const url = this.configService.get<string>('features.stateChanges.url');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should provide a better naming, such as features.stateChanges.rabbitUrl ? add a fallback to features.stateChanges.url as well

imports: [ApiConfigModule],
inject: [ApiConfigService],
useFactory: (apiConfigService: ApiConfigService) => ({
uri: apiConfigService.getDatabaseUrl().replace(":27017", ''), // TODO: remove this hack
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can keep this TODO for now, tested and working

@Query('withScrCount', ParseBoolPipe) withScrCount?: boolean,
@Query('withTimestamp', ParseBoolPipe) withTimestamp?: boolean,
@Query('withAssets', ParseBoolPipe) withAssets?: boolean,
@Query('timestamp', ParseIntPipe) _timestamp?: number,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove the timestamp parameter if we don't use it

}
}

async getAccountRaw(address: string, withAssets?: boolean): Promise<AccountDetailed | null> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function seems to duplicate the logic of the "v1" account service. Why don't we import account service v1 and simply call it? or even simpler, in the controller, if we get null or undefined from v2 service, simply call the v1 service

import { ApiProperty } from "@nestjs/swagger";
import { AccountAssets } from "src/common/assets/entities/account.assets";

export class Account {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the entities seem to be duplicates of the v1 entities. or are there differences?


@CompetingRabbitConsumer({
exchange: 'state_accesses',
queueName: 'api_state_accesses_queue-test',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a way to provide these from config? not sure if the decorator supports variables

Comment thread src/state-changes/utils/token.parser.ts Outdated
const tokenKey = tokenKeyRaw.toString();
const token = tokenKey;

const indexOfFirstHyphen = token.indexOf(this.separatorChar);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will work differently for sovereign, where we have tokens like SOV-ABC-0011aa. maybe add a TODO

})
async consumeEvents(blockWithStateChanges: BlockWithStateChangesRaw) {
try {
if (blockWithStateChanges.shardID === 4294967295) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use api config service -> getMetaChainShardId()

Comment thread config/config.devnet.yaml
enabled: false
port: 5675
url: 'amqp://guest:guest@127.0.0.1:5672'
rabbitUrl: 'amqp://guest:guest@127.0.0.1:5672'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adapt the other config files as well (mainnet, testnet, etc)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@stefangutica stefangutica force-pushed the state-changes branch 2 times, most recently from f6e2d70 to 91ea6a0 Compare November 4, 2025 13:52
@stefangutica stefangutica deleted the state-changes branch November 4, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants