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: Transcript redesign #2668

Closed
wants to merge 13 commits into from
Closed

Conversation

lucasxia01
Copy link
Contributor

Please provide a paragraph or two giving a summary of the change, including relevant motivation and context.

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).

@lucasxia01 lucasxia01 changed the title refactor: Transcript redesign feat: Transcript redesign Oct 4, 2023
@lucasxia01 lucasxia01 self-assigned this Oct 6, 2023
@lucasxia01 lucasxia01 marked this pull request as draft October 11, 2023 18:05
@codygunton codygunton self-requested a review October 11, 2023 18:32
@AztecBot
Copy link
Collaborator

AztecBot commented Oct 12, 2023

Benchmark results

All benchmarks are run on txs on the Benchmarking contract on the repository. Each tx consists of a batch call to create_note and increment_balance, which guarantees that each tx has a private call, a nested private call, a public call, and a nested public call, as well as an emitted private note, an unencrypted log, and public storage read and write.

This benchmark source data is available in JSON format on S3 here.

Values are compared against data from master at commit bde77b8e and shown if the difference exceeds 1%.

L2 block published to L1

Each column represents the number of txs on an L2 block published to L1.

Metric 8 txs 32 txs 128 txs
l1_rollup_calldata_size_in_bytes 45,444 179,588 716,132
l1_rollup_calldata_gas 222,996 868,220 3,447,788
l1_rollup_execution_gas 842,083 3,595,328 22,203,157
l2_block_processing_time_in_ms ⚠️ 1,241 (+20%) ⚠️ 4,802 (+21%) ⚠️ 18,758 (+20%)
note_successful_decrypting_time_in_ms ⚠️ 384 (+16%) ⚠️ 1,257 (+22%) ⚠️ 4,876 (+28%)
note_trial_decrypting_time_in_ms ⚠️ 88.0 (+144%) 110 (+2%) 144 (+5%)
l2_block_building_time_in_ms ⚠️ 10,888 (+20%) ⚠️ 44,188 (+22%) ⚠️ 188,671 (+24%)
l2_block_rollup_simulation_time_in_ms ⚠️ 8,145 (+21%) ⚠️ 33,362 (+24%) ⚠️ 132,274 (+24%)
l2_block_public_tx_process_time_in_ms ⚠️ 2,700 (+17%) ⚠️ 10,679 (+15%) ⚠️ 55,562 (+24%)

L2 chain processing

Each column represents the number of blocks on the L2 chain where each block has 16 txs.

Metric 5 blocks 10 blocks
node_history_sync_time_in_ms 14,064 (-2%) 30,767 (-2%)
note_history_successful_decrypting_time_in_ms 2,267 (-3%) 4,652 (-1%)
note_history_trial_decrypting_time_in_ms 122 151 (+3%)
node_database_size_in_bytes 1,650,158 1,194,069
pxe_database_size_in_bytes 27,188 54,187

Circuits stats

Stats on running time and I/O sizes collected for every circuit run across all benchmarks.

Circuit circuit_simulation_time_in_ms circuit_input_size_in_bytes circuit_output_size_in_bytes
private-kernel-init 47.9 (+10%) 56,577 14,745
private-kernel-ordering ⚠️ 23.6 (+11%) 20,137 8,089
base-rollup ⚠️ 944 (+11%) 631,605 811
root-rollup 40.7 (+8%) 4,072 1,097
private-kernel-inner ⚠️ 39.9 (+11%) 72,288 14,745
public-kernel-private-input ⚠️ 52.7 (+12%) 37,359 14,745
public-kernel-non-first-iteration 31.2 (+10%) 37,401 14,745
merge-rollup ⚠️ 0.993 (+14%) 2,592 873

Miscellaneous

Transaction sizes based on how many contracts are deployed in the tx.

Metric 0 deployed contracts 1 deployed contracts
tx_size_in_bytes 8,723 27,094

}
}

static std::vector<uint8_t> serializeObj(TranscriptObjectType enum_type, void* obj_ptr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if its possible to replace the void* usage with a type safe union instead, something like:

#include <iostream>
#include <string>
#include <variant>

// Define a structure for each variant 
// (The code already has this defined, see uint32_t, FF, Commitment, ...)
struct VariantOne {
    int value;
};

struct VariantTwo {
    std::string message;
};

// Define the enum as a variant of all of your structures
using TranscriptObjectTypes = std::variant<VariantOne, VariantTwo>;

// Function to handle both variants
void handleVariant(const TranscriptObjectTypes& object_types) {
    std::visit([](auto&& arg) {
        using T = std::decay_t<decltype(arg)>;
        if constexpr (std::is_same_v<T, VariantOne>) {
            std::cout << "Handling VariantOne: " << arg.value << std::endl;
        } 
        else if constexpr (std::is_same_v<T, VariantTwo>) {
            std::cout << "Handling VariantTwo: " << arg.message << std::endl;
        }
    }, object_types);
}

int main() {
    TranscriptObjectTypes object_type = VariantOne{20694};
    handleVariant(object_type);
    
    object_type = VariantTwo{"Hello Rust!"};
    handleVariant(object_type);

    
    return 0;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

This may not be the best way to do it, just pointing out alternatives to void*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgot to respond - thanks for the suggestion! certainly a better solution than void*, but I think msgpack solves these problems

Copy link
Contributor

Choose a reason for hiding this comment

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

can you elaborate how msgpack help this? I don't think msgpack should live at such a low level in the protocol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

msgpack would help get rid of this ordered_objects vector because it handles the serialization/deserialization part. The other use case for ordered_objects was for determining whether the prover and verifier followed the specified ordering. This use case isn't that useful and is mostly for preventing implementation bugs in the prover/verifier that should be caught by other tests, so I think it's fine to not have that.

@codygunton
Copy link
Contributor

Replaced by #2937

@codygunton codygunton closed this Oct 24, 2023
@lucasxia01 lucasxia01 deleted the lx/transcript-structuring branch February 23, 2024 12:09
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.

4 participants