Skip to content

Commit

Permalink
Merge pull request #2 from Eoracle/develop
Browse files Browse the repository at this point in the history
DEV-v0.0.7
  • Loading branch information
uri-lightblocks committed Apr 11, 2024
2 parents 4a2af08 + 9c2b125 commit 93a52cd
Show file tree
Hide file tree
Showing 11 changed files with 2,942 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @uri-lightblocks @fbaralle @ArielLaub @RonTuretzky
21 changes: 21 additions & 0 deletions .github/workflows/enforce_branch_name.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Enforce Branch Name

on:
push:
branches:
- "*"

jobs:
enforce_branch_name:
runs-on: ubuntu-latest

steps:
- name: Check Branch Name
run: |
regular_branch_pattern='^DEV-[0-9]{3,}.*$'
hotfix_branch_pattern='^HF-.*$'
branch_name=$(echo $GITHUB_REF | sed 's/refs\/heads\///')
if [[ ! $branch_name =~ $regular_zranch_patter && ! $branch_name =~ $hotfix_branch_pattern ]]; then
echo "Branch name $branch_name does not match the required patterns."
exit 1
fi
60 changes: 60 additions & 0 deletions .github/workflows/operator_cli_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Operator CLI Build
on:
push:
branches:
- "*"

jobs:
go_build:
name: Operator CLI
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup Go Environment
uses: actions/setup-go@v5

- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0

- name: Build Operator CLI
run: |
make build-oprcli-arm64
make build-oprcli-amd64
- name: 'Reproduce Builds'
run: |
cp bin/oprcli-arm64 bin/oprcli-arm64-1
cp bin/oprcli-amd64 bin/oprcli-amd64-1
make build-oprcli-arm64
make build-oprcli-amd64
buildsha1=$(shasum -a256 ./oprcli-arm64-1 | awk '{print $1}')
buildsha2=$(shasum -a256 ./oprcli-arm64 | awk '{print $1}')
echo "Arm64 Build 1 SHA: $buildsha1"
echo "Arm64 Build 2 SHA: $buildsha2"
if [ "$buildsha1" != "$buildsha2" ]; then
echo "Arm64 build artifact does not match original"
exit 1
else
echo "Arm64 Build artifact matches original"
fi
buildsha1=$(shasum -a256 ./oprcli-amd64-1 | awk '{print $1}')
buildsha2=$(shasum -a256 ./oprcli-amd64 | awk '{print $1}')
echo "Amd64 Build 1 SHA: $buildsha1"
echo "Amd64 Build 2 SHA: $buildsha2"
if [ "$buildsha1" != "$buildsha2" ]; then
echo "Amd64 build artifact does not match original"
exit 1
else
echo "Amd64 Build artifact matches original"
fi
103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Release
on:
push:
branches-ignore:
- '**'
tags:
- 'v*.*.*'
# to be used by fork patch-releases ^^
- 'v*.*.*-*'

permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
env:
DOCKER_CONFIG: $HOME/.docker

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go Environment
uses: actions/setup-go@v5

- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Run GoReleaser build
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: build --clean --parallelism 3 --config build/.goreleaser-operatorcli.yml

- name: Check if the release already exists
id: check_release
run: |
if gh release view ${{ github.ref_name }} 2>/dev/null; then
echo "::set-output name=exists::true"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Delete existing release
if: steps.check_release.outputs.exists == 'true'
run: gh release delete ${{ github.ref_name }} -y
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser Release
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean --parallelism 3 --config build/.goreleaser-operatorcli.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Save docker digest by tag
id: docker_digest_bytag
run: |
opr_cli_amd64=$(docker inspect eoracle/opr_cli:${{ github.ref_name }}-amd64 | jq -r '.[].RepoDigests[]')
opr_cli_arm64=$(docker inspect eoracle/opr_cli:${{ github.ref_name }}-arm64 | jq -r '.[].RepoDigests[]')
echo "eoracle/opr_cli:${{ github.ref_name }}-amd64: $opr_cli_amd64" > dockers_digest.txt
echo "eoracle/opr_cli:${{ github.ref_name }}-arm64: $opr_cli_arm64" >> dockers_digest.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update docker latest tag if needed
run: |
NEW_TAG="${{ github.ref_name }}"
HIGHEST_TAG=$(git tag | sort -V | tail -n 1)
if [ "$NEW_TAG" == "$HIGHEST_TAG" ]; then
export DOCKER_CLI_EXPERIMENTAL=enabled
docker tag eoracle/opr_cli:${{ github.ref_name }}-amd64 eoracle/opr_cli:latest-amd64
docker tag eoracle/opr_cli:${{ github.ref_name }}-arm64 eoracle/opr_cli:latest-arm64
docker push eoracle/opr_cli:latest-amd64
docker push eoracle/opr_cli:latest-arm64
docker manifest create eoracle/opr_cli:latest \
--amend eoracle/opr_cli:latest-amd64 \
--amend eoracle/opr_cli:latest-arm64
docker manifest push eoracle/opr_cli:latest
opr_cli_amd64=$(docker inspect eoracle/opr_cli:latest-amd64 | jq -r '.[].RepoDigests[]')
opr_cli_arm64=$(docker inspect eoracle/opr_cli:latest-arm64 | jq -r '.[].RepoDigests[]')
echo "eoracle/opr_cli:latest-amd64: $opr_cli_amd64" > dockers_digest.txt
echo "eoracle/opr_cli:latest-arm64: $opr_cli_arm64" >> dockers_digest.txt
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Docker digest file to GitHub release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dockers_digest.txt
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/
dist/

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# Project files
.keystore
.DS_Store

