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

Remove the alphMinConfirmations flag #77

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 4 additions & 6 deletions node/cmd/guardiand/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ var (
// solanaWsRPC *string
// solanaRPC *string

alphRPC *string
alphApiKey *string
alphMinConfirmations *uint8
alphPollInterval *uint8
alphRPC *string
alphApiKey *string
alphPollInterval *uint8

logLevel *string

Expand Down Expand Up @@ -218,7 +217,6 @@ func init() {

alphRPC = NodeCmd.Flags().String("alphRPC", "", "Alephium RPC URL (required)")
alphApiKey = NodeCmd.Flags().String("alphApiKey", "", "Alphium RPC api key")
alphMinConfirmations = NodeCmd.Flags().Uint8("alphMinConfirmations", 1, "The min confirmations for alephium tx")
alphPollInterval = NodeCmd.Flags().Uint8("alphPollInterval", 4, "The poll interval of alephium watcher")

logLevel = NodeCmd.Flags().String("logLevel", "info", "Logging level (debug, info, warn, error, dpanic, panic, fatal)")
Expand Down Expand Up @@ -690,7 +688,7 @@ func runNode(cmd *cobra.Command, args []string) {

alphWatcher, err := alephium.NewAlephiumWatcher(
*alphRPC, *alphApiKey, alphConfig, common.ReadinessAlephiumSyncing,
lockC, *alphMinConfirmations, *alphPollInterval, chainObsvReqC[vaa.ChainIDAlephium],
lockC, *alphPollInterval, chainObsvReqC[vaa.ChainIDAlephium],
)
if err != nil {
logger.Error("failed to create alephium watcher", zap.Error(err))
Expand Down
2 changes: 1 addition & 1 deletion node/pkg/alephium/reobserve.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (w *Watcher) getGovernanceEventsByTxId(

reobservedEvents = append(reobservedEvents, &reobservedEvent{
&event,
maxUint8(msg.consistencyLevel, w.minConfirmations),
msg.consistencyLevel,
Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR: how do we enforce the minimum consistencyLevel for new messages from users?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, we enforce the minimum consistency level in both frontend and contract:

  1. The frontend sets the consistencyLevel to 105 when the user sends a transaction
  2. We also check in the contract that the consistencyLevel for the transfer transaction is not less than 105

header,
txId,
})
Expand Down
11 changes: 4 additions & 7 deletions node/pkg/alephium/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ type Watcher struct {
msgChan chan *common.MessagePublication
obsvReqC chan *gossipv1.ObservationRequest

minConfirmations uint8
pollInterval uint8
currentHeight int32
pollInterval uint8
currentHeight int32

client *Client
}
Expand All @@ -92,7 +91,6 @@ func NewAlephiumWatcher(
chainConfig *common.ChainConfig,
readiness readiness.Component,
messageEvents chan *common.MessagePublication,
minConfirmations uint8,
pollInterval uint8,
obsvReqC chan *gossipv1.ObservationRequest,
) (*Watcher, error) {
Expand Down Expand Up @@ -121,8 +119,7 @@ func NewAlephiumWatcher(
msgChan: messageEvents,
obsvReqC: obsvReqC,

minConfirmations: minConfirmations,
pollInterval: pollInterval,
pollInterval: pollInterval,

client: NewClient(url, apiKey, 10),
}
Expand Down Expand Up @@ -374,7 +371,7 @@ func (w *Watcher) handleEvents_(
remain := make([]*UnconfirmedEvent, 0)
logger.Info("processing events from block", zap.String("blockHash", blockEvents.header.Hash), zap.Int("size", len(blockEvents.events)))
for _, event := range blockEvents.events {
eventConfirmations := maxUint8(event.msg.consistencyLevel, w.minConfirmations)
eventConfirmations := event.msg.consistencyLevel
if blockEvents.header.Height+int32(eventConfirmations) > height {
logger.Debug(
"event not confirmed",
Expand Down