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: Connect CPU to ECALL tables #364

Merged
merged 65 commits into from
Mar 20, 2024
Merged

feat: Connect CPU to ECALL tables #364

merged 65 commits into from
Mar 20, 2024

Conversation

hidenori-shinohara
Copy link
Contributor

No description provided.

DEVELOPMENT.md Outdated
RUST_LOG=info RUST_BACKTRACE=1 cargo test syscall::precompiles::edwards::ed_add::tests::test_ed_add_simple --features debug --no-default-features --release -- --nocapture
```

RUST_LOG=info RUST_BACKTRACE=1 cargo test syscall::precompiles::edwards::ed_add::tests::test_ed_add_simple --no-default-features --release -- --nocapture
Copy link
Member

Choose a reason for hiding this comment

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

remove

}

/// Receives a ecall operation to be processed.
fn receive_ecall<EShard, EClk, Ea, Eb, Ec, EMult>(
Copy link
Member

Choose a reason for hiding this comment

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

should we standardize ecall / syscall naming? maybe it should be ecall everywhere?

core/src/cpu/trace.rs Outdated Show resolved Hide resolved

/// A system call is invoked by the the `ecall` instruction with a specific value in register t0.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter, CheckSyscallConsistency)]
Copy link
Member

Choose a reason for hiding this comment

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

IMO this would be cleaner in the unit test module rather than derive, maybe like this:

#[test]
fn test_syscall_codes_consistent() {
    check_syscall_consistency!(SyscallCode)
}

Copy link
Member

Choose a reason for hiding this comment

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

oh were you trying to do that I see the import in tests


/// A system call is invoked by the the `ecall` instruction with a specific value in register t0.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, EnumIter, CheckSyscallConsistency)]
#[allow(non_camel_case_types)]
pub enum SyscallCode {
Copy link
Member

Choose a reason for hiding this comment

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

needs comment explaining the slots

Comment on lines 29 to 37
println!("reading in ht");
let mut hx = [0u32; 8];
for i in 0..8 {
let (record, value) = rt.mr(w_ptr + (H_START_IDX + i as u32) * 4);
let (record, value) = rt.mr(h_ptr + i as u32 * 4);
h_read_records.push(record);
hx[i] = value;
rt.clk += 4;
}

println!("reading in w");
Copy link
Member

Choose a reason for hiding this comment

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

remove

@@ -31,6 +31,7 @@ impl<F: PrimeField> MachineAir<F> for ShaCompressChip {
let mut new_field_events = Vec::new();
for i in 0..input.sha_compress_events.len() {
let mut event = input.sha_compress_events[i].clone();
// println!("event: {:?}", event);
Copy link
Member

Choose a reason for hiding this comment

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

remove

io_test.sh Outdated Show resolved Hide resolved
@@ -23,7 +23,7 @@ impl Syscall for SyscallEnterUnconstrained {
record: std::mem::take(&mut ctx.rt.record),
op_record: std::mem::take(&mut ctx.rt.memory_accesses),
};
1
None
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be 1, that's how the program knows to enter unconstrained mode. But in the VM it actually needs to be constrained to return 0. Also, the exit syscall needs to return 0.

@@ -0,0 +1 @@
RUST_LOG=debug cargo test --package sp1-core --lib -- syscall::precompiles::weierstrass::weierstrass_add::tests::test_secp256k1_add_simple --exact --nocapture
Copy link
Member

Choose a reason for hiding this comment

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

remove

@puma314 puma314 changed the title wip: Connect CPU to ECALL tables feat: Connect CPU to ECALL tables Mar 19, 2024
@puma314 puma314 marked this pull request as ready for review March 20, 2024 00:21
DEVELOPMENT.md Outdated
```
RUST_LOG=info RUST_BACKTRACE=1 cargo test syscall::precompiles::edwards::ed_add::tests::test_ed_add_simple --features debug --no-default-features --release -- --nocapture
RUS_LOG=info RUST_BACKTRACE=1 cargo test syscall::precompiles::edwards::ed_add::tests::test_ed_add_simple --release --features debug --no-default-features -- --nocapture
Copy link
Member

Choose a reason for hiding this comment

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

RUST_LOG

} else {
a = syscall_id; // By default just keep the register value the same as it was before.
// Default to syscall_id if no value is returned from syscall execution.
a = syscall_id;
}
(precompile_rt.next_pc, syscall_impl.num_extra_cycles())
} else {
panic!("Unsupported syscall: {:?}", syscall);
(0, 0)
Copy link
Member

Choose a reason for hiding this comment

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

remove

Comment on lines +261 to +263
let send_to_table = syscall_code[1]; // Does the syscall have a table that should be sent.
let num_cycles = syscall_code[2]; // How many extra cycles to increment the clk for the syscall.
let is_halt = syscall_code[3]; // Whether or not the syscall is a halt.
Copy link
Member

Choose a reason for hiding this comment

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

might need to check that send_to_table and is_halt are bool

core/src/runtime/syscall.rs Outdated Show resolved Hide resolved
@puma314 puma314 merged commit 45c680f into main Mar 20, 2024
5 checks passed
@puma314 puma314 deleted the hide/alu-comprocessor branch March 20, 2024 01:48
jtguibas pushed a commit that referenced this pull request Mar 29, 2024
Co-authored-by: Uma Roy <[email protected]>
Co-authored-by: Chris Tian <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants