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

Zsa issuance #15

Open
wants to merge 32 commits into
base: zsa1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
717b96e
Use custom Orchard crate
alexeykoren Dec 12, 2022
787e1f9
Custom librustzcash
alexeykoren Dec 19, 2022
2c6dc2a
Custom librustzcash
alexeykoren Dec 19, 2022
a92d604
Re-enable last faling test
alexeykoren Dec 19, 2022
727e5a1
Updated librustzcash
alexeykoren Dec 20, 2022
1ef7a24
Update Orchard
alexeykoren Dec 23, 2022
f668826
AssetId WIP
alexeykoren Dec 12, 2022
5806f57
Add Asset to Builder interface
alexeykoren Dec 30, 2022
459a2b6
Native Asset FFI
alexeykoren Jan 3, 2023
de93afb
ZSA balances RPC
alexeykoren Jan 16, 2023
235d4b6
Linter
alexeykoren Jan 16, 2023
59ad682
Fix include guard
alexeykoren Jan 16, 2023
e139a58
Fix config.offline
alexeykoren Jan 16, 2023
2c427aa
Re-enable InvalidOrchardShieldedCoinbase test
alexeykoren Feb 4, 2023
6c21939
AssetId derivation
alexeykoren Feb 4, 2023
cdc73bf
Fix fmt
alexeykoren Feb 6, 2023
3b56e72
Fix cargo patches
alexeykoren Feb 6, 2023
e7dfdb3
Update Orchard version
alexeykoren Feb 15, 2023
b5c4854
Rename ZEC to Native + small fixes
alexeykoren Feb 20, 2023
470dfd1
Rebase
alexeykoren Jan 31, 2023
831f3a0
Pre-zsa-bundle version
alexeykoren Feb 22, 2023
b49f800
Reorganize issuance
alexeykoren Feb 25, 2023
9fc0b08
cxxbridge for issuance
alexeykoren Mar 3, 2023
e60acff
Issuance RPC WIP
alexeykoren Mar 15, 2023
a122314
RPC test and fixes
Mar 18, 2023
33d8bec
Issance RPC and Wallet
alexeykoren Apr 20, 2023
f9aa675
Green tests
alexeykoren May 8, 2023
68033f1
Py test update
alexeykoren May 8, 2023
5b9f71a
CI checks fixed
alexeykoren May 10, 2023
d60949c
Cargo vet regenerated
alexeykoren May 10, 2023
ed518fc
Downgrade Rust version
alexeykoren May 10, 2023
3596772
Temp fix for cargo patches
alexeykoren May 10, 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
10 changes: 10 additions & 0 deletions .cargo/config.offline
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,15 @@ linker = "aarch64-linux-gnu-gcc"
[source.crates-io]
replace-with = "vendored-sources"

[source."https://github.com/QED-it/librustzcash"]
git = "https://github.com/QED-it/librustzcash"
rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81"
replace-with = "vendored-sources"

[source."https://github.com/QED-it/orchard"]
git = "https://github.com/QED-it/orchard"
rev = "3518629964805c46598c7ccc4764ea6f42fbd5c5"
replace-with = "vendored-sources"

[source.vendored-sources]
# The directory for this source is set to RUST_VENDORED_SOURCES by src/Makefile.am
27 changes: 9 additions & 18 deletions Cargo.lock

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

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,12 @@ lto = true
panic = 'abort'
codegen-units = 1

[patch.crates-io]
orchard = { git = "https://github.com/QED-it/orchard", rev = "3518629964805c46598c7ccc4764ea6f42fbd5c5" } # branch = "ivk-to-bytes-visibility-downgrade"
zcash_primitives = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" } # branch = "zsa-bundle-in-v5-vector-serialization"
equihash = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" }
zcash_address = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" }
zcash_encoding = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" }
zcash_note_encryption = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" }
zcash_proofs = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" }
zcash_history = { git = "https://github.com/QED-it/librustzcash", rev = "b35afbce395ada0c3d62373ffa12f7a7e4f82e81" }
54 changes: 54 additions & 0 deletions qa/rpc-tests/issuance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python3
# Copyright (c) 2022 The Zcash developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://www.opensource.org/licenses/mit-license.php .

