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

Epoch commitment metrics #2293

Merged
merged 304 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
304 commits
Select commit Hold shift + click to select a range
51d6a07
Finish loading snapshot
georgysavva Jun 2, 2022
90a6d65
Update Commitment Factory after state root changes
daria305 Jun 2, 2022
296d4b5
Add indexes from the snapshot
georgysavva Jun 2, 2022
0a58681
Merge branch 'feat/epoch-commitment' into feat/notarization-snapshot-…
georgysavva Jun 2, 2022
159f62a
Delete old code
georgysavva Jun 2, 2022
bbe799b
New types
karimodm Jun 2, 2022
df6e090
Move types from notarization to the new epoch package
georgysavva Jun 2, 2022
79c4ad8
Add ec models and storage
georgysavva Jun 2, 2022
cff1bca
Separate commitment from commitment trees
daria305 Jun 2, 2022
474214b
Merge remote-tracking branch 'origin/feat/epoch-commitment' into feat…
daria305 Jun 2, 2022
9664e84
Fix EI refs
daria305 Jun 2, 2022
1bc8c75
More epochs
karimodm Jun 2, 2022
89de972
Add notarization event (#2239)
jkrvivian Jun 3, 2022
e4a9475
Refactor and small fixes for notarization manager
daria305 Jun 3, 2022
17ce13e
Refactor and small fixes for commitment factory
daria305 Jun 3, 2022
f812013
Fix plugin dependencies errors
daria305 Jun 3, 2022
a2b4f8b
Handle message orphaned event in the notarization manager.
georgysavva Jun 3, 2022
acb4180
Change diff storage and update it on tx confirmation
daria305 Jun 3, 2022
832ee21
Merge remote-tracking branch 'origin/feat/epoch-commitment' into feat…
daria305 Jun 3, 2022
cd2ae61
Fix snapshot errors after diff store changes
daria305 Jun 3, 2022
db7b3ee
Merge branch 'feat/epoch-commitment' of github.com:iotaledger/goshimm…
karimodm Jun 7, 2022
dc98c0f
types fixes and storage
karimodm Jun 7, 2022
aeff4d9
Revert GetLatestEC
karimodm Jun 7, 2022
d2a666d
Feat: Avoid storing transient UTXOs in epoch diffs #2251
karimodm Jun 7, 2022
2b259cc
Small fixes
karimodm Jun 7, 2022
b191500
Feat: some structures lifecycle
karimodm Jun 7, 2022
fbef94f
Better storage
karimodm Jun 8, 2022
a6dd203
Update the structure
daria305 Jun 8, 2022
cceb0b5
Merge branch 'feat/epoch-commitment' into feat/update-ec-structure
daria305 Jun 8, 2022
fccd6ec
Move epoch package inside ledger. Change OutputMetadata and EpochDiff…
georgysavva Jun 8, 2022
4a7837f
Feat: structures lifecycle
karimodm Jun 8, 2022
b6b7985
Feat: proper getters and setters for storables
karimodm Jun 8, 2022
947d77f
Add TODOs
karimodm Jun 8, 2022
08588d9
Merge branch 'feat/epoch-commitment' into feat/update-ec-structure
daria305 Jun 8, 2022
b25558f
Merge remote-tracking branch 'origin/develop' into feat/epoch-commitment
karimodm Jun 8, 2022
87f9a51
Fix: using new models after merge
karimodm Jun 8, 2022
da505cd
Fix: no compile errors
karimodm Jun 8, 2022
bb51d3e
Fix: storage nil pointer dereference
karimodm Jun 8, 2022
fc8307d
Add commitments progressing when delayed
daria305 Jun 9, 2022
42ffd22
Merge branch 'feat/epoch-commitment' into feat/update-ec-structure
daria305 Jun 9, 2022
6b0cf8a
Add comments to exported methods
jkrvivian Jun 9, 2022
cd1e8b5
Only have one MinMana threshold
karimodm Jun 9, 2022
079a005
Merge branch 'feat/epoch-commitment' of github.com:iotaledger/goshimm…
karimodm Jun 9, 2022
4380699
Change load snapshot logic for mana
georgysavva Jun 9, 2022
c51273d
Make epoch indeces persistent
karimodm Jun 9, 2022
39df69f
Add mana state root
daria305 Jun 9, 2022
3990932
Remove ecc
daria305 Jun 9, 2022
a5e12de
Use CachedECRecord
karimodm Jun 9, 2022
928d349
Merge branch 'feat/epoch-commitment' into feat/add-mana-root
daria305 Jun 9, 2022
f43fb1b
Merge branch 'feat/epoch-commitment' into snapshot-mana-epochs
georgysavva Jun 9, 2022
37ce2a5
Fix merge conflicts
georgysavva Jun 9, 2022
a3bb2f3
Fic EpochDiff definition
georgysavva Jun 9, 2022
3e73aff
Remove mana leaf if balance is 0
daria305 Jun 9, 2022
8ebc0b3
Remove EpochCommitment struct & code duplication
karimodm Jun 9, 2022
a6ae03c
Store latest ECRecord from snapshot
karimodm Jun 9, 2022
07321b7
Merge branch 'feat/epoch-commitment' into snapshot-mana-epochs-genera…
karimodm Jun 9, 2022
22da58f
Update packages/ledger/models.go
georgysavva Jun 9, 2022
7688260
EpochDiff now in ledger package to avoid cycles
karimodm Jun 9, 2022
df6971e
Merge branch 'snapshot-mana-epochs' of github.com:iotaledger/goshimme…
karimodm Jun 9, 2022
3825f8e
Genesis Snapshot Generation
karimodm Jun 9, 2022
840e65f
Merge branch 'feat/epoch-commitment' into feat/add-mana-root
daria305 Jun 9, 2022
d232ebd
AccessMana is now Mana1
karimodm Jun 9, 2022
42d174a
Remove references to --mana.snapshotResetTime=true
karimodm Jun 9, 2022
d546f29
Merge branch 'snapshot-mana-epochs' into feat/accessmana-mana1
karimodm Jun 9, 2022
03e9614
Remove references to --mana.snapshotResetTime=true
karimodm Jun 9, 2022
cda189a
Merge branch 'feat/accessmana-mana1' into feat/snapshot-mana-epochs-g…
karimodm Jun 9, 2022
090d5db
Fix some issues
karimodm Jun 9, 2022
fe263fb
Merge branch 'feat/epoch-commitment' into test-commitment
karimodm Jun 9, 2022
c12ebd6
Review fixes
georgysavva Jun 10, 2022
25beea7
Merge branch 'feat/epoch-commitment' into snapshot-mana-epochs
georgysavva Jun 10, 2022
0f65c0f
Genesis Snapshot Generation (#2266)
karimodm Jun 10, 2022
efdad0f
Remove OracleEpochShift
karimodm Jun 10, 2022
8247123
Fix: always initialize trees on new epoch
karimodm Jun 10, 2022
771763f
Working committments in messages
karimodm Jun 10, 2022
5ebe2e3
AccessMana is now Mana1 (#2267)
karimodm Jun 10, 2022
3a4a766
Add EC related variables to test framework
jkrvivian Jun 10, 2022
f4db46e
Add event mock structure for notarization manager
jkrvivian Jun 10, 2022
5dacd0e
Implement Tangle smt Tree test
jkrvivian Jun 10, 2022
0297231
EpochCommittment in dashboard
karimodm Jun 10, 2022
212cc2e
ECs finally in Messages
karimodm Jun 10, 2022
b56895c
Fixed dashboard LatestConfirmedEpoch glitch
karimodm Jun 10, 2022
938c22f
Fix: correctly compute PrevEC
karimodm Jun 10, 2022
96cc07c
Feat: include computed EC in dashboard
karimodm Jun 10, 2022
862dfae
Remove debugging prints
karimodm Jun 10, 2022
55bd58f
Merge branch 'feat/epoch-commitment' into test/notarization-manager
jkrvivian Jun 10, 2022
0ecbc6c
Update initialize with data method
georgysavva Jun 10, 2022
fe8023d
Snapshot
georgysavva Jun 10, 2022
87bf63a
Merge branch 'feat/epoch-commitment' into snapshot-mana-epochs
georgysavva Jun 10, 2022
832396f
Fix after merge
georgysavva Jun 10, 2022
bc7903c
Revert "Remove debugging prints"
karimodm Jun 10, 2022
dd0769c
Bump hive.go
karimodm Jun 11, 2022
25ddcf6
Several fixes
karimodm Jun 11, 2022
62d910c
Create snapshot in createGenesisOutputs
jkrvivian Jun 13, 2022
0ad47b9
Load snapshot and fix test
jkrvivian Jun 13, 2022
7e95967
Set up Tangle and issue messages
jkrvivian Jun 13, 2022
90b99f1
Fixes
jkrvivian Jun 13, 2022
b53e5b7
Fix a bunch of things
karimodm Jun 13, 2022
0c0111f
Merge pull request #2265 from iotaledger/snapshot-mana-epochs
karimodm Jun 13, 2022
120f372
Temporary Fix: epochdiff loading
karimodm Jun 13, 2022
0d702ab
Bypass finality gadget
jkrvivian Jun 14, 2022
2ff623e
Merge branch 'feat/epoch-commitment' into feat/add-mana-root
daria305 Jun 14, 2022
4c789b9
Fixes after merge
daria305 Jun 14, 2022
ad1dba2
Split EpochDiff storage & several fixes
karimodm Jun 14, 2022
946dfeb
Move store and load diff functions back to commitment factory
karimodm Jun 14, 2022
3fa3930
Update mana trees
daria305 Jun 15, 2022
6d1c636
Solve Update diff storage on inclusion todo
daria305 Jun 15, 2022
fff3aa5
Update diff on the message orphaned event if contain tx
daria305 Jun 15, 2022
2b999ac
Fix epochdiff storage
karimodm Jun 15, 2022
4f87ff4
Remove OnTransactionConfirmed in favor of OnTransactionInclusionUpdated
karimodm Jun 15, 2022
e6a8c0c
Merge remote-tracking branch 'origin/feat/add-mana-root' into feat/sp…
karimodm Jun 15, 2022
1c8f4d1
Rewrite test with TestScenario
jkrvivian Jun 15, 2022
c48bd04
Check CommitmentFunc error and committed epoch EI
jkrvivian Jun 16, 2022
d2ae82f
Start implementing epoch commitments metrics
georgysavva Jun 16, 2022
d75d3c2
Working epoch committments with ManaRoot
karimodm Jun 16, 2022
a503124
Move proof stuff to its own file
karimodm Jun 16, 2022
bcbbede
Save and serve epoch commitment related metrics
georgysavva Jun 17, 2022
196c418
Add state mutation and PCC tests
jkrvivian Jun 17, 2022
de0401b
Change mutation state test to non-conflicting txs scenario
jkrvivian Jun 17, 2022
2e6b32c
Add debug prints
jkrvivian Jun 17, 2022
db0f244
Remove some TODOs
karimodm Jun 17, 2022
fed2388
Addressed review
karimodm Jun 17, 2022
22c6260
Merge pull request #2291 from iotaledger/feat/split-epochdiff-storage
karimodm Jun 17, 2022
bb2b617
Fix: typos
karimodm Jun 17, 2022
a7e8b71
SnapshotDepth as notarization parameter
karimodm Jun 17, 2022
310fec2
Wire events from within notarization Manager
karimodm Jun 17, 2022
b13f3a0
Fix: do not shutdown Tangle twice
karimodm Jun 17, 2022
e4d4a88
Fix: removed unused mana snapshot
karimodm Jun 17, 2022
092951c
Dockerfile support go.work
karimodm Jun 17, 2022
2c1257e
Fix snapshot mana allocation for integration tests
karimodm Jun 17, 2022
d363d9e
Fix: mana test
karimodm Jun 17, 2022
180afbd
Merge branch 'feat/epoch-commitment' into test/notarization-manager
jkrvivian Jun 17, 2022
f86be7e
Fix Tangle tree test
jkrvivian Jun 20, 2022
43d2dbc
Use storage for epoch metrics
georgysavva Jun 20, 2022
e879c9f
Initialize ECRecord in new options
jkrvivian Jun 20, 2022
643fe73
Update State Mutation test to the latest changes
jkrvivian Jun 20, 2022
cd9ab89
Remove OnTransactionConfirmed
jkrvivian Jun 20, 2022
a3eb794
Fix some race conditions
karimodm Jun 20, 2022
d4f847f
Small improvement
karimodm Jun 20, 2022
ef266e8
Fix conflict Transaction Inclusion
karimodm Jun 20, 2022
9230360
Fix storage shutdown
karimodm Jun 20, 2022
953be01
Merge remote-tracking branch 'origin/develop' into fix/integration-tests
karimodm Jun 20, 2022
638c5ce
Fix common tests
karimodm Jun 20, 2022
a298075
Fix missing mana leaf startup error
karimodm Jun 20, 2022
72b4b13
Removed debugging prints
karimodm Jun 20, 2022
37cfcdf
Exported functions first
karimodm Jun 20, 2022
567182b
Fix: attachment might not be booked yet on BranchCreated
karimodm Jun 20, 2022
c7fe27c
Check if commitment tree exists before generating a proof
jkrvivian Jun 21, 2022
30ad96b
Implement proper API endpoints for epoch metrics
georgysavva Jun 21, 2022
d04b9b1
Merge branch 'feat/epoch-commitment' into feat/ec-chain-display
georgysavva Jun 21, 2022
6f03306
Fix after merge
georgysavva Jun 21, 2022
641a08e
Fix snapshot creation in TestFramework
karimodm Jun 21, 2022
523d209
Epoch Commitments: fix bugs & integration tests #2297 from iotaledger…
karimodm Jun 21, 2022
58c6832
Merge remote-tracking branch 'origin/feat/epoch-commitment' into feat…
karimodm Jun 21, 2022
7fb2a8b
Merge remote-tracking branch 'origin/develop' into feat/merge-base-de…
karimodm Jun 21, 2022
7e68d36
Merge remote-tracking branch 'origin/test/notarization-manager' into …
karimodm Jun 21, 2022
27e904d
Fixes after merge
karimodm Jun 21, 2022
65f0dac
Merge remote-tracking branch 'origin/feat/epoch-commitment' into test…
karimodm Jun 21, 2022
056c62e
Fixes after merge
karimodm Jun 21, 2022
e83929f
Verify root and msgID/txID
jkrvivian Jun 21, 2022
ec1c29f
pkged.go
karimodm Jun 21, 2022
71d3d29
Disable notarization plugin on entrynode
karimodm Jun 21, 2022
01b885e
Review fixes
georgysavva Jun 22, 2022
bdd9b9b
Fix and add conflicting test
jkrvivian Jun 22, 2022
1308457
Use notarization manager direct to report UTXOs, Messages, and Transa…
georgysavva Jun 23, 2022
20675b4
Merge branch 'feat/epoch-commitment' into feat/ec-chain-display
georgysavva Jun 23, 2022
4b2ab2e
Fix after merge
georgysavva Jun 23, 2022
1ed2211
Only treat Notarization events when node is bootstrapped
karimodm Jun 23, 2022
785e16c
Initialize aMana from snapshot without epoch delay
karimodm Jun 23, 2022
ce9eac1
Remove EpochManager as it is completely stateless
karimodm Jun 23, 2022
c0e9e86
Properly return or panic when error conditions are detected
karimodm Jun 23, 2022
f8bb143
Drop committmentTrees upon committing an epoch
karimodm Jun 23, 2022
14d1b5a
Refactor testing framework set-up
jkrvivian Jun 24, 2022
2500836
Refactor assert functions
jkrvivian Jun 24, 2022
47d4b0a
Remove proofs code
karimodm Jun 24, 2022
fac32ec
Merge pull request #2310 from iotaledger/feat/epoch-commitment-fixes
karimodm Jun 24, 2022
35d873a
Merge remote-tracking branch 'origin/feat/epoch-commitment' into feat…
karimodm Jun 24, 2022
40c041e
Merge pull request #2309 from iotaledger/feat/move-epochmanager-to-epoch
karimodm Jun 24, 2022
33ebc9e
Ditch TestScenario in testing
jkrvivian Jun 24, 2022
b774ba3
Merge branch 'feat/merge-develop-into-epochs' into feat/epoch-commitment
karimodm Jun 24, 2022
3292b58
Merge remote-tracking branch 'origin/develop' into feat/epoch-commitment
karimodm Jun 24, 2022
e95dcdb
Merge pull request #2304 from iotaledger/feat/epoch-commitment-only-w…
karimodm Jun 24, 2022
6b03bb7
Only trigger EpochCommitted if newly committed
karimodm Jun 24, 2022
a34277d
WIP: TestManager_DiffUTXOs
karimodm Jun 24, 2022
5e26bf3
Merge branch 'feat/epoch-commitment' into feat/ec-chain-display
georgysavva Jun 24, 2022
90f221c
Store epoch content in storage
georgysavva Jun 24, 2022
a8facd2
Fix after merge
georgysavva Jun 24, 2022
42ace0b
Fix after merge
georgysavva Jun 24, 2022
16d6cd8
Add TransactionInclusionUpdate test
jkrvivian Jun 24, 2022
64e3f04
Add assert diff store function
jkrvivian Jun 25, 2022
bd65e4e
Fix OutputWithMetadata model FromObjectStorage
karimodm Jun 26, 2022
16bd789
Merge branch 'test/notarization-manager' of github.com:iotaledger/gos…
karimodm Jun 26, 2022
73370ef
Fix: properly compact spent/created diff
karimodm Jun 26, 2022
5527fe7
Fix: async diffStorage shutdown in goroutine
karimodm Jun 26, 2022
ea76c9d
DiffUTXO test with reattachment
karimodm Jun 26, 2022
b094f02
Fix: isNew ecRecord
karimodm Jun 26, 2022
e32d180
DiffUTXO test with event expectation
karimodm Jun 26, 2022
da8bc45
Fix all notarization manager tests
karimodm Jun 26, 2022
31dee3f
OutputWithMetadata FromBytes with correct IDs
karimodm Jun 27, 2022
8f5d647
Merge remote-tracking branch 'origin/feat/epoch-commitment' into test…
karimodm Jun 27, 2022
0b21d7a
Some fixes after merge
karimodm Jun 27, 2022
6d30ad2
Compiles again
karimodm Jun 27, 2022
82ece8d
notarization tests passing
karimodm Jun 27, 2022
4b84f2b
Fix all the things!
karimodm Jun 27, 2022
373e7ba
Fix Genesis snapshot loading with epoch 0
karimodm Jun 27, 2022
7b409cc
Remove --mana.snapshotResetTime=true from docker network compose
karimodm Jun 27, 2022
b5bffa0
Update packages/epoch/types.go
karimodm Jun 27, 2022
9e9180c
Address review
karimodm Jun 27, 2022
36b11ab
Merge branch 'test/notarization-manager' of github.com:iotaledger/gos…
karimodm Jun 27, 2022
2287d1e
Fix: always check inclusionTime before triggering TransactionConfirme…
karimodm Jun 28, 2022
db3c51d
More fixes to bugs and tests
karimodm Jun 28, 2022
796e69e
Fix all tests
karimodm Jun 28, 2022
754b332
Remove prints
karimodm Jun 28, 2022
16f0d20
Revert "Fix: always check inclusionTime before triggering Transaction…
karimodm Jun 28, 2022
34f35ee
txMeta.InclusionTime().IsZero() guard in OnTransactionConfirmed
karimodm Jun 28, 2022
1cce33e
Fix other unit tests
karimodm Jun 28, 2022
20981f4
Remove content storage from notarization manager
jkrvivian Jun 29, 2022
c54b2b1
Add events to track changes in trees and diff stores
jkrvivian Jun 29, 2022
04eae67
Fix TransactionConfirmed w/ InclusionTime
karimodm Jun 29, 2022
807c69b
Implement epochstorage plugin
jkrvivian Jun 30, 2022
8539312
Merge pull request #2311 from iotaledger/test/notarization-manager
karimodm Jun 30, 2022
a870017
Merge branch 'feat/epoch-commitment' into feat/ec-chain-display
jkrvivian Jun 30, 2022
eaaa9bf
Remove metrics prefix from database
jkrvivian Jun 30, 2022
071a86b
Update dependencies
jkrvivian Jun 30, 2022
ed0d474
Add plugin to research and fix bugs
jkrvivian Jun 30, 2022
19c0c6d
Add lock for maps
jkrvivian Jun 30, 2022
9e799d8
Limit epoch contents to store
jkrvivian Jul 1, 2022
39f9318
Remove unused method: LastCommittedEpoch
jkrvivian Jul 1, 2022
26bf83c
Remove unused method: IsCommittable
jkrvivian Jul 1, 2022
9c66b19
Remove debug prints
jkrvivian Jul 1, 2022
ead4623
Fix outputID decoding
jkrvivian Jul 1, 2022
01ccd96
Add last committed EI to grafana dashboard
jkrvivian Jul 4, 2022
98fc1e6
Add comments
jkrvivian Jul 5, 2022
ecd4eb2
Add EC weight webapi
jkrvivian Jul 5, 2022
61c94c6
Merge branch 'develop' into feat/ec-chain-display
jkrvivian Jul 5, 2022
4829a23
Adding and removing comments
jkrvivian Jul 5, 2022
02f4911
Update to develop
jkrvivian Jul 5, 2022
d349e60
Ignore checking number of events to mock
jkrvivian Jul 5, 2022
c795645
Remove unused codes
jkrvivian Jul 5, 2022
1e18e8c
Disable epochstorage and epoch webapi in integration test
jkrvivian Jul 5, 2022
f7ec9c3
Fix epochstorage plugin shutdown
jkrvivian Jul 5, 2022
82b0301
Remove last EC from webapi
jkrvivian Jul 6, 2022
23a09a5
Disable epochstorage and webapi in peer node in integration test
jkrvivian Jul 6, 2022
6e5aa64
Fix misplaced error check in messageFactory
jkrvivian Jul 6, 2022
a3ac7fa
Rename events
jkrvivian Jul 6, 2022
c99d384
Fix dependency issue
jkrvivian Jul 6, 2022
2ac2783
Manage committableEpochs limit
jkrvivian Jul 7, 2022
f642227
Merge branch 'develop' into feat/ec-chain-display
jkrvivian Jul 7, 2022
1ae9f5e
Update event name
jkrvivian Jul 7, 2022
6d8d74a
Resolve part of comments
jkrvivian Jul 7, 2022
4be1857
Update epoch votes correctly
jkrvivian Jul 8, 2022
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
48 changes: 48 additions & 0 deletions packages/jsonmodels/epochs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package jsonmodels

import (
"github.com/iotaledger/goshimmer/packages/epoch"
)

type EpochInfo struct {
EI uint64 `json:"EI"`
ECR string `json:"ECR"`
PrevEC string `json:"prevEC"`
}

func EpochInfoFromRecord(record *epoch.ECRecord) *EpochInfo {
return &EpochInfo{
EI: uint64(record.EI()),
ECR: record.ECR().Base58(),
PrevEC: record.PrevEC().Base58(),
}
}

type EpochsResponse struct {
Epochs []*EpochInfo `json:"epochs"`
}

type EpochVotersWeightResponse struct {
VotersWeight map[string]*NodeWeight `json:"ecrVoters"`
}

type NodeWeight struct {
Weights map[string]float64 `json:"weights"`
}

type EpochUTXOsResponse struct {
SpentOutputs []string `json:"spentOutputs"`
CreatedOutputs []string `json:"createdOutputs"`
}

type EpochMessagesResponse struct {
Messages []string `json:"messages"`
}

type EpochTransactionsResponse struct {
Transactions []string `json:"transactions"`
}

type EpochPendingBranchCountResponse struct {
PendingBranchCount uint64 `json:"pendingBranchCount"`
}
4 changes: 4 additions & 0 deletions packages/jsonmodels/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ type InfoResponse struct {
Mana Mana `json:"mana,omitempty"`
// Scheduler is the scheduler.
Scheduler Scheduler `json:"scheduler"`

jkrvivian marked this conversation as resolved.
Show resolved Hide resolved
// LastCommittedEpoch contains information about the last committed epoch.
LastCommittedEpoch EpochInfo

georgysavva marked this conversation as resolved.
Show resolved Hide resolved
// RateSetter is the rate setter.
RateSetter RateSetter `json:"rateSetter"`
// error of the response
Expand Down
2 changes: 1 addition & 1 deletion packages/notarization/commitments.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,4 @@ func EC(ecRecord *epoch.ECRecord) (ec epoch.EC) {
return epoch.NewMerkleRoot(ecHash[:])
}

// endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////
// endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////
80 changes: 75 additions & 5 deletions packages/notarization/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ func NewManager(epochCommitmentFactory *EpochCommitmentFactory, t *tangle.Tangle
log: options.Log,
options: options,
Events: &Events{
EpochCommittable: event.New[*EpochCommittableEvent](),
ManaVectorUpdate: event.New[*ManaVectorUpdateEvent](),
TangleTreeInserted: event.New[*TangleTreeUpdatedEvent](),
TangleTreeRemoved: event.New[*TangleTreeUpdatedEvent](),
StateMutationInserted: event.New[*StateMutationTreeUpdatedEvent](),
StateMutationRemoved: event.New[*StateMutationTreeUpdatedEvent](),
UTXOInserted: event.New[*UTXOUpdatedEvent](),
UTXORemoved: event.New[*UTXOUpdatedEvent](),
EpochCommittable: event.New[*EpochCommittableEvent](),
ManaVectorUpdate: event.New[*ManaVectorUpdateEvent](),
},
}

Expand Down Expand Up @@ -193,7 +199,9 @@ func (m *Manager) OnMessageConfirmed(message *tangle.Message) {
err := m.epochCommitmentFactory.insertTangleLeaf(ei, message.ID())
if err != nil && m.log != nil {
m.log.Error(err)
return
}
m.Events.TangleTreeInserted.Trigger(&TangleTreeUpdatedEvent{EI: ei, MessageID: message.ID()})
}

// OnMessageOrphaned is the handler for message orphaned event.
Expand All @@ -210,10 +218,13 @@ func (m *Manager) OnMessageOrphaned(message *tangle.Message) {
if err != nil && m.log != nil {
m.log.Error(err)
}
m.Events.TangleTreeRemoved.Trigger(&TangleTreeUpdatedEvent{EI: ei, MessageID: message.ID()})

transaction, isTransaction := message.Payload().(utxo.Transaction)
if isTransaction {
spent, created := m.resolveOutputs(transaction)
m.epochCommitmentFactory.deleteDiffUTXOs(ei, created, spent)
m.Events.UTXORemoved.Trigger(&UTXOUpdatedEvent{EI: ei, Spent: spent, Created: created})
}
}

Expand Down Expand Up @@ -280,7 +291,6 @@ func (m *Manager) OnTransactionInclusionUpdated(event *ledger.TransactionInclusi
func (m *Manager) OnBranchConfirmed(branchID utxo.TransactionID) {
m.epochCommitmentFactoryMutex.Lock()
defer m.epochCommitmentFactoryMutex.Unlock()

ei := m.getBranchEI(branchID, true)

if m.isEpochAlreadyCommitted(ei) {
Expand Down Expand Up @@ -339,6 +349,20 @@ func (m *Manager) OnAcceptanceTimeUpdated(newTime time.Time) {
}
}

// PendingConflictsCount returns the current value of pendingConflictsCount.
func (m *Manager) PendingConflictsCount(ei epoch.Index) uint64 {
return m.pendingConflictsCounters[ei]
}

// PendingConflictsCountAll returns the current value of pendingConflictsCount per epoch.
func (m *Manager) PendingConflictsCountAll() map[epoch.Index]uint64 {
duplicate := make(map[epoch.Index]uint64, len(m.pendingConflictsCounters))
jkrvivian marked this conversation as resolved.
Show resolved Hide resolved
for k, v := range m.pendingConflictsCounters {
duplicate[k] = v
}
return duplicate
}

// Shutdown shuts down the manager's permanent storagee.
func (m *Manager) Shutdown() {
m.epochCommitmentFactoryMutex.Lock()
Expand All @@ -362,8 +386,10 @@ func (m *Manager) includeTransactionInEpoch(txID utxo.TransactionID, ei epoch.In
if err := m.epochCommitmentFactory.insertStateMutationLeaf(ei, txID); err != nil {
return err
}
m.Events.StateMutationInserted.Trigger(&StateMutationTreeUpdatedEvent{TransactionID: txID})

m.epochCommitmentFactory.storeDiffUTXOs(ei, spent, created)
m.Events.UTXOInserted.Trigger(&UTXOUpdatedEvent{EI: ei, Spent: spent, Created: created})

return nil
}
Expand All @@ -372,8 +398,10 @@ func (m *Manager) removeTransactionFromEpoch(txID utxo.TransactionID, ei epoch.I
if err := m.epochCommitmentFactory.removeStateMutationLeaf(ei, txID); err != nil {
return err
}
m.Events.StateMutationRemoved.Trigger(&StateMutationTreeUpdatedEvent{TransactionID: txID})

m.epochCommitmentFactory.deleteDiffUTXOs(ei, spent, created)
m.Events.UTXORemoved.Trigger(&UTXOUpdatedEvent{EI: ei, Spent: spent, Created: created})

return nil
}
Expand Down Expand Up @@ -480,7 +508,9 @@ func (m *Manager) moveLatestCommittableEpoch(currentEpoch epoch.Index) {

// reads the roots and store the ec
// rolls the state trees
if _, ecRecordErr := m.epochCommitmentFactory.ecRecord(ei); ecRecordErr != nil {
ecRecord := epoch.NewECRecord(epoch.Index(0))
Fixed Show fixed Hide fixed
ecRecord, ecRecordErr := m.epochCommitmentFactory.ecRecord(ei)
if ecRecordErr != nil {
m.log.Errorf("could not update commitments for epoch %d: %v", ei, ecRecordErr)
return
}
Expand All @@ -490,7 +520,7 @@ func (m *Manager) moveLatestCommittableEpoch(currentEpoch epoch.Index) {
return
}

m.Events.EpochCommittable.Trigger(&EpochCommittableEvent{EI: ei})
m.Events.EpochCommittable.Trigger(&EpochCommittableEvent{EI: ei, ECRecord: ecRecord})
m.triggerManaVectorUpdate(ei)
}
}
Expand Down Expand Up @@ -539,12 +569,52 @@ type Events struct {
// EpochCommittable is an event that gets triggered whenever an epoch commitment is committable.
EpochCommittable *event.Event[*EpochCommittableEvent]
ManaVectorUpdate *event.Event[*ManaVectorUpdateEvent]
// TangleTreeInserted is an event that gets triggered when a Message is inserted to Tangle smt.
jkrvivian marked this conversation as resolved.
Show resolved Hide resolved
TangleTreeInserted *event.Event[*TangleTreeUpdatedEvent]
// TangleTreeRemoved is an event that gets triggered when a Message is removed to Tangle smt.
jkrvivian marked this conversation as resolved.
Show resolved Hide resolved
TangleTreeRemoved *event.Event[*TangleTreeUpdatedEvent]
// StateMutationInserted is an event that gets triggered when a transaction is inserted to state mutation smt.
StateMutationInserted *event.Event[*StateMutationTreeUpdatedEvent]
// StateMutationRemoved is an event that gets triggered when a transaction is removed to state mutation smt.
StateMutationRemoved *event.Event[*StateMutationTreeUpdatedEvent]
// UTXOInserted is an event that gets triggered when UTXOs are stored.
UTXOInserted *event.Event[*UTXOUpdatedEvent]
// UTXORemoved is an event that gets triggered when UTXOs are removed.
UTXORemoved *event.Event[*UTXOUpdatedEvent]
}

// TangleTreeUpdatedEvent is a container that acts as a dictionary for the TangleTree inserted/removed event related parameters.
type TangleTreeUpdatedEvent struct {
// EI is the index of the message.
EI epoch.Index
// MessageID is the messageID that inserted/removed to/from the tangle smt.
MessageID tangle.MessageID
}

// StateMutationTreeUpdatedEvent is a container that acts as a dictionary for the State mutation tree inserted/removed event related parameters.
type StateMutationTreeUpdatedEvent struct {
// EI is the index of the transaction.
EI epoch.Index
// TransactionID is the transaction ID that inserted/removed to/from the state mutation smt.
TransactionID utxo.TransactionID
}

// UTXOUpdatedEvent is a container that acts as a dictionary for the UTXO update event related parameters.
type UTXOUpdatedEvent struct {
// EI is the index of updated UTXO.
EI epoch.Index
// Created are the outputs created in a transaction.
Created []*ledger.OutputWithMetadata
// Spent are outputs that is spent in a transaction.
Spent []*ledger.OutputWithMetadata
}

// EpochCommittableEvent is a container that acts as a dictionary for the EpochCommittable event related parameters.
type EpochCommittableEvent struct {
// EI is the index of committable epoch.
EI epoch.Index
// ECRecord is the ec root of committable epoch.
ECRecord *epoch.ECRecord
}

// ManaVectorUpdateEvent is a container that acts as a dictionary for the EpochCommittable event related parameters.
Expand Down
2 changes: 1 addition & 1 deletion packages/notarization/proofs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ func (f *EpochCommitmentFactory) VerifyStateMutationRoot(proof CommitmentProof,
return f.verifyRoot(proof, key, key)
}

// endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////
// endregion ///////////////////////////////////////////////////////////////////////////////////////////////////////////
3 changes: 2 additions & 1 deletion packages/tangle/ratesetter_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package tangle

import (
"github.com/iotaledger/goshimmer/packages/epoch"
"testing"
"time"

"github.com/iotaledger/goshimmer/packages/epoch"

"github.com/iotaledger/goshimmer/packages/tangle/payload"

"github.com/iotaledger/hive.go/crypto/ed25519"
Expand Down
Loading