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

Fixed account diffs #958

Merged
merged 12 commits into from
May 7, 2024
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
Loading