Skip to content

Commit

Permalink
Merge branch 'staging' into renovate/node-22.x
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiam86 authored Dec 10, 2024
2 parents ed23212 + b726fc7 commit f2a86c2
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ VITE_IS_HOSTED = 'false'

FRONTEND_BUILD_TARGET = 'final' # change to 'dev' to run in dev mode

# Backend Configuration
BACKEND_BUILD_TARGET = 'debug' # change to 'prod' or remove to run in prod mode

# Hardhat port
HARDHAT_URL = 'http://hardhat'
HARDHAT_PORT = '8545'
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/docker-build-and-push-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ jobs:
dockerhub_username: ${{ vars.DOCKERHUB_USERNAME }}
secrets:
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}

hardhat:
uses: ./.github/workflows/docker-build-and-push-image.yml
with:
docker_build_context: .
dockerfile: docker/Dockerfile.hardhat
dockerhub_repo: yeagerai/simulator-hardhat
dockerhub_username: ${{ vars.DOCKERHUB_USERNAME }}
secrets:
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
- run: pip install pytest-cov
- run: pytest tests/unit --cov=backend --cov-report=xml --cov-branch
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@v3.0.0
uses: sonarsource/sonarcloud-github-action@v4.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
51 changes: 28 additions & 23 deletions backend/consensus/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,33 +573,38 @@ async def _appeal_window(self):
FINALITY_WINDOW = int(os.getenv("FINALITY_WINDOW"))
print(" ~ ~ ~ ~ ~ FINALITY WINDOW: ", FINALITY_WINDOW)
while True:
with self.get_session() as session:
chain_snapshot = ChainSnapshot(session)
transactions_processor = TransactionsProcessor(session)
accepted_transactions = chain_snapshot.get_accepted_transactions()
for transaction in accepted_transactions:
transaction = transaction_from_dict(transaction)
if not transaction.appealed:
if (
int(time.time()) - transaction.timestamp_accepted
) > FINALITY_WINDOW:
self.finalize_transaction(
try:
with self.get_session() as session:
chain_snapshot = ChainSnapshot(session)
transactions_processor = TransactionsProcessor(session)
accepted_transactions = chain_snapshot.get_accepted_transactions()
for transaction in accepted_transactions:
transaction = transaction_from_dict(transaction)
if not transaction.appealed:
if (
int(time.time()) - transaction.timestamp_accepted
) > FINALITY_WINDOW:
self.finalize_transaction(
transaction,
transactions_processor,
)
session.commit()
else:
transactions_processor.set_transaction_appeal(
transaction.hash, False
)
self.commit_reveal_accept_transaction(
transaction,
transactions_processor,
lambda contract_address: contract_snapshot_factory(
contract_address, session, transaction
),
)
session.commit()
else:
transactions_processor.set_transaction_appeal(
transaction.hash, False
)
self.commit_reveal_accept_transaction(
transaction,
transactions_processor,
lambda contract_address: contract_snapshot_factory(
contract_address, session, transaction
),
)
session.commit()

except Exception as e:
print("Error running consensus", e)
print(traceback.format_exc())

await asyncio.sleep(1)

Expand Down
13 changes: 12 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ services:
- ./backend:/app/backend
- ./hardhat/artifacts:/app/hardhat/artifacts
depends_on:
hardhat:
condition: service_healthy
database-migration:
condition: service_completed_successfully
webrequest:
Expand Down Expand Up @@ -199,7 +201,16 @@ services:
- ./hardhat/scripts:/app/scripts
- ./hardhat/test:/app/test
- ./hardhat/hardhat.config.js:/app/hardhat.config.js
- ./hardhat/artifacts:/app/artifacts
- hardhat_artifacts:/app/artifacts
environment:
- HARDHAT_NETWORK=hardhat
healthcheck:
test: ["CMD", "curl", "-X", "POST", "-H", "Content-Type: application/json", "--fail", "http://localhost:8545", "-d", '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}']
interval: 10s
timeout: 5s
retries: 10
start_period: 10s

volumes:
hardhat_artifacts:

20 changes: 13 additions & 7 deletions docker/Dockerfile.hardhat
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ FROM node:22.12-alpine3.19
RUN addgroup -S hardhat-group && adduser -S hardhat-user -G hardhat-group
WORKDIR /app

RUN apk add --no-cache g++ make netcat-openbsd python3
# Install necessary packages and set up the environment
RUN apk add --no-cache curl g++ make netcat-openbsd python3 && \
# Copy and install npm packages
mkdir -p /app && \
chown -R hardhat-user:hardhat-group /app

COPY ./hardhat/package*.json ./
RUN npm install --ignore-scripts

COPY ./hardhat .

# Change ownership of the app directory to the non-root user
RUN chown -R hardhat-user:hardhat-group /app
# Set up directories and permissions
RUN mkdir -p /app/artifacts/build-info && \
mkdir -p /app/artifacts/contracts && \
chown -R hardhat-user:hardhat-group /app && \
chmod -R 755 /app/artifacts && \
# Create start script
echo -e '#!/bin/sh\necho "Compiling contracts..."\nnpx hardhat compile --force\necho "Starting Hardhat node..."\nexec ./node_modules/.bin/hardhat node --network hardhat' > /app/start.sh && \
chmod +x /app/start.sh

ENV PATH="/app/node_modules/.bin:${PATH}"

RUN echo -e '#!/bin/sh\necho "Compiling contracts..."\nnpx hardhat compile --force\necho "Starting Hardhat node..."\nexec ./node_modules/.bin/hardhat node --network hardhat' > /app/start.sh && \
chmod +x /app/start.sh && \
ls -la /app/start.sh

EXPOSE 8545

# Switch to non-root user
Expand Down
32 changes: 18 additions & 14 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/ui": "^1.6.0",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-prettier": "^10.0.0",
"@vue/eslint-config-typescript": "^13.0.0",
"@vue/test-utils": "^2.4.5",
"@vue/tsconfig": "^0.5.1",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/hooks/useGenlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function useGenlayer() {
function initClient() {
client = createClient({
chain: simulator,
endpoint: import.meta.env.VITE_JSON_RPC_SERVER_URL,
account: createAccount(accountsStore.currentPrivateKey || undefined),
});
}
Expand Down
4 changes: 2 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"npm": {
"minimumReleaseAge": "3 days"
},
"reviewers": ["denishacquin", "AgustinRamiroDiaz"]
}
"reviewers": ["denishacquin", "mpaya5", "kstroobants", "epsjunior"]
}

0 comments on commit f2a86c2

Please sign in to comment.