from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
NU5_BRANCH_ID,
assert_equal,
nuparams,
start_nodes,
)

class IssueTest(BitcoinTestFramework):
def __init__(self):
super().__init__()
self.num_nodes = 4

def setup_nodes(self):
return start_nodes(self.num_nodes, self.options.tmpdir, [[
nuparams(NU5_BRANCH_ID, 205),
'-regtestwalletsetbestchaineveryblock'
]] * self.num_nodes)

def run_test(self):
# Sanity-check the test harness
assert_equal(self.nodes[0].getblockcount(), 200)

# Get a new Orchard account on node 0
acct0 = self.nodes[0].z_getnewaccount()['account']
ua0 = self.nodes[0].z_getaddressforaccount(acct0, ['orchard'])['address']

# Activate NU5
self.nodes[0].generate(5)
self.sync_all()

# Send a transaction to node 1 so that it has an Orchard note to spend.
self.nodes[0].issue(0, ua0, "WBTC", 4001, True)

self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

walletinfo = self.nodes[0].getwalletinfo()

print(walletinfo)

assert_equal(len(walletinfo['asset_balances'].items()), 1)
for key, value in walletinfo['asset_balances'].items():
assert_equal(value['confirmed_balance'], 4001)

if __name__ == '__main__':
IssueTest().main()

30 changes: 27 additions & 3 deletions qa/rpc-tests/test_framework/mininode.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def deserialize(self, f):
self.rk = deser_uint256(f)
self.cmx = deser_uint256(f)
self.ephemeralKey = deser_uint256(f)
self.encCiphertext = f.read(580)
self.encCiphertext = f.read(612)
self.outCiphertext = f.read(80)

def serialize(self):
Expand Down Expand Up @@ -524,6 +524,21 @@ def __repr__(self):
)


class IssueBundle(object):

def deserialize(self, f):
num_actions = struct.unpack("<B", f.read(1))[0]
if num_actions != 0:
raise Exception("Non-empty IssueBundle is not implemented in mininode")

def serialize(self):
r = b""
r += ser_compact_size(0)
return r

def __repr__(self):
return "IssueBundle(Empty)"

class Groth16Proof(object):
def __init__(self):
self.data = None
Expand Down Expand Up @@ -628,7 +643,7 @@ def deserialize(self, f):
self.cv = deser_uint256(f)
self.cmu = deser_uint256(f)
self.ephemeralKey = deser_uint256(f)
self.encCiphertext = f.read(580)
self.encCiphertext = f.read(612)
self.outCiphertext = f.read(80)

def serialize(self):
Expand Down Expand Up @@ -665,7 +680,7 @@ def deserialize(self, f):
self.cv = deser_uint256(f)
self.cmu = deser_uint256(f)
self.ephemeralKey = deser_uint256(f)
self.encCiphertext = f.read(580)
self.encCiphertext = f.read(612)
self.outCiphertext = f.read(80)
self.zkproof = Groth16Proof()
self.zkproof.deserialize(f)
Expand Down Expand Up @@ -981,6 +996,7 @@ def __init__(self, tx=None):
self.valueBalance = 0
self.saplingBundle = SaplingBundle()
self.orchardBundle = OrchardBundle()
self.issueBundle = IssueBundle()
self.shieldedSpends = []
self.shieldedOutputs = []
self.vJoinSplit = []
Expand All @@ -1000,6 +1016,7 @@ def __init__(self, tx=None):
self.valueBalance = tx.valueBalance
self.saplingBundle = copy.deepcopy(tx.saplingBundle)
self.orchardBundle = copy.deepcopy(tx.orchardBundle)
self.issueBundle = copy.deepcopy(tx.issueBundle)
self.shieldedSpends = copy.deepcopy(tx.shieldedSpends)
self.shieldedOutputs = copy.deepcopy(tx.shieldedOutputs)
self.vJoinSplit = copy.deepcopy(tx.vJoinSplit)
Expand Down Expand Up @@ -1044,6 +1061,10 @@ def deserialize(self, f):
self.orchardBundle = OrchardBundle()
self.orchardBundle.deserialize(f)

# Orchard transaction fields
self.issueBundle = IssueBundle()
self.issueBundle.deserialize(f)

return

self.vin = deser_vector(f, CTxIn)
Expand Down Expand Up @@ -1102,6 +1123,9 @@ def serialize(self):
# Orchard transaction fields
r += self.orchardBundle.serialize()

# Issuance transaction fields
r += self.issueBundle.serialize()

return r

r = b""
Expand Down
28 changes: 25 additions & 3 deletions qa/rpc-tests/test_framework/zip244.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ def orchard_auth_digest(orchardBundle):

return digest.digest()

def issue_digest(tx):
digest = blake2b(digest_size=32, person=b'ZTxIdOrcZSAIssue')

# if tx.issueBundle is not None:
# Add all fields
# So far we only need digests for empty bundle here for pre-ZSA tests

return digest.digest()


def issue_auth_digest(tx):
digest = blake2b(digest_size=32, person=b'ZTxIdOrcZSAIssue')

# if tx.issueBundle is not None:
# Add all fields
# So far we only need digests for empty bundle here for pre-ZSA tests

return digest.digest()

# - Actions

def orchard_actions_compact_digest(orchardBundle):
Expand All @@ -163,21 +182,21 @@ def orchard_actions_compact_digest(orchardBundle):
digest.update(ser_uint256(desc.nullifier))
digest.update(ser_uint256(desc.cmx))
digest.update(ser_uint256(desc.ephemeralKey))
digest.update(desc.encCiphertext[:52])
digest.update(desc.encCiphertext[:84])
return digest.digest()

def orchard_actions_memos_digest(orchardBundle):
digest = blake2b(digest_size=32, person=b'ZTxIdOrcActMHash')
for desc in orchardBundle.actions:
digest.update(desc.encCiphertext[52:564])
digest.update(desc.encCiphertext[84:596])
return digest.digest()

def orchard_actions_noncompact_digest(orchardBundle):
digest = blake2b(digest_size=32, person=b'ZTxIdOrcActNHash')
for desc in orchardBundle.actions:
digest.update(ser_uint256(desc.cv))
digest.update(ser_uint256(desc.rk))
digest.update(desc.encCiphertext[564:])
digest.update(desc.encCiphertext[596:])
digest.update(desc.outCiphertext)
return digest.digest()

Expand All @@ -204,6 +223,7 @@ def txid_digest(tx):
digest.update(transparent_digest(tx))
digest.update(sapling_digest(tx.saplingBundle))
digest.update(orchard_digest(tx.orchardBundle))
digest.update(issue_digest(tx.issueBundle))

return digest.digest()

Expand All @@ -218,6 +238,7 @@ def auth_digest(tx):
digest.update(transparent_scripts_digest(tx))
digest.update(sapling_auth_digest(tx.saplingBundle))
digest.update(orchard_auth_digest(tx.orchardBundle))
digest.update(issue_auth_digest(tx.issueBundle))

return digest.digest()

Expand All @@ -233,6 +254,7 @@ def signature_digest(tx, nHashType, txin):
digest.update(transparent_sig_digest(tx, nHashType, txin))
digest.update(sapling_digest(tx.saplingBundle))
digest.update(orchard_digest(tx.orchardBundle))
digest.update(issue_digest(tx.issueBundle))

return digest.digest()

Expand Down
1 change: 0 additions & 1 deletion qa/supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -550,4 +550,3 @@ who = "Daira Hopwood <[email protected]>"
criteria = "safe-to-deploy"
delta = "1.4.3 -> 1.5.7"
notes = "The zeroize_c_string unit test has UB, but that's very unlikely to cause a problem in practice."

Loading