Skip to content

Commit decd1c7

Browse files
IAvecillaPatStilesuri-99
authored
feat: migrate cbor lib and add Fuzzer for cbor serialization (#1110)
Co-authored-by: PatStiles <[email protected]> Co-authored-by: Urix <[email protected]>
1 parent 6b1a4ae commit decd1c7

File tree

10 files changed

+238
-90
lines changed

10 files changed

+238
-90
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,22 @@ update_operator:
121121
@make build_operator
122122
@./operator/build/aligned-operator --version
123123

124+
operator_valid_marshall_fuzz_macos:
125+
@cd operator/pkg && go test -fuzz=FuzzValidMarshall -ldflags=-extldflags=-Wl,-ld_classic
126+
127+
operator_valid_marshall_fuzz_linux:
128+
@cd operator/pkg && \
129+
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
130+
go test -fuzz=FuzzValidMarshall
131+
132+
operator_marshall_unmarshall_fuzz_macos:
133+
@cd operator/pkg && go test -fuzz=FuzzMarshalUnmarshal -ldflags=-extldflags=-Wl,-ld_classic
134+
135+
operator_marshall_unmarshall_fuzz_linux:
136+
@cd operator/pkg && \
137+
LD_LIBRARY_PATH=$(LD_LIBRARY_PATH):$(CURDIR)/operator/risc_zero/lib \
138+
go test -fuzz=FuzzMarshalUnmarshal
139+
124140
bindings:
125141
cd contracts && ./generate-go-bindings.sh
126142

common/proving_systems.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"encoding/json"
55
"fmt"
66
"log"
7+
8+
"github.com/fxamacker/cbor/v2"
79
)
810

911
type ProvingSystemId uint16
@@ -96,6 +98,32 @@ func (t *ProvingSystemId) UnmarshalBinary(data []byte) error {
9698
return err
9799
}
98100

101+
func (s *ProvingSystemId) UnmarshalCBOR(data []byte) error {
102+
var statusStr string
103+
if err := cbor.Unmarshal(data, &statusStr); err != nil {
104+
return err
105+
}
106+
107+
switch statusStr {
108+
case "GnarkPlonkBls12_381":
109+
*s = GnarkPlonkBls12_381
110+
case "GnarkPlonkBn254":
111+
*s = GnarkPlonkBn254
112+
case "Groth16Bn254":
113+
*s = Groth16Bn254
114+
case "SP1":
115+
*s = SP1
116+
case "Halo2KZG":
117+
*s = Halo2KZG
118+
case "Halo2IPA":
119+
*s = Halo2IPA
120+
case "Risc0":
121+
*s = Risc0
122+
}
123+
124+
return nil
125+
}
126+
99127
func (t ProvingSystemId) MarshalBinary() ([]byte, error) {
100128
// needs to be defined but should never be called
101129
return nil, fmt.Errorf("not implemented")

docs/3_guides/6_setup_aligned.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ Before starting, you need to set up an S3 bucket. More data storage will be test
5050

5151
You need to fill the data in:
5252

53-
```batcher/aligned-batcher/.env```
53+
`batcher/aligned-batcher/.env`
5454

5555
And you can use this file as an example of how to fill it:
5656

57-
```batcher/aligned-batcher/.env.example```
57+
`batcher/aligned-batcher/.env.example`
5858

5959
After having the env setup, run in different terminals the following commands to boot Aligned locally:
6060

@@ -108,15 +108,15 @@ Note that when upgrading the contracts, you must also:
108108

109109
1. Re-generate the Go smart contract bindings:
110110

111-
```bash
112-
make bindings
113-
```
111+
```bash
112+
make bindings
113+
```
114114

115115
2. Rebuild Aggregator and Operator Go binaries:
116116

117-
```bash
118-
make build_binaries
119-
```
117+
```bash
118+
make build_binaries
119+
```
120120

121121
</details>
122122

@@ -324,7 +324,7 @@ batcher (`batcher/aligned-batcher/`).
324324
The necessary environment variables are:
325325

326326
| Variable Name | Description |
327-
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|
327+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
328328
| AWS_SECRET_ACCESS_KEY | Secret key to authenticate and authorize API requests to the AWS S3 Bucket. |
329329
| AWS_REGION | Geographical region where the AWS S3 Bucket will be accessed. |
330330
| AWS_ACCESS_KEY_ID | Access key used in combination with the AWS_SECRET_ACCESS_KEY to authenticate and authorize API requests to the AWS S3 Bucket. |
@@ -660,7 +660,7 @@ Create a `.env` file in the `/explorer` directory of the project.
660660
The `.env` file needs to contain the following variables:
661661

662662
| Variable | Description |
663-
|-----------------------|-------------------------------------------------------------------------------------------------|
663+
| --------------------- | ----------------------------------------------------------------------------------------------- |
664664
| `RPC_URL` | The RPC URL of the network you want to connect to. |
665665
| `ENVIRONMENT` | The environment you want to run the application in. It can be `devnet`, `holesky` or `mainnet`. |
666666
| `ALIGNED_CONFIG_FILE` | The config file containing Aligned contracts' deployment information |
@@ -719,18 +719,34 @@ forge install Layr-Labs/eigenlayer-middleware@mainnet
719719

720720
Then, to solve the issue<https://github.com/Layr-Labs/eigenlayer-middleware/issues/229>, we changed it to:
721721

722-
```forge install yetanotherco/eigenlayer-middleware@yac-mainnet --no-commit```
722+
`forge install yetanotherco/eigenlayer-middleware@yac-mainnet --no-commit`
723723

724724
As soon as it gets fixed in mainnet, we can revert it.
725725

726-
Base version of middleware used is ```7229f2b```.
726+
Base version of middleware used is `7229f2b`.
727727

728-
The script to initialize the devnet can be found on ```contracts/scripts/anvil```.
728+
The script to initialize the devnet can be found on `contracts/scripts/anvil`.
729729

730730
The addresses of the relevant contracts after running the anvil script are dumped
731-
on ```contracts/script/output/devnet```.
731+
on `contracts/script/output/devnet`.
732732

733-
The state is backed up on ```contracts/scripts/anvil/state```.
733+
The state is backed up on `contracts/scripts/anvil/state`.
734734

735735
EigenLayer contract deployment is almost the same as the EigenLayer contract deployment on mainnet.
736736
Changes are described in the file.
737+
738+
## Running Fuzzers:
739+
740+
Fuzzing for the operator can be done by executing the following make commands from the root directory of the project.
741+
742+
macOS:
743+
744+
```
745+
make operator_verification_data_fuzz_macos
746+
```
747+
748+
Linux:
749+
750+
```
751+
operator_verification_data_fuzz_linux
752+
```

0 commit comments

Comments
 (0)