Skip to content

Commit

Permalink
Merge pull request #2379 from CounterpartyXCP/develop
Browse files Browse the repository at this point in the history
v10.4.6
  • Loading branch information
ouziel-slama authored Oct 17, 2024
2 parents b96aeb4 + 5f5478d commit 1d90c24
Show file tree
Hide file tree
Showing 15 changed files with 3,439 additions and 3,391 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Docker Compose

on:
push:
branches: ['develop', 'master', 'fix503']
branches: ['develop', 'master', 'fixutxo']

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ Returns server information and the list of documented routes in JSON format.
"result": {
"server_ready": true,
"network": "mainnet",
"version": "10.4.5",
"version": "10.4.6",
"backend_height": 850214,
"counterparty_height": 850214,
"documentation": "https://counterpartycore.docs.apiary.io/",
Expand Down
2 changes: 1 addition & 1 deletion counterparty-core/counterpartycore/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# Semantic Version
__version__ = "10.4.5" # for hatch
__version__ = "10.4.6" # for hatch
VERSION_STRING = __version__
version = VERSION_STRING.split("-")[0].split(".")
VERSION_MAJOR = int(version[0])
Expand Down
3 changes: 1 addition & 2 deletions counterparty-core/counterpartycore/lib/gettxinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,7 @@ def get_utxos_info(db, decoded_tx):
else:
vin_hash = inverse_hash(binascii.hexlify(vin["hash"]).decode("utf-8"))
utxo = vin_hash + ":" + str(vin["n"])
utxo_balances = ledger.get_utxo_balances(db, utxo)
if len(utxo_balances) > 0:
if ledger.utxo_has_balance(db, utxo):
sources.append(utxo)
destination = None
# the destination is the first non-OP_RETURN vout
Expand Down
23 changes: 23 additions & 0 deletions counterparty-core/counterpartycore/lib/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ def credit(db, address, asset, quantity, tx_index, action=None, event=None):
credit_address = None
utxo = address
utxo_address = backend.bitcoind.safe_get_utxo_address(utxo)
UTXOBalancesCache(db).add_balance(utxo)

add_to_balance(db, address, asset, quantity, tx_index, utxo_address)

Expand Down Expand Up @@ -446,6 +447,28 @@ def get_balance(db, address, asset, raise_error_if_no_balance=False, return_list
return balances[0]["quantity"]


class UTXOBalancesCache(metaclass=util.SingletonMeta):
def __init__(self, db):
logger.debug("Initialising utxo balances cache...")
sql = "SELECT utxo, asset, quantity, MAX(rowid) FROM balances WHERE utxo IS NOT NULL GROUP BY utxo, asset"
cursor = db.cursor()
cursor.execute(sql)
utxo_balances = cursor.fetchall()
self.utxos_with_balance = {}
for utxo_balance in utxo_balances:
self.utxos_with_balance[utxo_balance["utxo"]] = True

def has_balance(self, utxo):
return utxo in self.utxos_with_balance

def add_balance(self, utxo):
self.utxos_with_balance[utxo] = True


def utxo_has_balance(db, utxo):
return UTXOBalancesCache(db).has_balance(utxo)


def get_address_balances(db, address: str):
"""
Returns the balances of an address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"timestamp": 0,
"event": "BLOCK_PARSED",
"tx_hash": None,
"event_hash": "895d409a2e1c92470ac8745282bc80bc5317bc193413728450b4c097ff3d1e31",
"event_hash": "72f12f8d9225bfe88c43e2561d6e34ff4bb061174f0b025fd2e8f37e204dbf2c",
},
}
],
Expand Down

Large diffs are not rendered by default.

3,378 changes: 1,689 additions & 1,689 deletions counterparty-core/counterpartycore/test/fixtures/scenarios/unittest_fixture.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Returns server information and the list of documented routes in JSON format.
"result": {
"server_ready": true,
"network": "mainnet",
"version": "10.4.5",
"version": "10.4.6",
"backend_height": 850214,
"counterparty_height": 850214,
"documentation": "https://counterpartycore.docs.apiary.io/",
Expand Down
2 changes: 1 addition & 1 deletion counterparty-core/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ JSON-log-formatter==1.0
yoyo-migrations==8.2.0
gunicorn==23.0.0
waitress==3.0.0
counterparty-rs==10.4.5
counterparty-rs==10.4.6
2 changes: 1 addition & 1 deletion counterparty-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion counterparty-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "counterparty-rs"
version = "10.4.5"
version = "10.4.6"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion counterparty-wallet/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ colorlog==6.8.0
python-dateutil==2.8.2
requests==2.32.0
termcolor==2.4.0
counterparty-core==10.4.5
counterparty-core==10.4.6
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ x-addrindexrs-common: &addrindexrs-common
restart: unless-stopped

x-counterparty-common: &counterparty-common
image: counterparty/counterparty:v10.4.5
image: counterparty/counterparty:v10.4.6
stop_grace_period: 1m
volumes:
- data:/root/.bitcoin
Expand Down
26 changes: 26 additions & 0 deletions release-notes/release-notes-v10.4.6.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Release Notes - Counterparty Core v10.4.6 (2024-10-17)

This is a Hotfix release to address the slowness of block parsing.

# Upgrading

# ChangeLog

## Bugfixes


## Codebase

- Use of RAM cache to verify balances attached to a UTXO

## API

## CLI



# Credits

* Ouziel Slama
* Warren Puffett
* Adam Krellenstein

0 comments on commit 1d90c24

Please sign in to comment.