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

chore(release): merge summit2024 changes to main to make a new release #597

Merged
merged 158 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
158 commits
Select commit Hold shift + click to select a range
d6da402
Merge pull request #409 from cardano-foundation/summit-2023
cfuisat Oct 5, 2023
392ce7e
Merge pull request #412 from cardano-foundation/fix/nominee-name
jorgenavben Oct 5, 2023
aed05b8
feat: login and get votes
jimcase Aug 6, 2024
8d316bd
fix(keri-ballot-verifier): fixed docker image
rcmorano Aug 6, 2024
4385aea
fix: responsive AnimatedSwitch
jimcase Aug 7, 2024
a7876ba
Merge remote-tracking branch 'origin/feature/summit2024' into feature…
jimcase Aug 7, 2024
fbec2da
fix: responsive cookies
jimcase Aug 7, 2024
9c05014
fix: run prettier
jimcase Aug 7, 2024
59d7c7a
fix: remove onLogin prop
jimcase Aug 7, 2024
ceec0f1
fix: select category error
jimcase Aug 7, 2024
4cb1fde
feat: sign ballot and get receipt(wip)
jimcase Aug 8, 2024
981c6d5
fix: get votes
jimcase Aug 8, 2024
1d571ef
fix: auth headers and vote receipt
jimcase Aug 8, 2024
121f64f
Merge remote-tracking branch 'origin/develop' into feature/ui-updates
jimcase Aug 8, 2024
d22135a
fix: ViewReceipt prop in ReceiptHistory
jimcase Aug 8, 2024
74c8efa
fix: vote now disabled
jimcase Aug 8, 2024
813a5d3
fix: open verify wallet modal on connect wallet
jimcase Aug 9, 2024
268fa1c
fix: error after voting
jimcase Aug 9, 2024
57525ed
fix: test env vars
jimcase Aug 9, 2024
77a0544
fix: test env vars
jimcase Aug 9, 2024
55279a0
fix: index.html
jimcase Aug 9, 2024
e652e74
fix: remove debugs
jimcase Aug 9, 2024
5ecff75
fix: open verify wallet on connect
jimcase Aug 12, 2024
06ab9c8
feat: integrate vote receipts endpoint
jimcase Aug 12, 2024
c53d4f8
feat: protect ReceiptHistory page and run prettier
jimcase Aug 12, 2024
885675a
fix: total votes list background
jimcase Aug 12, 2024
1b164bd
Merge pull request #565 from cardano-foundation/feature/ui-updates
jimcase Aug 13, 2024
2ec9326
chore(gha): add events dispatcher
rcmorano Aug 13, 2024
298d04a
chore(gha): added missing id key for cf-gha-baseline step
rcmorano Aug 13, 2024
be71f63
chore(gha): dispatching triggering job
rcmorano Aug 13, 2024
8506c7c
chore(gha): remove job name while dispatching events and removed java…
rcmorano Aug 13, 2024
c554c17
chore(helm/follower-app): make cardano-node host configurable per fol…
rcmorano Aug 13, 2024
ade6442
chore(helm/follower-app): add default values for instance.yaci.cardan…
rcmorano Aug 13, 2024
4a8c419
chore(gha): separate dispatch event from builds
rcmorano Aug 13, 2024
46a0ef4
fix: default phone number
jimcase Aug 13, 2024
ca404d8
chore(gha) fix dispatch job
rcmorano Aug 13, 2024
201de1a
chore(helm/cf-cardano-ballot-voting-api): added KERI_BALLOT_VERIFIER_…
rcmorano Aug 13, 2024
24ed710
chore(helm): fix default vote-commitment app docker image name
rcmorano Aug 12, 2024
e648383
fix: include oobi when voting with Keri
jimcase Aug 14, 2024
0fa21ba
fix: run prettier
jimcase Aug 14, 2024
2003724
Merge pull request #568 from cardano-foundation/feature/ui-update
jimcase Aug 14, 2024
940ad0f
fix: debug voting
jimcase Aug 14, 2024
92239fa
chore(helm/voting-api): removed duplicated env vars
rcmorano Aug 14, 2024
29a544c
chore(user-verification): added KERI_BALLOT_VERIFIER_APP_URL
rcmorano Aug 14, 2024
013a40a
fix: connect wallet issue
jimcase Aug 19, 2024
ed42402
fix: prompt verify modal on connect
jimcase Aug 19, 2024
14ba0ae
fix: remove debugs
jimcase Aug 19, 2024
c64ab1e
fix: confirm sms code button color
jimcase Aug 20, 2024
9313b65
fix: verify with sms modal states and paths
jimcase Aug 20, 2024
dd4c99e
fix: update receipts
jimcase Aug 20, 2024
50659c6
fix: update receipts/votes redux after submit vote
jimcase Aug 22, 2024
a9d9fdc
fix: remove prompt login
jimcase Aug 23, 2024
f259f66
fix: included missing link to get tickets (#576)
jorgenavben Sep 3, 2024
5188e65
feat: shows number of total votes casted on the landing page (#578)
jorgenavben Sep 3, 2024
e7ca214
fix: UTC dates no longer change depending on timezone (#577)
jorgenavben Sep 3, 2024
402a3b4
feat: UI knows and reacts according to the event state (#575)
jorgenavben Sep 3, 2024
e40e221
UI: mapping categories (#580)
jimcase Sep 6, 2024
e638da5
fix: bio modal width in tablet
jimcase Sep 6, 2024
fc43136
fix: run prettier
jimcase Sep 6, 2024
f89a1f0
fix: Updated number of awards in preview card (#581)
jorgenavben Sep 6, 2024
76cec82
fix: select nominee card and vote
jimcase Sep 6, 2024
c669d31
fix: categoryId missing value
jimcase Sep 6, 2024
20fbd80
fix: remove char test
jimcase Sep 6, 2024
5e6c146
fix: include animation in explore section
jimcase Sep 9, 2024
f9e6857
fix: verify vote endpoint
jimcase Sep 9, 2024
89cc767
fix: leaderboard categories names
jimcase Sep 9, 2024
a39e3d4
fix: open terms from footer as a modal
jimcase Sep 9, 2024
5b7a287
fix: supported wallets modal
jimcase Sep 9, 2024
3bba387
feat: right menu
jimcase Sep 9, 2024
df902a7
fix: remove unused terms page
jimcase Sep 9, 2024
f804e10
fix: real data for winners
jimcase Sep 10, 2024
00243ff
fix: get votes after reveal
jimcase Sep 10, 2024
baedbed
fix: show winners in category
jimcase Sep 10, 2024
203fc17
fix: vote receipts data
jimcase Sep 10, 2024
d6beee7
fix: copy in receipts history
jimcase Sep 10, 2024
b052531
fix: remove debugs
jimcase Sep 10, 2024
9ae26d0
fix: vercel static images
jimcase Sep 11, 2024
31317f5
fix: bg static images
jimcase Sep 11, 2024
1c557c6
fix: vite static images
jimcase Sep 11, 2024
c476b24
fix: test bg image in prod
jimcase Sep 11, 2024
257f765
fix: clear votes on disconnect
jimcase Sep 11, 2024
a6f9ea4
feat: update cip45 message when idw
jimcase Sep 11, 2024
0f3c363
feat: handle login in categories
jimcase Sep 11, 2024
f868232
fix: nominee not selected
jimcase Sep 11, 2024
9e0c9fd
fix: hero margin top
jimcase Sep 11, 2024
7329ccf
fix: not selected nominee
jimcase Sep 11, 2024
c662be2
fix: test using alias and vite
jimcase Sep 11, 2024
875f9c7
fix: test using alias and vite
jimcase Sep 11, 2024
5fad116
fix: test replace bg with url
jimcase Sep 11, 2024
2d077ec
fix: test using backgroundImage
jimcase Sep 11, 2024
9692ebc
fix: leaderboard using backgroundImage for bg
jimcase Sep 11, 2024
0520ba0
fix: using gradient right bg
jimcase Sep 11, 2024
f7f85a4
fix: test gradient right bg in leaderboard
jimcase Sep 11, 2024
74f4d59
fix: set info-url about cip45 and run prettier
jimcase Sep 11, 2024
f4fe7c6
feat: ask for login after connecting verified wallet
jimcase Sep 12, 2024
a66f332
feat: using tooltip info
jimcase Sep 12, 2024
c73e5c9
fix: test vote receipts
jimcase Sep 12, 2024
79d117e
fix: test actions
jimcase Sep 12, 2024
20e4f18
fix: FULL status of receipt
jimcase Sep 12, 2024
53613f0
fix: FULL status of receipt not parsing
jimcase Sep 12, 2024
4c8fdfa
fix: test receipt status
jimcase Sep 12, 2024
bbcd13b
fix: receipt FINAL state
jimcase Sep 12, 2024
d94bece
fix: receipt finality state
jimcase Sep 12, 2024
00a1cbc
fix: receipt iconBottom
jimcase Sep 12, 2024
0dfde2b
fix: see results redirect to categories
jimcase Sep 12, 2024
51c4246
fix: test vote verification
jimcase Sep 12, 2024
dbe1828
fix: test vote verification
jimcase Sep 12, 2024
d4d212f
fix: receipt action
jimcase Sep 12, 2024
018685b
fix: open vote tx hash
jimcase Sep 12, 2024
9df6191
fix: error parsing publicKey
jimcase Sep 12, 2024
9ea7cd3
feat: Created the commands for running the Cardano 2024 Mainnet Event
jorgenavben Sep 16, 2024
9dcb11c
feat: replace award 3d model
jimcase Sep 17, 2024
d7960ea
fix: rename award 3d model
jimcase Sep 17, 2024
f0ae6ee
fix: category already voted
jimcase Sep 17, 2024
2744dc4
feat: leaderboard show hovered category
jimcase Sep 17, 2024
f65f35e
fix: remove 3 dots menu from Leaderboard.tsx
jimcase Sep 17, 2024
fe77a3c
feat: Event details ready for mainnet test
jorgenavben Sep 17, 2024
795ab8a
feat: Included data for the mainnet event for Ballot 2024 (#583)
jorgenavben Sep 17, 2024
6a7927b
fix: resolveWalletType support for mainnet
jimcase Sep 18, 2024
463650b
Merge remote-tracking branch 'origin/feature/ui-update' into feature/…
jimcase Sep 18, 2024
9c8d670
feat: add additionalPeerConnectTrackerUrls
jimcase Sep 18, 2024
21a8c05
chore(helm/vote-commit): add CARDANO_NODE* env vars
rcmorano Sep 18, 2024
0156cbf
chore(helm/vote-commit): fixed port quotation
rcmorano Sep 18, 2024
f458b59
fix: serialisation fix, concatenate both message and payload into res…
Sep 18, 2024
d7b5edc
fix: test backgrounds
jimcase Sep 18, 2024
706b9a2
fix: no file size limit with vite
jimcase Sep 18, 2024
52e816a
chore(gha): sync with develop
rcmorano Sep 18, 2024
5a4a05f
Merge pull request #585 from cardano-foundation/vote-serialisation-fix
rcmorano Sep 18, 2024
64b261e
fix: backgrounds and run prettier
jimcase Sep 18, 2024
d83d692
Merge pull request #571 from cardano-foundation/feature/ui-update
jimcase Sep 18, 2024
32a1d39
chore(ui): adding support for custom VITE_VERSION and setting it to g…
rcmorano Sep 18, 2024
c60f0b7
chore(ui): disable runtime VITE_VERSION
rcmorano Sep 18, 2024
b330040
chore(ui): trying to fix earthly FROM DOCKERFILE
rcmorano Sep 18, 2024
08f57f5
chore(ui): trying to fix earthly FROM DOCKERFILE
rcmorano Sep 18, 2024
624ed2f
feat(vote-commitment): added blockfrost auth header for submit api
rcmorano Sep 19, 2024
580a850
chore(helm/ui): removed flint as default wallet
rcmorano Sep 19, 2024
a196a70
chore(helm/follower): added support for local cardano-nodes
rcmorano Sep 19, 2024
096d056
chore(helm/follower): changed default cardano-node tag to main-amd64
rcmorano Sep 19, 2024
2a17ff1
chore(helm/ui): added VITE_MATOMO_PROJECT_ID support
rcmorano Sep 19, 2024
696693c
feat: matomo config (#586)
jimcase Sep 19, 2024
5931b69
chore(helm/ui): set VITE_MATOMO_PROJECT_ID to 1 so js doesn't complai…
rcmorano Sep 19, 2024
4af759d
chore(helm/vote-commitment): added support for ROLLBACK_HANDLING_ENABLED
rcmorano Sep 20, 2024
f26badf
Merge pull request #587 from cardano-foundation/feat/add-support-for-…
rcmorano Sep 22, 2024
7762d57
Fix: default matomo siteId and multiple winners (#588)
jimcase Sep 23, 2024
24af8e2
fix: disable rollback handler for good.
Sep 23, 2024
ed460d2
fix(admin-cli): add blockfrost api key for tx submission
rcmorano Sep 23, 2024
ac1c7c5
feat: aded time and name ballot 2024
jorgenavben Sep 23, 2024
5cc4c50
fix: click learn more winner (#590)
jimcase Sep 23, 2024
94585c2
feat(vote-commitment): added blockfrost auth header for submit api
rcmorano Sep 19, 2024
1321978
Merge pull request #589 from cardano-foundation/rollback-fix
rcmorano Sep 24, 2024
53eae89
Merge pull request #584 from cardano-foundation/feature/add-mainnet-e…
rcmorano Sep 25, 2024
f02fb4d
fix: missing very_high state and update vote receipt and other UI fix…
jimcase Sep 25, 2024
abe7971
fix: UI minor bugs (#592)
jimcase Sep 27, 2024
8f5fac2
Merge pull request #594 from cardano-foundation/fix/oobi-not-found
rcmorano Oct 2, 2024
fbd2380
fix: fix typo on explore section
jorgenavben Oct 3, 2024
5ff7024
Merge pull request #595 from cardano-foundation/fix/explore-section-typo
rcmorano Oct 3, 2024
57356cc
chore(gha): fix tag trigger regex
rcmorano Oct 9, 2024
58d25c2
fix: support hashed content CIP-30 data content which is typically g……
matiwinnetou Nov 6, 2024
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
34 changes: 23 additions & 11 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [ main, develop ]
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
types: [ opened, synchronize ]
workflow_dispatch:
Expand Down Expand Up @@ -53,17 +54,6 @@ jobs:
--DOCKER_REGISTRIES="${{ secrets.DOCKER_REGISTRIES }}" \
--DOCKER_IMAGES_EXTRA_TAGS="${EARTHLY_DOCKER_IMAGES_EXTRA_TAGS}"

- name: Dispatch successful build event to private repo
uses: cardano-foundation/cf-gha-workflows/./actions/cf-gha-dispatch-event@main
with:
EVENT_TYPE: "${{ github.event_name }}-${{ steps.cf-gha-baseline.outputs.TRIGGERING_REF }}-${{ steps.cf-gha-baseline.outputs.BRANCH_NAME }}"
GITHUB_TOKEN: ${{ secrets.PRIVATE_REPO_PAT }}
GITHUB_REPO: ${{ secrets.PRIVATE_REPO }}
TRIGGERING_EVENT: ${{ github.event_name }}
TRIGGERING_REF: ${{ steps.cf-gha-baseline.outputs.TRIGGERING_REF }}
TRIGGERING_BRANCH: ${{ steps.cf-gha-baseline.outputs.BRANCH_NAME }}
GIT_SHORT_COMMIT: ${{ steps.cf-gha-baseline.outputs.GIT_SHORT_COMMIT }}

ui-summit-2024:
runs-on: ${{ fromJson(vars.RUNS_ON) }}
env:
Expand All @@ -88,10 +78,31 @@ jobs:
- name: 🌍 earthly (docker build and push)
run: |
earthly +${{ env.APP_NAME }} \
--VITE_VERSION=${{ steps.cf-gha-baseline.outputs.GIT_SHORT_COMMIT }} \
--PUSH=${DOCKER_PUSH} \
--DOCKER_REGISTRIES="${{ secrets.DOCKER_REGISTRIES }}" \
--DOCKER_IMAGES_EXTRA_TAGS="${EARTHLY_DOCKER_IMAGES_EXTRA_TAGS}"

dispatch-build-success-event:
runs-on: ${{ fromJson(vars.RUNS_ON) }}
needs:
- ui-summit-2024
steps:
- name: Checkout
uses: actions/checkout@v4

- name: ⛮ cf-gha-baseline
uses: cardano-foundation/cf-gha-workflows/./actions/cf-gha-baseline@main
id: cf-gha-baseline
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRIVATE_DOCKER_REGISTRY_URL: ${{ env.PRIVATE_DOCKER_REGISTRY_URL }}
PRIVATE_DOCKER_REGISTRY_USER: ${{ env.PRIVATE_DOCKER_REGISTRY_USER }}
PRIVATE_DOCKER_REGISTRY_PASS: ${{ env.PRIVATE_DOCKER_REGISTRY_PASS }}
HUB_DOCKER_COM_USER: ${{ secrets.HUB_DOCKER_COM_USER }}
HUB_DOCKER_COM_PASS: ${{ secrets.HUB_DOCKER_COM_PASS }}
DOCKER_REGISTRIES: "${{ secrets.DOCKER_REGISTRIES }}"

- name: Dispatch successful build event to private repo
uses: cardano-foundation/cf-gha-workflows/./actions/cf-gha-dispatch-event@main
with:
Expand All @@ -101,4 +112,5 @@ jobs:
TRIGGERING_EVENT: ${{ github.event_name }}
TRIGGERING_REF: ${{ steps.cf-gha-baseline.outputs.TRIGGERING_REF }}
TRIGGERING_BRANCH: ${{ steps.cf-gha-baseline.outputs.BRANCH_NAME }}
TRIGGERING_GHRUNID: ${{ github.run_id }}
GIT_SHORT_COMMIT: ${{ steps.cf-gha-baseline.outputs.GIT_SHORT_COMMIT }}
3 changes: 2 additions & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ user-verification-service:

ui-summit-2024:
ARG EARTHLY_TARGET_NAME
ARG VITE_VERSION=0.1.0
LET DOCKER_IMAGE_NAME=${DOCKER_IMAGES_PREFIX}-${EARTHLY_TARGET_NAME}

WAIT
FROM DOCKERFILE ./ui/summit-2024
FROM DOCKERFILE --build-arg VITE_VERSION=${VITE_VERSION} ./ui/summit-2024
END
WAIT
SAVE IMAGE ${DOCKER_IMAGE_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public BlockchainTransactionSubmissionService backendServiceTransactionSubmissio
@Bean
@Profile( value = { "prod", "dev--preprod" } )
public BlockchainTransactionSubmissionService cardanoSummitTransactionSubmissionService(HttpClient httpClient,
@Value("${cardano.tx.submit.api.url}") String cardanoSubmitApiUrl) {
return new CardanoSubmitApiBlockchainTransactionSubmissionService(cardanoSubmitApiUrl, httpClient);
@Value("${cardano.tx.submit.api.url}") String cardanoSubmitApiUrl,
@Value("${blockfrost.api.key}") String blockfrostApiKey) {
return new CardanoSubmitApiBlockchainTransactionSubmissionService(cardanoSubmitApiUrl, httpClient, blockfrostApiKey);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.cardano.foundation.voting.repository.VoteRepository;
import org.cardanofoundation.cip30.CIP30Verifier;

import java.nio.ByteBuffer;
import java.util.Optional;
import java.util.function.Function;

Expand All @@ -26,12 +27,13 @@ public static Function<VoteRepository.CompactVote, byte[]> createSerialiserFunct
case KERI -> {
val message = vote.getSignature().getBytes();
val payload = vote.getPayload().map(String::getBytes).orElse(new byte[0]);
val totalLength = message.length + payload.length;

val result = new byte[message.length + payload.length];
val buffer = ByteBuffer.allocate(totalLength);
buffer.put(message);
buffer.put(payload);

System.arraycopy(message, 0, result, 0, payload.length);

yield blake2bHash256(result);
yield blake2bHash256(buffer.array());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ public class CardanoSubmitApiBlockchainTransactionSubmissionService implements B

private final HttpClient httpClient;

private final String blockfrostApiKey;

@Override
@SneakyThrows
public String submitTransaction(byte[] txData) {
var txTransactionSubmitPostRequest = HttpRequest.newBuilder()
.uri(URI.create(cardanoSubmitApiUrl))
.POST(HttpRequest.BodyPublishers.ofByteArray(txData))
.header("Content-Type", "application/cbor")
.header("project_id", blockfrostApiKey)
.build();

var r = httpClient.send(txTransactionSubmitPostRequest, HttpResponse.BodyHandlers.ofString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
package org.cardano.foundation.voting.service.yaci;

import com.bloxbean.cardano.yaci.core.model.Block;
import com.bloxbean.cardano.yaci.core.model.Era;
import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point;
import com.bloxbean.cardano.yaci.helper.BlockSync;
import com.bloxbean.cardano.yaci.helper.listener.BlockChainDataListener;
import com.bloxbean.cardano.yaci.helper.model.Transaction;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.cardano.foundation.voting.client.ChainFollowerClient;
import org.cardano.foundation.voting.domain.ChainNetwork;
import org.cardano.foundation.voting.domain.WellKnownPointWithProtocolMagic;
import org.cardano.foundation.voting.service.merkle_tree.VoteCommitmentService;
import org.cardano.foundation.voting.service.merkle_tree.VoteMerkleProofService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Optional;

@Component
@Slf4j
@ConditionalOnProperty(prefix = "rollback.handling", value = "enabled", havingValue = "true")
public class RollbackHandler {

@Value("${cardano.node.ip}")
private String cardanoNodeIp;

@Value("${cardano.node.port}")
private int cardanoNodePort;

@Autowired
private ChainNetwork chainNetwork;

@Autowired
private ChainFollowerClient chainFollowerClient;

@Autowired
private VoteMerkleProofService voteMerkleProofService;

@Autowired
private VoteCommitmentService voteCommitmentService;

@Autowired
private WellKnownPointWithProtocolMagic wellKnownPointWithProtocolMagic;

private Optional<BlockSync> blockSync = Optional.empty();

@PostConstruct
public void init() {
log.info("Starting cardano block sync on network: {}...", chainNetwork);

if (wellKnownPointWithProtocolMagic.wellKnownPointForNetwork().isEmpty()) {
log.warn("Well known point is not known. Skipping rollback handler / sync...");
return;
}

var wellKnownPoint = wellKnownPointWithProtocolMagic.wellKnownPointForNetwork().orElseThrow();

var protocolMagic = wellKnownPointWithProtocolMagic.protocolMagic();
var blockSync = startBlockSync(protocolMagic, wellKnownPoint);

this.blockSync = Optional.of(blockSync);
}

private BlockSync startBlockSync(long protocolMagic, Point wellKnownPoint) {
var blockSync = new BlockSync(cardanoNodeIp, cardanoNodePort, protocolMagic, wellKnownPoint);
blockSync.startSyncFromTip(new BlockChainDataListener() {

@Override
public void onBlock(Era era, Block block, List<Transaction> transactions) {
var headerBody = block.getHeader().getHeaderBody();

log.info("Block's slot:{}, hash:{}, blockNo:{}", headerBody.getSlot(), headerBody.getBlockHash(), headerBody.getBlockNumber());
}

@Override
public void onRollback(Point point) {
var allCommitmentWindowOpenEventsE = chainFollowerClient.findAllCommitmentWindowOpenEvents();

if (allCommitmentWindowOpenEventsE.isEmpty()) {
var issue = allCommitmentWindowOpenEventsE.swap().get();
log.warn("Failed to get eventSummaries issue: {}, will try again in some time (on next rollback)...", issue.toString());

return;
}

var allCommitmentWindowOpenEvents = allCommitmentWindowOpenEventsE.get();

if (allCommitmentWindowOpenEvents.isEmpty()) {
log.info("No commitment window open events found. Skipping rollback handler...");

return;
}

var absoluteSlot = point.getSlot();

for (var eventSummary : allCommitmentWindowOpenEvents) {
String eventId = eventSummary.id();

log.info("Processing rollback for eventId: {}, absoluteSlot: {}", eventId, absoluteSlot);

int updatedVoteProofs = voteMerkleProofService.softDeleteAllProofsAfterSlot(eventId, absoluteSlot);

log.info("Soft deleted {} vote proofs after slot: {} for eventId: {}", updatedVoteProofs, absoluteSlot, eventId);
}

}

});

return blockSync;
}

@PreDestroy
public void destroy() {
log.info("Stopping block sync...");

blockSync.ifPresent(BlockSync::stop);
}

}
//package org.cardano.foundation.voting.service.yaci;
//
//import com.bloxbean.cardano.yaci.core.model.Block;
//import com.bloxbean.cardano.yaci.core.model.Era;
//import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point;
//import com.bloxbean.cardano.yaci.helper.BlockSync;
//import com.bloxbean.cardano.yaci.helper.listener.BlockChainDataListener;
//import com.bloxbean.cardano.yaci.helper.model.Transaction;
//import jakarta.annotation.PostConstruct;
//import jakarta.annotation.PreDestroy;
//import lombok.extern.slf4j.Slf4j;
//import org.cardano.foundation.voting.client.ChainFollowerClient;
//import org.cardano.foundation.voting.domain.ChainNetwork;
//import org.cardano.foundation.voting.domain.WellKnownPointWithProtocolMagic;
//import org.cardano.foundation.voting.service.merkle_tree.VoteCommitmentService;
//import org.cardano.foundation.voting.service.merkle_tree.VoteMerkleProofService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//import java.util.Optional;
//
//@Component
//@Slf4j
//@ConditionalOnProperty(prefix = "rollback.handling", value = "enabled", havingValue = "true")
//public class RollbackHandler {
//
// @Value("${cardano.node.ip}")
// private String cardanoNodeIp;
//
// @Value("${cardano.node.port}")
// private int cardanoNodePort;
//
// @Autowired
// private ChainNetwork chainNetwork;
//
// @Autowired
// private ChainFollowerClient chainFollowerClient;
//
// @Autowired
// private VoteMerkleProofService voteMerkleProofService;
//
// @Autowired
// private VoteCommitmentService voteCommitmentService;
//
// @Autowired
// private WellKnownPointWithProtocolMagic wellKnownPointWithProtocolMagic;
//
// private Optional<BlockSync> blockSync = Optional.empty();
//
// @PostConstruct
// public void init() {
// log.info("Starting cardano block sync on network: {}...", chainNetwork);
//
// if (wellKnownPointWithProtocolMagic.wellKnownPointForNetwork().isEmpty()) {
// log.warn("Well known point is not known. Skipping rollback handler / sync...");
// return;
// }
//
// var wellKnownPoint = wellKnownPointWithProtocolMagic.wellKnownPointForNetwork().orElseThrow();
//
// var protocolMagic = wellKnownPointWithProtocolMagic.protocolMagic();
// var blockSync = startBlockSync(protocolMagic, wellKnownPoint);
//
// this.blockSync = Optional.of(blockSync);
// }
//
// private BlockSync startBlockSync(long protocolMagic, Point wellKnownPoint) {
// var blockSync = new BlockSync(cardanoNodeIp, cardanoNodePort, protocolMagic, wellKnownPoint);
// blockSync.startSyncFromTip(new BlockChainDataListener() {
//
// @Override
// public void onBlock(Era era, Block block, List<Transaction> transactions) {
// var headerBody = block.getHeader().getHeaderBody();
//
// log.info("Block's slot:{}, hash:{}, blockNo:{}", headerBody.getSlot(), headerBody.getBlockHash(), headerBody.getBlockNumber());
// }
//
// @Override
// public void onRollback(Point point) {
// var allCommitmentWindowOpenEventsE = chainFollowerClient.findAllCommitmentWindowOpenEvents();
//
// if (allCommitmentWindowOpenEventsE.isEmpty()) {
// var issue = allCommitmentWindowOpenEventsE.swap().get();
// log.warn("Failed to get eventSummaries issue: {}, will try again in some time (on next rollback)...", issue.toString());
//
// return;
// }
//
// var allCommitmentWindowOpenEvents = allCommitmentWindowOpenEventsE.get();
//
// if (allCommitmentWindowOpenEvents.isEmpty()) {
// log.info("No commitment window open events found. Skipping rollback handler...");
//
// return;
// }
//
// var absoluteSlot = point.getSlot();
//
// for (var eventSummary : allCommitmentWindowOpenEvents) {
// String eventId = eventSummary.id();
//
// log.info("Processing rollback for eventId: {}, absoluteSlot: {}", eventId, absoluteSlot);
//
// int updatedVoteProofs = voteMerkleProofService.softDeleteAllProofsAfterSlot(eventId, absoluteSlot);
//
// log.info("Soft deleted {} vote proofs after slot: {} for eventId: {}", updatedVoteProofs, absoluteSlot, eventId);
// }
//
// }
//
// });
//
// return blockSync;
// }
//
// @PreDestroy
// public void destroy() {
// log.info("Stopping block sync...");
//
// blockSync.ifPresent(BlockSync::stop);
// }
//
//}
Loading
Loading