Skip to content

Commit a9f63ef

Browse files
committed
replace ledger_hash by migration_hash
1 parent 406e2a2 commit a9f63ef

File tree

8 files changed

+221
-471
lines changed

8 files changed

+221
-471
lines changed

counterparty-core/counterpartycore/lib/cli/log.py

-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ def isodt(epoch_time):
296296
"order_hash",
297297
"rps_hash",
298298
"ledger_hash",
299-
"migration_hash",
300299
"txlist_hash",
301300
"messages_hash",
302301
"offer_hash",

counterparty-core/counterpartycore/lib/ledger/currentstate.py

-7
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,12 @@ def append_to_block_ledger(self, item):
8686
def append_to_block_journal(self, item):
8787
self.journal.append(item)
8888

89-
def append_to_block_migration(self, item):
90-
self.migration.append(item)
91-
9289
def block_ledger(self):
9390
return self.ledger
9491

9592
def block_journal(self):
9693
return self.journal
9794

98-
def block_migration(self):
99-
return self.migration
100-
10195
def reset(self):
10296
self.ledger = []
10397
self.journal = []
104-
self.migration = []

counterparty-core/counterpartycore/lib/ledger/events.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ def debit(db, address, asset, quantity, tx_index, action=None, event=None):
269269
}
270270
insert_record(db, "debits", bindings, "DEBIT")
271271

272-
ConsensusHashBuilder().append_to_block_ledger(f"{block_index}{address}{asset}{quantity}")
273-
ConsensusHashBuilder().append_to_block_migration(
272+
ConsensusHashBuilder().append_to_block_ledger(
274273
f"{block_index}{str(address)[0:36]}{asset}{quantity}"
275274
)
276275
return utxo_address
@@ -349,8 +348,7 @@ def credit(db, address, asset, quantity, tx_index, action=None, event=None):
349348
}
350349
insert_record(db, "credits", bindings, "CREDIT")
351350

352-
ConsensusHashBuilder().append_to_block_ledger(f"{block_index}{address}{asset}{quantity}")
353-
ConsensusHashBuilder().append_to_block_migration(
351+
ConsensusHashBuilder().append_to_block_ledger(
354352
f"{block_index}{str(address)[0:36]}{asset}{quantity}"
355353
)
356354

counterparty-core/counterpartycore/lib/ledger/migrations/0004.add_migration_hash.sql

-1
This file was deleted.

counterparty-core/counterpartycore/lib/messages/data/checkpoints.py

+212-434
Large diffs are not rendered by default.

counterparty-core/counterpartycore/lib/parser/blocks.py

+2-19
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def parse_block(
309309
previous_ledger_hash=None,
310310
previous_txlist_hash=None,
311311
previous_messages_hash=None,
312-
previous_migration_hash=None,
313312
reparsing=False,
314313
):
315314
"""Parse the block, return hash of new ledger, txlist and messages.
@@ -379,12 +378,6 @@ def parse_block(
379378
previous_messages_hash,
380379
ledger.currentstate.ConsensusHashBuilder().block_journal(),
381380
)
382-
new_migration_hash, _found_migration_hash = check.consensus_hash(
383-
db,
384-
"migration_hash",
385-
previous_migration_hash,
386-
ledger.currentstate.ConsensusHashBuilder().block_migration(),
387-
)
388381

389382
# Update block
390383

@@ -394,15 +387,13 @@ def parse_block(
394387
txlist_hash=:txlist_hash,
395388
ledger_hash=:ledger_hash,
396389
messages_hash=:messages_hash,
397-
migration_hash=:migration_hash,
398390
transaction_count=:transaction_count
399391
WHERE block_index=:block_index
400392
"""
401393
update_block_bindings = {
402394
"txlist_hash": new_txlist_hash,
403395
"ledger_hash": new_ledger_hash,
404396
"messages_hash": new_messages_hash,
405-
"migration_hash": new_migration_hash,
406397
"transaction_count": len(transactions),
407398
"block_index": block_index,
408399
}
@@ -420,14 +411,13 @@ def parse_block(
420411
"ledger_hash": new_ledger_hash,
421412
"txlist_hash": new_txlist_hash,
422413
"messages_hash": new_messages_hash,
423-
"migration_hash": new_migration_hash,
424414
"transaction_count": len(transactions),
425415
},
426416
)
427417

428418
cursor.close()
429419

430-
return new_ledger_hash, new_txlist_hash, new_messages_hash, new_migration_hash
420+
return new_ledger_hash, new_txlist_hash, new_messages_hash
431421

