Skip to content

Commit

Permalink
Merge pull request #958 from iotaledger/fix/account-diffs
Browse files Browse the repository at this point in the history
Fixed account diffs
  • Loading branch information
alexsporn authored May 7, 2024
2 parents 35f346b + ab8fc6e commit 014fb64
Show file tree
Hide file tree
Showing 31 changed files with 1,130 additions and 970 deletions.
2 changes: 1 addition & 1 deletion components/inx/server_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (s *Server) ReadIsValidatorAccount(_ context.Context, accountInfoRequest *i
return nil, ierrors.Wrapf(err, "error when retrieving account data for %s", accountID)
}

return inx.WrapBoolResponse(exists && account.StakeEndEpoch <= deps.Protocol.APIForSlot(slot).TimeProvider().EpochFromSlot(slot)), nil
return inx.WrapBoolResponse(exists && account.StakeEndEpoch() <= deps.Protocol.APIForSlot(slot).TimeProvider().EpochFromSlot(slot)), nil
}

func (s *Server) ReadIsCommitteeMember(_ context.Context, accountInfoRequest *inx.AccountInfoRequest) (*inx.BoolResponse, error) {
Expand Down
2 changes: 1 addition & 1 deletion components/prometheus/metrics_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var AccountMetrics = collector.NewCollection(accountNamespace,
deps.Protocol.Events.Engine.BlockGadget.BlockAccepted.Hook(func(block *blocks.Block) {
accountData, exists, _ := deps.Protocol.Engines.Main.Get().Ledger.Account(block.IssuerID(), deps.Protocol.Engines.Main.Get().SyncManager.LatestCommitment().Slot())
if exists {
deps.Collector.Update(accountNamespace, credits, float64(accountData.Credits.Value), accountData.ID.String())
deps.Collector.Update(accountNamespace, credits, float64(accountData.Credits().Value()), accountData.ID().String())
}
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand Down
5 changes: 3 additions & 2 deletions pkg/model/account_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package model

import (
"io"
"strconv"

"github.com/iotaledger/hive.go/ierrors"
"github.com/iotaledger/hive.go/lo"
Expand Down Expand Up @@ -83,8 +84,8 @@ func (d *AccountDiff) String() string {
builder.AddField(stringify.NewStructField("PreviousExpirySlot", uint32(d.PreviousExpirySlot)))
builder.AddField(stringify.NewStructField("NewOutputID", d.NewOutputID))
builder.AddField(stringify.NewStructField("PreviousOutputID", d.PreviousOutputID))
builder.AddField(stringify.NewStructField("BlockIssuerKeysAdded", d.BlockIssuerKeysAdded))
builder.AddField(stringify.NewStructField("BlockIssuerKeysRemoved", d.BlockIssuerKeysRemoved))
builder.AddField(stringify.NewStructField("BlockIssuerKeysAdded", func() string { return strconv.Itoa(d.BlockIssuerKeysAdded.Size()) }()))
builder.AddField(stringify.NewStructField("BlockIssuerKeysRemoved", func() string { return strconv.Itoa(d.BlockIssuerKeysRemoved.Size()) }()))
builder.AddField(stringify.NewStructField("ValidatorStakeChange", d.ValidatorStakeChange))
builder.AddField(stringify.NewStructField("DelegationStakeChange", d.DelegationStakeChange))
builder.AddField(stringify.NewStructField("FixedCostChange", d.FixedCostChange))
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func newCommitment(commitments *Commitments, model *model.Commitment) *Commitmen
WarpSyncBlocks: reactive.NewVariable[bool](),
BlocksToWarpSync: reactive.NewVariable[ds.Set[iotago.BlockID]](),
Weight: reactive.NewVariable[uint64](),
AttestedWeight: reactive.NewVariable[uint64](func(currentValue uint64, newValue uint64) uint64 { return max(currentValue, newValue) }), //nolint:gocritic // easier to read
AttestedWeight: reactive.NewVariable[uint64](func(currentValue uint64, newValue uint64) uint64 { return max(currentValue, newValue) }),
CumulativeWeight: reactive.NewVariable[uint64](),
CumulativeAttestedWeight: reactive.NewVariable[uint64](),
CumulativeVerifiedWeight: reactive.NewVariable[uint64](),
Expand Down
2 changes: 1 addition & 1 deletion pkg/protocol/commitment_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (c *CommitmentVerifier) verifyAttestations(attestations []*iotago.Attestati
switch signature := att.Signature.(type) {
case *iotago.Ed25519Signature:
// We found the accountData, but we don't know the public key used to sign this block/attestation. Ignore.
if !accountData.BlockIssuerKeys.Has(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey(signature.PublicKey)) {
if !accountData.BlockIssuerKeys().Has(iotago.Ed25519PublicKeyHashBlockIssuerKeyFromPublicKey(signature.PublicKey)) {
continue
}

Expand Down
Loading

0 comments on commit 014fb64

Please sign in to comment.