# Docker configuration
.docker
20 changes: 20 additions & 0 deletions cmd/operatorcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var commandPrintStatus = &cli.Command{
flag.PassphraseFlag,
flag.KeyStorePathFlag,
flag.EcdsaPrivateKeyFlag,
flag.QuorumNumberFlag,
},
}

Expand All @@ -83,6 +84,20 @@ var commandGenerateBLSKey = &cli.Command{
Flags: []cli.Flag{},
}

var commandEOChainSetAlias = &cli.Command{
Name: "eochain-set-alias",
Description: "Create or Import a ECDSA private key only for oracle chain. The command can also update the eochain with the alias",
Action: runEOChainSetAlias,
Flags: []cli.Flag{
flag.EcdsaPrivateKeyFlag,
flag.PassphraseFlag,
flag.KeyStorePathFlag,
flag.EOChainEthRPCFlag,
flag.EncryptOnlyFlag,
flag.EOConfigFlag,
},
}

func main() {
app := cli.NewApp()
app.Name = "operatorCli"
Expand All @@ -95,6 +110,7 @@ func main() {
commandDeregister,
commandPrintStatus,
commandGenerateBLSKey,
commandEOChainSetAlias,
}

if err := app.Run(os.Args); err != nil {
Expand Down Expand Up @@ -126,3 +142,7 @@ func runPrintStatus(c *cli.Context) error {
func runGenerateBLSKey(c *cli.Context) error {
return operatorcli.RunGenerateBLSKey(c)
}

func runEOChainSetAlias(c *cli.Context) error {
return operatorcli.RunEOChainSetAlias(c)
}
2,539 changes: 2,539 additions & 0 deletions contracts/bindings/EOConfig/binding.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions contracts/generate-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,10 @@ for contract in $el_contracts; do
create_binding ../../eoracle-middleware/lib/eigenlayer-contracts $contract ./bindings
sleep 1
done

# Create bindings for the eoconfig contract in eochain
eo_contracts="EOConfig"
for contract in $eo_contracts; do
create_binding ../../lb-contracts $contract ./bindings
sleep 1
done
1 change: 1 addition & 0 deletions docker-entrypoint-oprcli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ STARTUP="oprcli $@"
echo "$PROGNAME: Starting $STARTUP"
if [[ "$(id -u)" = '0' ]]; then
cd ${WORKDIR}
find . \! -type l \! -user ${USER} -exec chown ${USER}:${GROUP} '{}' +
exec su-exec ${USER} ${STARTUP}
else
# allow the container to be started with `--user`, in this case we cannot use su-exec
Expand Down
17 changes: 17 additions & 0 deletions internal/flag/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,21 @@ var (
DefaultText: "0",
Value: 0,
}
EOChainEthRPCFlag = &cli.StringFlag{
Name: "eochaineth-rpc",
Usage: "eochain ethereum rpc url",
EnvVars: []string{"EO_CHAIN_ETH_RPC"},
}
EncryptOnlyFlag = &cli.BoolFlag{
Name: "encrypt-only",
Usage: "Indication if the key should be just encrypted",
EnvVars: []string{"EO_CHAIN_ENCRYPT_ONLY"},
DefaultText: "False",
Value: false,
}
EOConfigFlag = &cli.StringFlag{
Name: "eoconfig",
Usage: "eoconfig contract address",
EnvVars: []string{"EO_EOCONFIG"},
}
)
Loading

0 comments on commit 93a52cd

Please sign in to comment.