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

fix: #96 add condition to verify if network is testnet #99

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

Sotatek-HuyLe3a
Copy link
Collaborator

@Sotatek-HuyLe3a Sotatek-HuyLe3a commented Dec 4, 2023

Root cause: misssing condition to verify a network is testnet -> reward account hex calculation is wrong when certificate is pool registraion. (BlockAggregatorServiceImpl.java)

                // Reward account
                // Workaround for bug https://github.com/input-output-hk/cardano-db-sync/issues/546
                String rewardAccountHex = poolRegistration.getPoolParams().getRewardAccount();
                byte[] rewardAccountBytes = HexUtil.decodeHexString(rewardAccountHex);
                int networkId = Constant.isTestnet(network) ? 0 : 1;
                byte header = rewardAccountBytes[0];
                if (((header & 0xff) & networkId) == 0) {
                    rewardAccountBytes[0] = (byte) ((header & ~1) | networkId);
                }
                blockDataService.saveFirstAppearedTxHashForStakeAddress(
                        HexUtil.encodeHexString(rewardAccountBytes), txHash);

@@ -28,6 +28,7 @@ public static boolean isLoveLace (byte[] data){
public static boolean isTestnet(int networkMagic) {
return networkMagic == TESTNET
Copy link
Member

Choose a reason for hiding this comment

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

@Sotatek-HuyLe3a I think we can change this logic to networkMagic != MAINNET, then it's Testnet

Copy link
Collaborator Author

@Sotatek-HuyLe3a Sotatek-HuyLe3a Dec 4, 2023

Choose a reason for hiding this comment

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

I just updated @satran004

@Sotatek-HuyLe3a Sotatek-HuyLe3a merged commit 4827629 into develop Dec 4, 2023
1 check passed
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.

2 participants