Skip to content

Commit

Permalink
EigenDA x Nitro V3.0.3 - fix proof generation bug in host-io.rs && re…
Browse files Browse the repository at this point in the history
…moved some dead code
  • Loading branch information
epociask committed Jul 16, 2024
1 parent 86d1e71 commit fbb314a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
7 changes: 2 additions & 5 deletions arbitrator/prover/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,15 @@ pub fn hash_preimage(preimage: &[u8], ty: PreimageType) -> Result<[u8; 32]> {
let blob = EigenDABlob::from_padded_bytes_unchecked(preimage);

let blob_polynomial = blob
.to_polynomial(PolynomialFormat::InEvaluationForm)
.unwrap();
let blob_commitment = kzg_bn254.commit(&blob_polynomial).unwrap();
.to_polynomial(PolynomialFormat::InEvaluationForm)?;
let blob_commitment = kzg_bn254.commit(&blob_polynomial)?;

let mut commitment_bytes = Vec::new();
blob_commitment.serialize_uncompressed(&mut commitment_bytes)?;

let mut commitment_hash: [u8; 32] = Sha256::digest(&commitment_bytes).into();
commitment_hash[0] = 1;

println!("commitment_hash: {:?}", commitment_hash);

Ok(commitment_hash)
}
}
Expand Down
28 changes: 11 additions & 17 deletions arbitrator/prover/test-cases/rust/src/bin/host-io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,25 +108,19 @@ fn main() {

let expected_len = 0;

// for i in 0..5{
// let eigen_hash = hex!("011e229d75b13559dcb2d757ecae9b66fa579268e28e196789503322115c06e1");
// bytebuffer = Bytes32(eigen_hash);

// let actual_len = wavm_read_eigen_da_hash_preimage(bytebuffer.0.as_mut_ptr(), i * 32);

// if i < 4 {
// assert_eq!(actual_len, 32);
// } else {
// assert_eq!(actual_len, 0);
// }
// }

let eigen_hash = hex!("011e229d75b13559dcb2d757ecae9b66fa579268e28e196789503322115c06e1");
for i in 0..5{
let eigen_hash = hex!("011e229d75b13559dcb2d757ecae9b66fa579268e28e196789503322115c06e1");
bytebuffer = Bytes32(eigen_hash);


let actual_len = wavm_read_eigen_da_hash_preimage(bytebuffer.0.as_mut_ptr(), 1);
assert_eq!(actual_len, 32);
let actual_len = wavm_read_eigen_da_hash_preimage(bytebuffer.0.as_mut_ptr(), i * 32);

if i < 4 {
assert_eq!(actual_len, 32);
} else {
assert_eq!(actual_len, 0);
}
}
}

println!("Done!");
}
7 changes: 0 additions & 7 deletions cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,24 +154,17 @@ type EigenDAPreimageReader struct{}
// QueryBlob returns the blob for the given cert from the preimage oracle using the hash of the
// certificate kzg commitment for identifying the preimage.
func (dasReader *EigenDAPreimageReader) QueryBlob(ctx context.Context, cert *eigenda.EigenDABlobInfo, domain string) ([]byte, error) {
println("Querying EigenDA blob")
kzgCommit, err := cert.SerializeCommitment()
if err != nil {
return nil, err
}

println("kzgCommit: ", hex.EncodeToString(kzgCommit))
shaDataHash := sha256.New()
shaDataHash.Write(kzgCommit)
dataHash := shaDataHash.Sum([]byte{})
dataHash[0] = 1

hash := common.BytesToHash(dataHash)
println("Reading EigenDA blob from preimage oracle: ", hash.String())

// 128 byte preimage
// (1) READPREIMAGE -> hash, 0th offset
// (2) READPREIMAGE -> hash, 32 offset
preimage, err := wavmio.ResolveTypedPreimage(arbutil.EigenDaPreimageType, hash)
if err != nil {
return nil, err
Expand Down
6 changes: 1 addition & 5 deletions eigenda/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (c *EigenDAProxyClient) Get(ctx context.Context, blobInfo *DisperserBlobInf
return nil, fmt.Errorf("failed to encode blob info: %w", err)
}

// TODO: support more strict versioning
commitWithVersion := append([]byte{0x0}, commitment...)

data, err := c.client.GetData(ctx, commitWithVersion, StrToDomainType(domainFilter))
Expand Down Expand Up @@ -88,7 +89,6 @@ func StrToDomainType(s string) DomainType {

// TODO: Add support for custom http client option
type Config struct {
Actor string
URL string
}

Expand Down Expand Up @@ -139,10 +139,6 @@ func (c *client) Health() error {
func (c *client) GetData(ctx context.Context, comm []byte, domain DomainType) ([]byte, error) {
url := fmt.Sprintf("%s/get/0x%x?domain=%s&commitment_mode=simple", c.cfg.URL, comm, domain.String())

if c.cfg.Actor != "" {
url = fmt.Sprintf("%s&actor=%s", url, c.cfg.Actor)
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
if err != nil {
return nil, fmt.Errorf("failed to construct http request: %e", err)
Expand Down

0 comments on commit fbb314a

Please sign in to comment.