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

use rust version of SpendBundle #17430

Merged
merged 1 commit into from
Jul 8, 2024
Merged

use rust version of SpendBundle #17430

merged 1 commit into from
Jul 8, 2024

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Jan 29, 2024

Purpose:

This is a step towards validating transactions in threads. The python <-> rust boundary will need to move to make the SpendBundle live on the rust side, to allow moving it to the worker thread and back.

Current Behavior:

SpendBundle is a python type.

New Behavior:

SpendBundle is a rust type.

@arvidn arvidn added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label Jan 29, 2024
@arvidn arvidn force-pushed the rust-spend-bundle branch 5 times, most recently from 0a3b7ff to b77bbf2 Compare February 6, 2024 22:14
Copy link
Contributor

github-actions bot commented Feb 8, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Feb 8, 2024
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Feb 8, 2024
Copy link
Contributor

github-actions bot commented Feb 8, 2024

Conflicts have been resolved. A maintainer will review the pull request shortly.

@arvidn arvidn marked this pull request as ready for review February 8, 2024 19:34
@arvidn arvidn requested a review from a team as a code owner February 8, 2024 19:34
@arvidn arvidn marked this pull request as draft February 28, 2024 16:58
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Mar 14, 2024
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Apr 5, 2024
Copy link
Contributor

github-actions bot commented Apr 5, 2024

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Apr 26, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

github-actions bot commented May 7, 2024

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions github-actions bot added merge_conflict Branch has conflicts that prevent merge to main and removed merge_conflict Branch has conflicts that prevent merge to main labels May 7, 2024
Copy link
Contributor

github-actions bot commented May 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

1 similar comment
Copy link
Contributor

github-actions bot commented May 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label May 7, 2024
Copy link
Contributor

github-actions bot commented May 7, 2024

Conflicts have been resolved. A maintainer will review the pull request shortly.

@arvidn arvidn marked this pull request as ready for review May 8, 2024 12:03
@arvidn arvidn requested a review from Rigidity May 8, 2024 12:03
@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label May 13, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

1 similar comment
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@arvidn arvidn requested a review from Rigidity June 12, 2024 15:50
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Jun 12, 2024
Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@Rigidity
Copy link
Contributor

Rigidity commented Jul 1, 2024

I'm going to take a look at wallet performance with this PR, given the recent weight proof debacle. Otherwise, looks good to me.

Copy link

coveralls-official bot commented Jul 1, 2024

Pull Request Test Coverage Report for Build 9485741536

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 10 of 13 (76.92%) changed or added relevant lines in 7 files are covered.
  • 30 unchanged lines in 12 files lost coverage.
  • Overall coverage decreased (-0.009%) to 90.886%

Changes Missing Coverage Covered Lines Changed/Added Lines %
chia/wallet/trading/offer.py 1 4 25.0%
Files with Coverage Reduction New Missed Lines %
chia/daemon/keychain_proxy.py 1 72.57%
chia/farmer/farmer.py 1 72.23%
chia/wallet/util/wallet_sync_utils.py 1 86.54%
chia/timelord/timelord_launcher.py 1 69.34%
chia/daemon/client.py 1 73.33%
chia/daemon/server.py 1 83.22%
chia/full_node/full_node_api.py 2 81.66%
chia/rpc/rpc_server.py 3 87.71%
chia/wallet/wallet_node.py 3 88.79%
chia/_tests/core/util/test_lockfile.py 4 89.47%
Totals Coverage Status
Change from base Build 9484102110: -0.009%
Covered Lines: 99991
Relevant Lines: 109964

💛 - Coveralls

Copy link
Contributor

@wjblanke wjblanke left a comment

Choose a reason for hiding this comment

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

aok

@Starttoaster
Copy link
Contributor

Starttoaster commented Jul 2, 2024

Waiting on passing CI, resolved conversations, and coverage diff resolution/override

Copy link
Contributor

@Rigidity Rigidity left a comment

Choose a reason for hiding this comment

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

With Rust spend bundle:
Total time: 3.2067s
Total amount: 6194000
Total coin spends: 12400000

With Python spend bundle:
Total time: 3.2434s
Total amount: 6194000
Total coin spends: 12400000

from time import monotonic
from typing import List
from chia_rs import Coin, CoinSpend, G2Element, Program, SpendBundle
from chia_rs.sized_ints import uint64
from chia_rs.sized_bytes import bytes32

from chia.util.hash import std_hash
from chia.wallet.nft_wallet.nft_puzzles import STANDARD_PUZZLE_MOD


FAKE_PUZZLE = Program.from_program(STANDARD_PUZZLE_MOD)
FAKE_PUZZLE_HASH = bytes32(b"0" * 32)


def make_spend_bundle(spend_count: int) -> SpendBundle:
    coin_spends: List[CoinSpend] = []

    for i in range(spend_count):
        coin = Coin(std_hash(i.to_bytes(4, "big")), FAKE_PUZZLE_HASH, uint64(i))
        puzzle_reveal = FAKE_PUZZLE
        solution = Program.to([[51, FAKE_PUZZLE_HASH, i]])
        coin_spends.append(CoinSpend(coin, puzzle_reveal, solution))

    return SpendBundle(coin_spends, G2Element.generator())


def bench_spend_bundles():
    initial = monotonic()
    total_amount = 0
    spend_count = 0

    for i in range(1, 16):
        start = monotonic()
        spend_bundle = make_spend_bundle(i * 100)
        for cs in spend_bundle.coin_spends:
            spend_count += len(spend_bundle.coin_spends)
            _ = spend_bundle.coin_spends
            total_amount += cs.coin.amount
        end = monotonic()
        print(f"{i * 100} coin spends with O(n^2) loop took {end - start:.4f}s")

    final = monotonic()
    print(f"Total time: {final - initial:.4f}s")
    print(f"Total amount: {total_amount}")
    print(f"Total coin spends: {spend_count}")


if __name__ == "__main__":
    bench_spend_bundles()

@Rigidity
Copy link
Contributor

Rigidity commented Jul 3, 2024

I don't think we need to worry about coin_solutions compatibility anymore. Resolved my comments.

@arvidn
Copy link
Contributor Author

arvidn commented Jul 8, 2024

the streamable format of Offer was missing test coverage before this change

@arvidn arvidn added ready_to_merge Submitter and reviewers think this is ready and removed coverage-diff labels Jul 8, 2024
Copy link
Contributor

github-actions bot commented Jul 8, 2024

File Coverage Missing Lines
chia/wallet/trading/offer.py 25.0% lines 687, 691-692
Total Missing Coverage
13 lines 3 lines 76%

@Starttoaster
Copy link
Contributor

Re-removing coverage diff since Arvid overrid it earlier and a new CI run added it back.

@Starttoaster Starttoaster merged commit 956894d into main Jul 8, 2024
367 of 368 checks passed
@Starttoaster Starttoaster deleted the rust-spend-bundle branch July 8, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog ready_to_merge Submitter and reviewers think this is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants