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

feat: Example card game #2135

Merged
merged 19 commits into from
Sep 8, 2023
Merged

feat: Example card game #2135

merged 19 commits into from
Sep 8, 2023

Conversation

sirasistant
Copy link
Collaborator

Resolves #1463

Checklist:

Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.

  • If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag.
  • I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code.
  • Every change is related to the PR description.
  • I have linked this pull request to relevant issues (if any exist).

@sirasistant sirasistant changed the title Arv/card game feat: Example card game Sep 8, 2023
@sirasistant sirasistant marked this pull request as ready for review September 8, 2023 14:00
}

#[aztec(private)]
fn joinGame(
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should avoid camelCase

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok!

@ludamad
Copy link
Collaborator

ludamad commented Sep 8, 2023

  1. It's a 7 minute test - probably OK for now, but at some point we might want to figure out how if we can get this down / what we keep long term
  2. it'd be good to have a negative test for people using cards they dont own

]);

expect((await contract.methods.view_game(GAME_ID).view({ from: firstPlayer })) as Game).toMatchObject({
players: [
Copy link
Collaborator

Choose a reason for hiding this comment

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

:D nice technique

@ludamad
Copy link
Collaborator

ludamad commented Sep 8, 2023

Honourary CGAM member

@sirasistant sirasistant enabled auto-merge (squash) September 8, 2023 15:55
}

fn compute_deck_strength<N>(cards: [Card; N]) -> Field {
cards.fold(0, |acc, card: Card| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

"Come to noir we have for loops"
we write this

}

const cardToField = (card: Card): bigint => {
return card.strength + card.points * 65536n;
Copy link
Contributor

Choose a reason for hiding this comment

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

side q:
longer term, is this something that should be handled by a generated typescript class?

also i think there is prover system abstraction leaking through (modulus/overflow is proving system dependent?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nah this is only because our macros dont' support arrays of structs yet as arguments to contract functions, when that's updated we don't need to pack the card into a field, we can just pass a card struct

What do you mean about the modulus/overflow? the fact that we can pack the card (32 bits) into a single field? For aztec we can safely assume that we'll always have bn254 I think 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh OK got it!

ohh right for modulus I forgot aztec has the pinned backend vs "regular" noir. i was thinking if points got really big we could maybe have overflow (in some setting besides the test)

Copy link
Contributor

@dan-aztec dan-aztec left a comment

Choose a reason for hiding this comment

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

wow a lot more complex than the private token contract!

@sirasistant sirasistant merged commit 9084b89 into master Sep 8, 2023
@sirasistant sirasistant deleted the arv/card_game branch September 8, 2023 16:29
PhilWindle pushed a commit that referenced this pull request Sep 8, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.5.2</summary>

##
[0.5.2](aztec-packages-v0.5.2...aztec-packages-v0.5.2)
(2023-09-08)


### Features

* Example card game
([#2135](#2135))
([9084b89](9084b89))


### Bug Fixes

* **tests:** Increase test timeout
([#2144](#2144))
([7da9615](7da9615))


### Miscellaneous

* **build:** Updated release please config
([#2142](#2142))
([e119c4f](e119c4f))
* Release 0.5.2
([f76b53c](f76b53c))
</details>

<details><summary>barretenberg.js: 0.5.2</summary>

##
[0.5.2](barretenberg.js-v0.5.2...barretenberg.js-v0.5.2)
(2023-09-08)


### Miscellaneous

* Release 0.5.2
([f76b53c](f76b53c))
</details>

<details><summary>barretenberg: 0.5.2</summary>

##
[0.5.2](barretenberg-v0.5.2...barretenberg-v0.5.2)
(2023-09-08)


### Miscellaneous

* Release 0.5.2
([f76b53c](f76b53c))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
AztecBot pushed a commit to AztecProtocol/barretenberg that referenced this pull request Sep 8, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.5.2</summary>

##
[0.5.2](AztecProtocol/aztec-packages@aztec-packages-v0.5.2...aztec-packages-v0.5.2)
(2023-09-08)


### Features

* Example card game
([#2135](AztecProtocol/aztec-packages#2135))
([9084b89](AztecProtocol/aztec-packages@9084b89))


### Bug Fixes

* **tests:** Increase test timeout
([#2144](AztecProtocol/aztec-packages#2144))
([7da9615](AztecProtocol/aztec-packages@7da9615))


### Miscellaneous

* **build:** Updated release please config
([#2142](AztecProtocol/aztec-packages#2142))
([e119c4f](AztecProtocol/aztec-packages@e119c4f))
* Release 0.5.2
([f76b53c](AztecProtocol/aztec-packages@f76b53c))
</details>

<details><summary>barretenberg.js: 0.5.2</summary>

##
[0.5.2](AztecProtocol/aztec-packages@barretenberg.js-v0.5.2...barretenberg.js-v0.5.2)
(2023-09-08)


### Miscellaneous

* Release 0.5.2
([f76b53c](AztecProtocol/aztec-packages@f76b53c))
</details>

<details><summary>barretenberg: 0.5.2</summary>

##
[0.5.2](AztecProtocol/aztec-packages@barretenberg-v0.5.2...barretenberg-v0.5.2)
(2023-09-08)


### Miscellaneous

* Release 0.5.2
([f76b53c](AztecProtocol/aztec-packages@f76b53c))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
PhilWindle pushed a commit that referenced this pull request Sep 8, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.6.1</summary>

##
[0.6.1](aztec-packages-v0.5.2...aztec-packages-v0.6.1)
(2023-09-08)


### Features

* Example card game
([#2135](#2135))
([9084b89](9084b89))


### Bug Fixes

* **tests:** Increase test timeout
([#2144](#2144))
([7da9615](7da9615))
* Work around intermittent wasm webkit issue
([#2140](#2140))
([a9b0934](a9b0934))


### Miscellaneous

* **build:** Updated release please config
([#2142](#2142))
([e119c4f](e119c4f))
* **build:** Updated version check
([#2145](#2145))
([4ed5f05](4ed5f05))
* **master:** Release 0.5.2
([#2141](#2141))
([451aad6](451aad6))
* Release 0.5.2
([f76b53c](f76b53c))
* Release 0.6.1
([1bd1a79](1bd1a79))
</details>

<details><summary>barretenberg.js: 0.6.1</summary>

##
[0.6.1](barretenberg.js-v0.5.2...barretenberg.js-v0.6.1)
(2023-09-08)


### Miscellaneous

* **master:** Release 0.5.2
([#2141](#2141))
([451aad6](451aad6))
* Release 0.5.2
([f76b53c](f76b53c))
* Release 0.6.1
([1bd1a79](1bd1a79))
</details>

<details><summary>barretenberg: 0.6.1</summary>

##
[0.6.1](barretenberg-v0.5.2...barretenberg-v0.6.1)
(2023-09-08)


### Bug Fixes

* Work around intermittent wasm webkit issue
([#2140](#2140))
([a9b0934](a9b0934))


### Miscellaneous

* **master:** Release 0.5.2
([#2141](#2141))
([451aad6](451aad6))
* Release 0.5.2
([f76b53c](f76b53c))
* Release 0.6.1
([1bd1a79](1bd1a79))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
AztecBot pushed a commit to AztecProtocol/barretenberg that referenced this pull request Sep 8, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>aztec-packages: 0.6.1</summary>

##
[0.6.1](AztecProtocol/aztec-packages@aztec-packages-v0.5.2...aztec-packages-v0.6.1)
(2023-09-08)


### Features

* Example card game
([#2135](AztecProtocol/aztec-packages#2135))
([9084b89](AztecProtocol/aztec-packages@9084b89))


### Bug Fixes

* **tests:** Increase test timeout
([#2144](AztecProtocol/aztec-packages#2144))
([7da9615](AztecProtocol/aztec-packages@7da9615))
* Work around intermittent wasm webkit issue
([#2140](AztecProtocol/aztec-packages#2140))
([a9b0934](AztecProtocol/aztec-packages@a9b0934))


### Miscellaneous

* **build:** Updated release please config
([#2142](AztecProtocol/aztec-packages#2142))
([e119c4f](AztecProtocol/aztec-packages@e119c4f))
* **build:** Updated version check
([#2145](AztecProtocol/aztec-packages#2145))
([4ed5f05](AztecProtocol/aztec-packages@4ed5f05))
* **master:** Release 0.5.2
([#2141](AztecProtocol/aztec-packages#2141))
([451aad6](AztecProtocol/aztec-packages@451aad6))
* Release 0.5.2
([f76b53c](AztecProtocol/aztec-packages@f76b53c))
* Release 0.6.1
([1bd1a79](AztecProtocol/aztec-packages@1bd1a79))
</details>

<details><summary>barretenberg.js: 0.6.1</summary>

##
[0.6.1](AztecProtocol/aztec-packages@barretenberg.js-v0.5.2...barretenberg.js-v0.6.1)
(2023-09-08)


### Miscellaneous

* **master:** Release 0.5.2
([#2141](AztecProtocol/aztec-packages#2141))
([451aad6](AztecProtocol/aztec-packages@451aad6))
* Release 0.5.2
([f76b53c](AztecProtocol/aztec-packages@f76b53c))
* Release 0.6.1
([1bd1a79](AztecProtocol/aztec-packages@1bd1a79))
</details>

<details><summary>barretenberg: 0.6.1</summary>

##
[0.6.1](AztecProtocol/aztec-packages@barretenberg-v0.5.2...barretenberg-v0.6.1)
(2023-09-08)


### Bug Fixes

* Work around intermittent wasm webkit issue
([#2140](AztecProtocol/aztec-packages#2140))
([a9b0934](AztecProtocol/aztec-packages@a9b0934))


### Miscellaneous

* **master:** Release 0.5.2
([#2141](AztecProtocol/aztec-packages#2141))
([451aad6](AztecProtocol/aztec-packages@451aad6))
* Release 0.5.2
([f76b53c](AztecProtocol/aztec-packages@f76b53c))
* Release 0.6.1
([1bd1a79](AztecProtocol/aztec-packages@1bd1a79))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Create a card-game Aztec noir example
3 participants