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

Store txConflicting reason correctly and rename ConflictDAG to SpendDAG #508

Merged
merged 27 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3c631d2
Remove optForkAllTransactions
jkrvivian Nov 7, 2023
4063dc2
Store conflictTx failure reason on rejected txs
jkrvivian Nov 7, 2023
f5a30c4
Rename ConflictDAG to SpendDAG
jkrvivian Nov 8, 2023
9280eb4
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 8, 2023
e01553a
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 8, 2023
02fb2f7
Hook to TransactionMetadata OnRejected to capture conflicting reason …
jkrvivian Nov 8, 2023
8561076
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 9, 2023
e6dd308
Remove TestAllWithoutForkingEverything
jkrvivian Nov 9, 2023
2500e79
Remove TestAllWithoutForkingEverything
jkrvivian Nov 9, 2023
0c78f57
Rename variable spenddag to spendDAG
jkrvivian Nov 9, 2023
2857d11
Rename conflict to spend
jkrvivian Nov 9, 2023
2e2f241
Fix resource cleanup unit test to work with forking all transactions.
piotrm50 Nov 10, 2023
e6f7360
Resolve comments
jkrvivian Nov 15, 2023
5f64dfb
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 15, 2023
c81bc25
Fix unit test
jkrvivian Nov 15, 2023
f63865c
Rename ConflictSet to SpendSet
jkrvivian Nov 20, 2023
9e667b2
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 21, 2023
aa045a2
Rename conflict to spend in dashboard frontend
jkrvivian Nov 21, 2023
311b2ef
spend -> spender
cyberphysic4l Nov 21, 2023
62e675e
fix merge errors
cyberphysic4l Nov 21, 2023
316a51e
rename files
cyberphysic4l Nov 21, 2023
357a1cd
remove broken line from spendDag test and clean up
cyberphysic4l Nov 22, 2023
71709d1
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 22, 2023
bf7c619
Remove unused Spend related frontend
jkrvivian Nov 23, 2023
07d4330
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 27, 2023
bd8b14c
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 27, 2023
34d7e00
Merge branch 'develop' into fix/conflicting-tx-reason
jkrvivian Nov 29, 2023
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

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion components/dashboard/frontend/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html> <html> <head> <meta charset="utf-8"> <title>iota-core Dashboard</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"/> </head> <body> <div id="root"></div> <script type="text/javascript" src="/app/a1e7322de4eb5154c0c3.js"></script><script type="text/javascript" src="/app/vendor.146c9687b00ba21e0070.js"></script><script type="text/javascript" src="/app/app.991aa07a823b10139416.js"></script></body> </html>
<!doctype html> <html> <head> <meta charset="utf-8"> <title>iota-core Dashboard</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"/> </head> <body> <div id="root"></div> <script type="text/javascript" src="/app/a1e7322de4eb5154c0c3.js"></script><script type="text/javascript" src="/app/vendor.146c9687b00ba21e0070.js"></script><script type="text/javascript" src="/app/app.6eea8010fee08f23aca6.js"></script></body> </html>
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ class OutputMeta extends React.Component<omProps, any> {
let pendingMana = this.props.pendingMana;
return (
<ListGroup>
ConflictIDs:
spendIDs:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Missing capital letter in Spend here and in other .tsx files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was that resolved without a comment? Because I also don't get the change...

<ListGroup>
{
metadata.conflictIDs.map((value, index) => {
metadata.spendIDs.map((value, index) => {
return (
<ListGroup.Item key={"ConflictID" + index + 1} className="text-break">
<Link to={`/explorer/conflict/${value}`}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ export class ExplorerBlockQueryResult extends React.Component<Props, any> {
Sequence Number: {blk.sequenceNumber}
</ListGroup.Item>
<ListGroup.Item>
ConflictIDs:
spendIDs:
muXxer marked this conversation as resolved.
Show resolved Hide resolved
<ListGroup>
{
blk.conflictIDs.map((value, index) => {
blk.spendIDs.map((value, index) => {
return (
<ListGroup.Item key={"ConflictID" + index + 1}
className="text-break">
Expand All @@ -141,10 +141,10 @@ export class ExplorerBlockQueryResult extends React.Component<Props, any> {
</ListGroup>
</ListGroup.Item>
<ListGroup.Item>
AddedConflictIDs:
AddedspendIDs:
<ListGroup>
{
blk.addedConflictIDs.map((value, index) => {
blk.addedSpendIDs.map((value, index) => {
return (
<ListGroup.Item key={"AddedConflictID" + index + 1}
className="text-break">
Expand All @@ -158,10 +158,10 @@ export class ExplorerBlockQueryResult extends React.Component<Props, any> {
</ListGroup>
</ListGroup.Item>
<ListGroup.Item>
SubtractedConflictIDs:
SubtractedspendIDs:
<ListGroup>
{
blk.subtractedConflictIDs.map((value, index) => {
blk.subtractedSpendIDs.map((value, index) => {
return (
<ListGroup.Item key={"SubtractedConflictID" + index + 1}
className="text-break">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class ExplorerConflictQueryResult extends React.Component<Props, any> {
</ListGroup>
</ListGroup.Item>
{<ListGroup.Item>Conflicts:
{conflict.conflictIDs && <ListGroup>
{conflict.conflictIDs.map((c,i) => <ListGroup.Item key={i}><a href={`/explorer/output/${c}`}>{c}</a></ListGroup.Item>)}
{conflict.spendIDs && <ListGroup>
{conflict.spendIDs.map((c,i) => <ListGroup.Item key={i}><a href={`/explorer/output/${c}`}>{c}</a></ListGroup.Item>)}
</ListGroup>}
</ListGroup.Item>}
<ListGroup.Item>ConfirmationState: {resolveConfirmationState(conflict.confirmationState)}</ListGroup.Item>
Expand All @@ -70,7 +70,7 @@ export class ExplorerConflictQueryResult extends React.Component<Props, any> {
{conflictConflicts.conflicts.map((c,i) => <div key={i}>
OutputID: <a href={`/explorer/output/${c.outputID.base58}`}>{c.outputID.base58}</a>
<ListGroup className={"mb-2"}>
{c.conflictIDs.map((b,j) => <ListGroup.Item key={j}>
{c.spendIDs.map((b,j) => <ListGroup.Item key={j}>
<a href={`/explorer/conflict/${b}`}>{resolveBase58ConflictID(b)}</a>
</ListGroup.Item>)}
</ListGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export class ExplorerOutputQueryResult extends React.Component<Props, any> {
{outputMetadata && <div className={"mb-2"}>
<ListGroup>
<ListGroup.Item>Transaction ID: <a href={`/explorer/transaction/${outputMetadata.outputID.transactionID}`}>{outputMetadata.outputID.transactionID}</a> </ListGroup.Item>
ConflictIDs:
spendIDs:
muXxer marked this conversation as resolved.
Show resolved Hide resolved
<ListGroup>
{
outputMetadata.conflictIDs.map((value, index) => {
outputMetadata.spendIDs.map((value, index) => {
return (
<ListGroup.Item key={"ConflictID" + index + 1} className="text-break">
<Link to={`/explorer/conflict/${value}`}>
Expand Down
20 changes: 10 additions & 10 deletions components/dashboard/frontend/src/app/stores/ExplorerStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class Block {
weakChildren: Array<string>;
shallowLikeChildren: Array<string>;
solid: boolean;
conflictIDs: Array<string>;
addedConflictIDs: Array<string>;
subtractedConflictIDs: Array<string>;
spendIDs: Array<string>;
addedSpendIDs: Array<string>;
subtractedSpendIDs: Array<string>;
scheduled: boolean;
booked: boolean;
orphaned: boolean;
Expand Down Expand Up @@ -88,7 +88,7 @@ class OutputID {

export class OutputMetadata {
outputID: OutputID;
conflictIDs: Array<string>;
spendIDs: Array<string>;
consumerCount: number;
confirmedConsumer: string // tx id of confirmed consumer
confirmationState: number
Expand All @@ -107,7 +107,7 @@ class OutputConsumers {

class TransactionMetadata {
transactionID: string;
conflictIDs: string[];
spendIDs: string[];
booked: boolean;
bookedTime: number;
confirmationState: string;
Expand All @@ -124,7 +124,7 @@ class PendingMana {
class Conflict {
id: string;
parents: Array<string>;
conflictIDs: Array<string>;
spendIDs: Array<string>;
confirmationState: number;
}

Expand All @@ -140,7 +140,7 @@ class ConflictChild {

class ConflictConflict {
outputID: OutputID;
conflictIDs: Array<string>;
spendIDs: Array<string>;
}

class ConflictConflicts {
Expand Down Expand Up @@ -411,9 +411,9 @@ export class ExplorerStore {
@action
updateBlock = (blk: Block) => {
this.blk = blk;
this.blk.conflictIDs = this.blk.conflictIDs ? this.blk.conflictIDs : []
this.blk.addedConflictIDs = this.blk.addedConflictIDs ? this.blk.addedConflictIDs : []
this.blk.subtractedConflictIDs = this.blk.subtractedConflictIDs ? this.blk.subtractedConflictIDs : []
this.blk.spendIDs = this.blk.spendIDs ? this.blk.spendIDs : []
this.blk.addedSpendIDs = this.blk.addedSpendIDs ? this.blk.addedSpendIDs : []
this.blk.subtractedSpendIDs = this.blk.subtractedSpendIDs ? this.blk.subtractedSpendIDs : []
this.blk.strongChildren = this.blk.strongChildren ? this.blk.strongChildren : []
this.blk.weakChildren = this.blk.weakChildren ? this.blk.weakChildren : []
this.blk.shallowLikeChildren = this.blk.shallowLikeChildren ? this.blk.shallowLikeChildren : []
Expand Down
8 changes: 4 additions & 4 deletions pkg/protocol/engine/mempool/spenddag/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package spenddag
import "github.com/iotaledger/hive.go/ierrors"

var (
ErrExpected = ierrors.New("expected error")
ErrAlreadyPartOfConflictSet = ierrors.New("spend already part of ConflictSet")
ErrEntityEvicted = ierrors.New("tried to operate on evicted entity")
ErrFatal = ierrors.New("fatal error")
ErrExpected = ierrors.New("expected error")
ErrAlreadyPartOfSpendSet = ierrors.New("spend already part of SpendSet")
ErrEntityEvicted = ierrors.New("tried to operate on evicted entity")
ErrFatal = ierrors.New("fatal error")
)
12 changes: 6 additions & 6 deletions pkg/protocol/engine/mempool/spenddag/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import (

// Events is a container that acts as a dictionary for the events of a SpendDAG.
type Events[SpendID, ResourceID comparable] struct {
// SpendCreated is triggered when a new Conflict is created.
// SpendCreated is triggered when a new Spend is created.
SpendCreated *event.Event1[SpendID]

// SpendEvicted is triggered when a Conflict is evicted from the SpendDAG.
// SpendEvicted is triggered when a Spend is evicted from the SpendDAG.
SpendEvicted *event.Event1[SpendID]

// ConflictingResourcesAdded is triggered when the Conflict is added to a new ConflictSet.
// ConflictingResourcesAdded is triggered when the Spend is added to a new SpendSet.
ConflictingResourcesAdded *event.Event2[SpendID, ds.Set[ResourceID]]

// SpendParentsUpdated is triggered when the parents of a Conflict are updated.
// SpendParentsUpdated is triggered when the parents of a Spend are updated.
SpendParentsUpdated *event.Event2[SpendID, ds.Set[SpendID]]

// SpendAccepted is an event that gets triggered whenever a Conflict is confirmed.
// SpendAccepted is an event that gets triggered whenever a Spend is confirmed.
SpendAccepted *event.Event1[SpendID]

// SpendRejected is an event that gets triggered whenever a Conflict is rejected.
// SpendRejected is an event that gets triggered whenever a Spend is rejected.
SpendRejected *event.Event1[SpendID]

event.Group[Events[SpendID, ResourceID], *Events[SpendID, ResourceID]]
Expand Down
4 changes: 2 additions & 2 deletions pkg/protocol/engine/mempool/spenddag/spenddag.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ type SpendDAG[SpendID, ResourceID IDType, VoteRank VoteRankType[VoteRank]] inter
AllSpendsSupported(seat account.SeatIndex, spendIDs ds.Set[SpendID]) bool
EvictSpend(spendID SpendID)

ConflictSets(spendID SpendID) (conflictSetIDs ds.Set[ResourceID], exists bool)
SpendSets(spendID SpendID) (spendSetIDs ds.Set[ResourceID], exists bool)
SpendParents(spendID SpendID) (spendIDs ds.Set[SpendID], exists bool)
ConflictSetMembers(conflictSetID ResourceID) (spendIDs ds.Set[SpendID], exists bool)
SpendSetMembers(spendSetID ResourceID) (spendIDs ds.Set[SpendID], exists bool)
SpendWeight(spendID SpendID) int64
SpendChildren(spendID SpendID) (spendIDs ds.Set[SpendID], exists bool)
SpendVoters(spendID SpendID) (voters ds.Set[account.SeatIndex])
Expand Down
72 changes: 0 additions & 72 deletions pkg/protocol/engine/mempool/spenddag/spenddagv1/conflict_set.go

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions pkg/protocol/engine/mempool/spenddag/spenddagv1/sorted_spend.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ func (s *sortedSpend[SpendID, ResourceID, VoteRank]) weightUpdateApplied() bool
}

// queuePreferredInsteadUpdate notifies the sortedSet that the preferred instead flag of the Spend was updated.
func (s *sortedSpend[SpendID, ResourceID, VoteRank]) queuePreferredInsteadUpdate(conflict *Spend[SpendID, ResourceID, VoteRank]) {
func (s *sortedSpend[SpendID, ResourceID, VoteRank]) queuePreferredInsteadUpdate(spend *Spend[SpendID, ResourceID, VoteRank]) {
s.preferredInsteadMutex.Lock()
defer s.preferredInsteadMutex.Unlock()

if (s.queuedPreferredInstead == nil && s.currentPreferredInstead == conflict) ||
(s.queuedPreferredInstead != nil && s.queuedPreferredInstead == conflict) ||
s.sortedSet.owner.Spend == conflict {
if (s.queuedPreferredInstead == nil && s.currentPreferredInstead == spend) ||
(s.queuedPreferredInstead != nil && s.queuedPreferredInstead == spend) ||
s.sortedSet.owner.Spend == spend {
return
}

s.queuedPreferredInstead = conflict
s.queuedPreferredInstead = spend
s.sortedSet.notifyPendingPreferredInsteadUpdate(s)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,14 @@ func (s *SortedSpends[SpendID, ResourceID, VoteRank]) applyWeightUpdate(member *

// fixMemberPosition fixes the position of the given member in the SortedSpends.
func (s *SortedSpends[SpendID, ResourceID, VoteRank]) fixMemberPosition(member *sortedSpend[SpendID, ResourceID, VoteRank]) {
preferredConflict := member.PreferredInstead()
preferredSpend := member.PreferredInstead()
memberIsPreferred := member.IsPreferred()

// the member needs to be moved up in the list
for currentMember := member.heavierMember; currentMember != nil && currentMember.Compare(member) == weight.Lighter; currentMember = member.heavierMember {
s.swapNeighbors(member, currentMember)

if currentMember == s.heaviestPreferredMember && (preferredConflict == currentMember.Spend || memberIsPreferred || member == s.owner) {
if currentMember == s.heaviestPreferredMember && (preferredSpend == currentMember.Spend || memberIsPreferred || member == s.owner) {
s.heaviestPreferredMember = member
s.owner.setPreferredInstead(member.Spend)
}
Expand Down
Loading
Loading