-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into refactor/wrap-error-elcontracts
- Loading branch information
Showing
25 changed files
with
1,025 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Bindings | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
pull_request: | ||
merge_group: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
generate_bindings: | ||
name: Generate bindings | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install go1.21 | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "1.21" | ||
|
||
- name: Add Ethereum PPA | ||
run: sudo add-apt-repository -y ppa:ethereum/ethereum | ||
|
||
- name: Install Abigen | ||
run: sudo apt-get update && sudo apt-get install ethereum | ||
|
||
- name: Show abigen version | ||
run: abigen --version | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: v0.3.0 | ||
|
||
- name: Run make bindings | ||
run: make bindings | ||
|
||
check_bindings: | ||
name: Check bindings are up-to-date | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
# This step is needed to know if the contracts were changed. | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
contracts: | ||
- 'contracts/lib/**' | ||
- 'contracts/script/**' | ||
- 'contracts/src/**' | ||
bindings: | ||
- 'contracts/bindings/**' | ||
# This step runs only if some contract changed. | ||
# It checks whether the bindings directory have changed. | ||
# If there are no changes, then the bindings are outdated | ||
# and therefore this step will fail. | ||
- name: Check the bindings are up-to-date | ||
if: steps.filter.outputs.contracts == 'true' | ||
run: | | ||
BINDINGS_UPDATED=${{ steps.filter.outputs.bindings }} | ||
if [[ "$BINDINGS_UPDATED" == "false" ]]; then | ||
echo "The bindings are outdated"; | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Check anvil state | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
pull_request: | ||
merge_group: | ||
|
||
jobs: | ||
generate-anvil-state: | ||
name: generate anvil state | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: stable | ||
|
||
- name: Generate anvil state | ||
run: make deploy-contracts-to-anvil-and-save-state | ||
|
||
check-anvil-state: | ||
name: Check anvil dump is up-to-date | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# This step is needed to know if the contracts were changed. | ||
- uses: dorny/paths-filter@v3 | ||
id: filter | ||
with: | ||
filters: | | ||
contracts: | ||
- 'contracts/lib/**' | ||
- 'contracts/script/**' | ||
- 'contracts/src/**' | ||
anvil_state: | ||
- 'contracts/anvil/contracts-deployed-anvil-state.json' | ||
# This step runs only if some contract changed. | ||
# It checks whether the anvil state has changed. | ||
# If there are no changes, then the anvil state is outdated | ||
# and therefore this step will fail. | ||
- name: Check the anvil state is up-to-date | ||
if: steps.filter.outputs.contracts == 'true' | ||
run: | | ||
ANVIL_STATE_UPDATED=${{ steps.filter.outputs.anvil_state }} | ||
if [[ "$ANVIL_STATE_UPDATED" == "false" ]]; then | ||
echo "The anvil state is outdated"; | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Contracts CI | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [ '**' ] | ||
|
||
env: | ||
FOUNDRY_PROFILE: ci | ||
|
||
jobs: | ||
check: | ||
strategy: | ||
fail-fast: true | ||
|
||
name: Foundry project | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./contracts | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Install Foundry | ||
uses: foundry-rs/foundry-toolchain@v1 | ||
with: | ||
version: stable | ||
|
||
- name: Show Forge version | ||
run: forge --version | ||
|
||
- name: Run Forge fmt | ||
run: forge fmt --check | ||
|
||
- name: Run Forge build | ||
run: forge build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package avsregistry_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/Layr-Labs/eigensdk-go/crypto/bls" | ||
"github.com/Layr-Labs/eigensdk-go/testutils" | ||
"github.com/Layr-Labs/eigensdk-go/testutils/testclients" | ||
"github.com/Layr-Labs/eigensdk-go/types" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSubscriberAvsRegistry(t *testing.T) { | ||
client, _ := testclients.BuildTestClients(t) | ||
chainSubscriber := client.AvsRegistryChainSubscriber | ||
chainWriter := client.AvsRegistryChainWriter | ||
|
||
t.Run("subscribe to new pubkey registrations", func(t *testing.T) { | ||
pubKeyRegistrationsC, event, err := chainSubscriber.SubscribeToNewPubkeyRegistrations() | ||
require.NoError(t, err) | ||
defer event.Unsubscribe() | ||
|
||
// Emit a NewPubkeyRegistration event creating a new operator | ||
keypair, err := bls.NewKeyPairFromString("0x01") | ||
require.NoError(t, err) | ||
|
||
ecdsaPrivateKey, err := crypto.HexToECDSA(testutils.ANVIL_FIRST_PRIVATE_KEY) | ||
require.NoError(t, err) | ||
|
||
quorumNumbers := types.QuorumNums{0} | ||
|
||
receipt, err := chainWriter.RegisterOperator( | ||
context.Background(), | ||
ecdsaPrivateKey, | ||
keypair, | ||
quorumNumbers, | ||
"", | ||
true, | ||
) | ||
require.NoError(t, err) | ||
require.NotNil(t, receipt) | ||
|
||
select { | ||
case newPubkeyRegistration := <-pubKeyRegistrationsC: | ||
expectedOperator := crypto.PubkeyToAddress(ecdsaPrivateKey.PublicKey) | ||
assert.Equal(t, expectedOperator, newPubkeyRegistration.Operator) | ||
case <-time.After(10 * time.Second): | ||
// Throw an error if the event is not received within 10 seconds, making the test fail | ||
t.Fatal("Timed out waiting for NewPubkeyRegistration event") | ||
} | ||
}) | ||
|
||
t.Run("subscribe to operator socket updates", func(t *testing.T) { | ||
socketC, event, err := chainSubscriber.SubscribeToOperatorSocketUpdates() | ||
require.NoError(t, err) | ||
defer event.Unsubscribe() | ||
|
||
// Emit a SocketUpdate event | ||
socketUpdate := "socket-update" | ||
receipt, err := chainWriter.UpdateSocket(context.Background(), types.Socket(socketUpdate), true) | ||
require.NoError(t, err) | ||
require.NotNil(t, receipt) | ||
|
||
select { | ||
case operatorSocketUpdate := <-socketC: | ||
assert.Equal(t, socketUpdate, operatorSocketUpdate.Socket) | ||
case <-time.After(10 * time.Second): | ||
// Throw an error if the event is not received within 10 seconds, making the test fail | ||
t.Fatal("Timed out waiting for OperatorSocketUpdate event") | ||
} | ||
}) | ||
} |
Oops, something went wrong.