432422
cursor.close()
433423
return None, None, None, None
@@ -653,21 +643,18 @@ def reparse(db, block_index=0):
653643
previous_ledger_hash = None
654644
previous_txlist_hash = None
655645
previous_messages_hash = None
656-
previous_migration_hash = None
657646
if CurrentState().current_block_index() > config.BLOCK_FIRST:
658647
previous_block = ledger.blocks.get_block(db, block["block_index"] - 1)
659648
previous_ledger_hash = previous_block["ledger_hash"]
660649
previous_txlist_hash = previous_block["txlist_hash"]
661650
previous_messages_hash = previous_block["messages_hash"]
662-
previous_migration_hash = previous_block["migration_hash"]
663651
parse_block(
664652
db,
665653
block["block_index"],
666654
block["block_time"],
667655
previous_ledger_hash=previous_ledger_hash,
668656
previous_txlist_hash=previous_txlist_hash,
669657
previous_messages_hash=previous_messages_hash,
670-
previous_migration_hash=previous_migration_hash,
671658
reparsing=True,
672659
)
673660
block_parsed_count += 1
@@ -754,7 +741,6 @@ def parse_new_block(db, decoded_block, tx_index=None):
754741
"ledger_hash": None,
755742
"txlist_hash": None,
756743
"messages_hash": None,
757-
"migration_hash": None,
758744
"block_index": config.BLOCK_FIRST - 1,
759745
}
760746
else:
@@ -799,21 +785,19 @@ def parse_new_block(db, decoded_block, tx_index=None):
799785
decoded_tx=transaction,
800786
)
801787
# Parse the transactions in the block.
802-
new_ledger_hash, new_txlist_hash, new_messages_hash, new_migration_hash = parse_block(
788+
new_ledger_hash, new_txlist_hash, new_messages_hash = parse_block(
803789
db,
804790
decoded_block["block_index"],
805791
decoded_block["block_time"],
806792
previous_ledger_hash=previous_block["ledger_hash"],
807793
previous_txlist_hash=previous_block["txlist_hash"],
808794
previous_messages_hash=previous_block["messages_hash"],
809-
previous_migration_hash=previous_block["migration_hash"],
810795
)
811796

812797
duration = time.time() - start_time
813798

814799
log_message = "Block %(block_index)s - Parsing complete. "
815800
log_message += "L: %(ledger_hash)s, "
816-
log_message += "L2: %(migration_hash)s, "
817801
log_message += "TX: %(txlist_hash)s, "
818802
log_message += "M: %(messages_hash)s "
819803
log_message += "(%(duration).2fs)"
@@ -824,7 +808,6 @@ def parse_new_block(db, decoded_block, tx_index=None):
824808
"ledger_hash": new_ledger_hash,
825809
"txlist_hash": new_txlist_hash,
826810
"messages_hash": new_messages_hash,
827-
"migration_hash": new_migration_hash,
828811
"duration": duration,
829812
},
830813
)

counterparty-core/counterpartycore/lib/parser/check.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
def consensus_hash(db, field, previous_consensus_hash, content):
16-
assert field in ("ledger_hash", "txlist_hash", "messages_hash", "migration_hash")
16+
assert field in ("ledger_hash", "txlist_hash", "messages_hash")
1717

1818
cursor = db.cursor()
1919
block_index = CurrentState().current_block_index()
@@ -58,7 +58,7 @@ def consensus_hash(db, field, previous_consensus_hash, content):
5858
]
5959
or None
6060
)
61-
if found_hash and field not in ["messages_hash", "ledger_hash"]:
61+
if found_hash and field != "messages_hash":
6262
# Check against existing value.
6363
if calculated_hash != found_hash:
6464
raise exceptions.ConsensusError(
@@ -76,7 +76,7 @@ def consensus_hash(db, field, previous_consensus_hash, content):
7676
network_checkpoints = checkpoints.CHECKPOINTS_MAINNET
7777

7878
if (
79-
field not in ["messages_hash", "ledger_hash"]
79+
field != "messages_hash"
8080
and block_index in network_checkpoints
8181
and network_checkpoints[block_index][field] != calculated_hash
8282
):

counterparty-core/counterpartycore/test/units/ledger/ledgerblocks_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_blocks_functions(ledger_db, current_block_index):
1111
assert last_block["block_index"] == current_block_index
1212
assert (
1313
last_block["ledger_hash"]
14-
== "cb226f571087a7585d9ef65ae98d36500e4d0abf3a6737923182d70bf3068e92"
14+
== "084d9a93dea77718d67f44e5bb34a63539f4d5437132d8af2b1abfb1e8ddf848"
1515
)
1616
assert (
1717
last_block["txlist_hash"]
@@ -28,7 +28,7 @@ def test_blocks_functions(ledger_db, current_block_index):
2828
assert last_block["block_index"] == current_block_index
2929
assert (
3030
last_block["ledger_hash"]
31-
== "cb226f571087a7585d9ef65ae98d36500e4d0abf3a6737923182d70bf3068e92"
31+
== "084d9a93dea77718d67f44e5bb34a63539f4d5437132d8af2b1abfb1e8ddf848"
3232
)
3333
assert (
3434
last_block["txlist_hash"]

0 commit comments

Comments
 (0)