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

Waylon/eip4844 #536

Closed
wants to merge 36 commits into from
Closed

Waylon/eip4844 #536

wants to merge 36 commits into from

Conversation

0xJepsen
Copy link
Contributor

@0xJepsen 0xJepsen commented Jul 1, 2023

Closes #526
Should be good for review!

@Autoparallel
Copy link
Contributor

Autoparallel commented Jul 15, 2023

Some tasks for us:

  • Write verify_kzg_proof()
  • Fix the type for BLS_MODULUS (no more BigInt)
  • Write tests and hunt for bugs.
  • Get CI/CD to pass.

I can take the first task and I am more than happy to write tests 🙂

@Autoparallel
Copy link
Contributor

We will test the point_evaluation_run now

Should be good to go.
Should be good to go. Cleaned and commented.
remove old
fix return
@0xJepsen 0xJepsen marked this pull request as ready for review August 1, 2023 13:46
// and otherwise with a zeroed bytes32 value. The opcode has a gas cost of HASH_OPCODE_GAS.
gas!(interpreter, gas::HASH_OPCODE_GAS);
pop!(interpreter, index);
let index = as_usize_or_fail!(interpreter, index, InstructionResult::InvalidOperandOOG);
Copy link
Member

Choose a reason for hiding this comment

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

Should it fail or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No i don't think it should, can i use as_usize_saturated!() here instead?

// and replaces it on the stack with tx.blob_versioned_hashes[index] if index < len(tx.blob_versioned_hashes),
// and otherwise with a zeroed bytes32 value. The opcode has a gas cost of HASH_OPCODE_GAS.
gas!(interpreter, gas::HASH_OPCODE_GAS);
pop!(interpreter, index);
Copy link
Member

Choose a reason for hiding this comment

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

see pop_top! in other instructions

} else {
// else write out a zerod out 32 bytes
let bytes: [u8; 32] = [0; 32];
push!(interpreter, U256::from_be_bytes(bytes));
Copy link
Member

Choose a reason for hiding this comment

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

is this just U256::zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, thats cleaner.

/// See: https://eips.ethereum.org/EIPS/eip-4844
pub fn point_evaluation_run(input: &[u8], gas_limit: u64) -> PrecompileResult {
// The data is encoded as follows: versioned_hash | z | y | commitment | proof | with z and y being padded 32 byte big endian values
assert!(input.len() == 192);
Copy link
Member

@rakita rakita Aug 8, 2023

Choose a reason for hiding this comment

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

Is this good assumption? what to do if it is less or more?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps not, Can we through an error if they aren't equal. Something like

    if input.len() != 192 {
        return Err(Error::InvalidInputLength);
    }

let versioned_hash = Bytes48::from_bytes(&input[0..32]).unwrap();
let proof = Bytes48::from_bytes(&input[144..192]).unwrap();
let kzg_settings = c_kzg::KzgSettings::load_trusted_setup_file(
"crates/precompile/src/trusted_setup4.txt".into(),
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this file in runtime? Where should be placed

Copy link
Contributor Author

@0xJepsen 0xJepsen Aug 9, 2023

Choose a reason for hiding this comment

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

This is a mock trusted setup from that was used for testing with the EF audited bindings from c-kzg, afaik we do need it at runtime and should replace it with the official trusted set up once the ceremony is finished. I am not sure where it should live so i put it here. Do you think it should go in a different directory?

@@ -24,6 +24,7 @@ tokio = { version = "1.28", features = ["rt-multi-thread", "macros"], optional =
ethers-providers = { version = "2.0", optional = true }
ethers-core = { version = "2.0", optional = true }
futures = { version = "0.3.27", optional = true }
rust-kzg = "0.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.

Is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No i was using it at one point when writing the point verification by hand prior to using the EF bindings.

@rakita rakita mentioned this pull request Aug 10, 2023
5 tasks
@rakita
Copy link
Member

rakita commented Aug 31, 2023

Closing in support for #668

@rakita rakita closed this Aug 31, 2023
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.

EIP-4844: Shard Blob Transactions
4 participants