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 16 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
14 changes: 7 additions & 7 deletions components/dashboard/explorer_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ func setupExplorerRoutes(routeGroup *echo.Group) {
routeGroup.GET("/output/:"+restapipkg.ParameterOutputID, getOutput)
// routeGroup.GET("/output/:outputID/metadata", ledgerstateAPI.GetOutputMetadata)
// routeGroup.GET("/output/:outputID/consumers", ledgerstateAPI.GetOutputConsumers)
// routeGroup.GET("/conflict/:conflictID", ledgerstateAPI.GetConflict)
// routeGroup.GET("/conflict/:conflictID/children", ledgerstateAPI.GetConflictChildren)
// routeGroup.GET("/conflict/:conflictID/conflicts", ledgerstateAPI.GetConflictConflicts)
// routeGroup.GET("/conflict/:conflictID/voters", ledgerstateAPI.GetConflictVoters)
// routeGroup.GET("/conflict/:spendID", ledgerstateAPI.GetConflict)
// routeGroup.GET("/conflict/:spendID/children", ledgerstateAPI.GetConflictChildren)
// routeGroup.GET("/conflict/:spendID/conflicts", ledgerstateAPI.GetConflictConflicts)
// routeGroup.GET("/conflict/:spendID/voters", ledgerstateAPI.GetConflictVoters)
routeGroup.GET("/slot/commitment/:"+restapipkg.ParameterCommitmentID, getSlotDetailsByID)

routeGroup.GET("/search/:search", func(c echo.Context) error {
Expand Down Expand Up @@ -172,8 +172,8 @@ func createExplorerBlock(block *model.Block, cachedBlock *blocks.Block, metadata
t.LikedInsteadChildren = lo.Map(cachedBlock.ShallowLikeChildren(), func(childBlock *blocks.Block) string {
return childBlock.ID().ToHex()
})
t.ConflictIDs = lo.Map(cachedBlock.ConflictIDs().ToSlice(), func(conflictID iotago.TransactionID) string {
return conflictID.ToHex()
t.SpendIDs = lo.Map(cachedBlock.SpendIDs().ToSlice(), func(spendID iotago.TransactionID) string {
return spendID.ToHex()
})
} else {
switch metadata.BlockState {
Expand Down Expand Up @@ -233,7 +233,7 @@ func getTransactionMetadata(c echo.Context) error {
return ierrors.Errorf("tx metadata not found: %s", txID.ToHex())
}

conflicts, _ := deps.Protocol.MainEngineInstance().Ledger.ConflictDAG().ConflictingConflicts(txID)
conflicts, _ := deps.Protocol.MainEngineInstance().Ledger.SpendDAG().ConflictingSpends(txID)

return httpserver.JSONResponse(c, http.StatusOK, NewTransactionMetadata(txMetadata, conflicts))
}
Expand Down

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 components/dashboard/jsonresponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewOutputID(outputID iotago.OutputID) *OutputID {
// OutputMetadata represents the JSON model of the mempool.OutputMetadata.
// type OutputMetadata struct {
// OutputID *OutputID `json:"outputID"`
// ConflictIDs []string `json:"conflictIDs"`
// SpendIDs []string `json:"spendIDs"`
// FirstConsumer string `json:"firstCount"`
// ConfirmedConsumer string `json:"confirmedConsumer,omitempty"`
// ConfirmationState confirmation.State `json:"confirmationState"`
Expand All @@ -102,7 +102,7 @@ func NewOutputID(outputID iotago.OutputID) *OutputID {
// func NewOutputMetadata(outputMetadata *mempool.OutputMetadata, confirmedConsumerID utxo.TransactionID) *OutputMetadata {
// return &OutputMetadata{
// OutputID: NewOutputID(outputMetadata.ID()),
// ConflictIDs: lo.Map(lo.Map(outputMetadata.ConflictIDs().Slice(), func(t utxo.TransactionID) []byte {
// SpendIDs: lo.Map(lo.Map(outputMetadata.SpendIDs().Slice(), func(t utxo.TransactionID) []byte {
// return lo.PanicOnErr(t.Bytes())
// }), base58.Encode),
// FirstConsumer: outputMetadata.FirstConsumer().Base58(),
Expand Down Expand Up @@ -234,7 +234,7 @@ func NewUnlockBlock(unlockBlock iotago.Unlock) *UnlockBlock {
// TransactionMetadata represents the JSON model of the mempool.TransactionMetadata.
type TransactionMetadata struct {
TransactionID string `json:"transactionID"`
ConflictIDs []string `json:"conflictIDs"`
SpendIDs []string `json:"spendIDs"`
Booked bool `json:"booked"`
BookedTime int64 `json:"bookedTime"`
ConfirmationState string `json:"confirmationState"`
Expand All @@ -254,7 +254,7 @@ func NewTransactionMetadata(transactionMetadata mempool.TransactionMetadata, con

return &TransactionMetadata{
TransactionID: transactionMetadata.ID().ToHex(),
ConflictIDs: func() []string {
SpendIDs: func() []string {
var strIDs []string
for _, txID := range conflicts.ToSlice() {
strIDs = append(strIDs, txID.ToHex())
Expand Down
6 changes: 3 additions & 3 deletions components/dashboard/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ type ExplorerBlock struct {
LikedInsteadChildren []string `json:"shallowLikeChildren"`
// Solid defines the solid status of the block.
Solid bool `json:"solid"`
ConflictIDs []string `json:"conflictIDs"`
AddedConflictIDs []string `json:"addedConflictIDs"`
SubtractedConflictIDs []string `json:"subtractedConflictIDs"`
SpendIDs []string `json:"spendIDs"`
AddedSpendIDs []string `json:"addedSpendIDs"`
jkrvivian marked this conversation as resolved.
Show resolved Hide resolved
SubtractedSpendIDs []string `json:"subtractedSpendIDs"`
Scheduled bool `json:"scheduled"`
Booked bool `json:"booked"`
Orphaned bool `json:"orphaned"`
Expand Down
14 changes: 7 additions & 7 deletions components/debugapi/debug_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ type (
Confirmed bool `json:"confirmed"`

Witnesses []string `json:"witnesses"`
// conflictIDs are the all conflictIDs of the block inherited from the parents + payloadConflictIDs.
ConflictIDs []iotago.TransactionID `json:"conflictIDs"`
// payloadConflictIDs are the conflictIDs of the block's payload (in case it is a transaction, otherwise empty).
PayloadConflictIDs []iotago.TransactionID `json:"payloadConflictIDs"`
String string `json:"string"`
// spendIDs are the all spendIDs of the block inherited from the parents + payloadSpendIDs.
SpendIDs []iotago.TransactionID `json:"spendIDs"`
// payloadSpendIDs are the spendIDs of the block's payload (in case it is a transaction, otherwise empty).
PayloadSpendIDs []iotago.TransactionID `json:"payloadSpendIDs"`
String string `json:"string"`
}

Validator struct {
Expand Down Expand Up @@ -82,8 +82,8 @@ func BlockMetadataResponseFromBlock(block *blocks.Block) *BlockMetadataResponse
PreConfirmed: block.IsPreConfirmed(),
Confirmed: block.IsConfirmed(),
Witnesses: lo.Map(block.Witnesses(), func(seatIndex account.SeatIndex) string { return fmt.Sprintf("%d", seatIndex) }),
ConflictIDs: block.ConflictIDs().ToSlice(),
PayloadConflictIDs: block.PayloadConflictIDs().ToSlice(),
SpendIDs: block.SpendIDs().ToSlice(),
PayloadSpendIDs: block.PayloadSpendIDs().ToSlice(),
String: block.String(),
}
}
8 changes: 4 additions & 4 deletions components/metrics/metrics_conflicts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Time since transaction issuance to the conflict acceptance"),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.ConflictDAG.ConflictAccepted.Hook(func(conflictID iotago.TransactionID) {
if txMetadata, exists := deps.Protocol.MainEngineInstance().Ledger.MemPool().TransactionMetadata(conflictID); exists {
deps.Protocol.Events.Engine.SpendDAG.SpendAccepted.Hook(func(spendID iotago.TransactionID) {
if txMetadata, exists := deps.Protocol.MainEngineInstance().Ledger.MemPool().TransactionMetadata(spendID); exists {
firstAttachmentID := txMetadata.EarliestIncludedAttachment()
if block, blockExists := deps.Protocol.MainEngineInstance().BlockFromCache(firstAttachmentID); blockExists {
timeSinceIssuance := time.Since(block.IssuingTime()).Milliseconds()
Expand All @@ -37,7 +37,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Number of resolved (accepted) conflicts"),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.ConflictDAG.ConflictAccepted.Hook(func(conflictID iotago.TransactionID) {
deps.Protocol.Events.Engine.SpendDAG.SpendAccepted.Hook(func(spendID iotago.TransactionID) {
deps.Collector.Increment(conflictNamespace, resolvedConflictCount)
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand All @@ -46,7 +46,7 @@ var ConflictMetrics = collector.NewCollection(conflictNamespace,
collector.WithType(collector.Counter),
collector.WithHelp("Number of created conflicts"),
collector.WithInitFunc(func() {
deps.Protocol.Events.Engine.ConflictDAG.ConflictCreated.Hook(func(conflictID iotago.TransactionID) {
deps.Protocol.Events.Engine.SpendDAG.SpendCreated.Hook(func(spendID iotago.TransactionID) {
deps.Collector.Increment(conflictNamespace, allConflictCounts)
}, event.WithWorkerPool(Component.WorkerPool))
}),
Expand Down
Loading
Loading