Skip to content

Commit

Permalink
fix/resolve conflict with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiden-araki committed Jan 6, 2025
2 parents 7b62364 + 953bb0a commit 32b447d
Show file tree
Hide file tree
Showing 21 changed files with 380 additions and 430 deletions.
36 changes: 36 additions & 0 deletions .github/rulesets/syb_develop_ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"id": 2539891,
"name": "syb_develop_ruleset",
"target": "branch",
"source_type": "Repository",
"source": "tokamak-network/tokamak-sybil-resistance-mvp",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": [
"refs/heads/develop"
]
}
},
"rules": [
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "pull_request",
"parameters": {
"required_approving_review_count": 1,
"dismiss_stale_reviews_on_push": true,
"require_code_owner_review": true,
"require_last_push_approval": false,
"required_review_thread_resolution": true,
"automatic_copilot_code_review_enabled": false
}
}
],
"bypass_actors": []
}
39 changes: 39 additions & 0 deletions .github/rulesets/syb_main_ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"id": 2539902,
"name": "syb_main_ruleset",
"target": "branch",
"source_type": "Repository",
"source": "tokamak-network/tokamak-sybil-resistance-mvp",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": [
"refs/heads/main"
]
}
},
"rules": [
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "required_linear_history"
},
{
"type": "pull_request",
"parameters": {
"required_approving_review_count": 2,
"dismiss_stale_reviews_on_push": true,
"require_code_owner_review": true,
"require_last_push_approval": false,
"required_review_thread_resolution": true,
"automatic_copilot_code_review_enabled": false
}
}
],
"bypass_actors": []
}
41 changes: 41 additions & 0 deletions .github/rulesets/syb_refactor_ruleset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": 3085803,
"name": "syb_refactor_ruleset",
"target": "branch",
"source_type": "Repository",
"source": "tokamak-network/tokamak-sybil-resistance-mvp",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": [
"refs/heads/refactor"
]
}
},
"rules": [
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "pull_request",
"parameters": {
"required_approving_review_count": 1,
"dismiss_stale_reviews_on_push": true,
"require_code_owner_review": false,
"require_last_push_approval": false,
"required_review_thread_resolution": true,
"automatic_copilot_code_review_enabled": true,
"allowed_merge_methods": [
"merge",
"squash",
"rebase"
]
}
}
],
"bypass_actors": []
}
40 changes: 40 additions & 0 deletions .github/scripts/cleanup_merged_branches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import subprocess
import requests # will be installed during the github action run

# Environment variables
GIT_TOKEN = os.getenv('GIT_TOKEN')
SLACK_WEBHOOK_URL = os.getenv('SLACK_WEBHOOK_URL')

# Git commands
remote_branches_command = "git branch -r --merged origin/develop"
delete_branch_command = "git push origin --delete {}"

# Execute git command to get merged branches
result = subprocess.run(remote_branches_command.split(), capture_output=True, text=True)
merged_branches = result.stdout.splitlines()

# Filter out specific branches
branches_to_delete = [branch.strip() for branch in merged_branches if branch.strip() not in ['origin/develop', 'origin/main', 'origin/refactor']]

# Delete branches and collect deleted branch names
deleted_branches = []
for branch in branches_to_delete:
branch_name = branch.replace('origin/', '')
delete_result = subprocess.run(delete_branch_command.format(branch_name).split(), capture_output=True, text=True)
if delete_result.returncode == 0:
deleted_branches.append(branch_name)

# Send Slack message
if deleted_branches:
message = f"The following branches have been deleted:\n" + "\n".join(deleted_branches)
payload = {"text": message}
response = requests.post(SLACK_WEBHOOK_URL, json=payload)
if response.status_code != 200:
raise ValueError(f"Request to Slack returned an error {response.status_code}, the response is:\n{response.text}")
else:
message = "No branches to delete."
payload = {"text": message}
response = requests.post(SLACK_WEBHOOK_URL, json=payload)
if response.status_code != 200:
raise ValueError(f"Request to Slack returned an error {response.status_code}, the response is:\n{response.text}")
28 changes: 28 additions & 0 deletions .github/workflows/cleanup_merged_branches.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Cleanup Merged Branches

on:
schedule:
- cron: '0 0 * * 0' # Runs every Sunday at midnight
workflow_dispatch:

jobs:
cleanup:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: pip install requests

- name: Run cleanup script
env:
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
run: python .github/scripts/cleanup_merged_branches.py
2 changes: 2 additions & 0 deletions .github/workflows/node.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ jobs:
PGUSER: "postgres"
PGPASSWORD: "postgres"
PGDATABASE: "statedb"
KEYSTORE_PATH: "./var/tokamak/ethkeystore"
KEYSTORE_PASSWORD: "123"
CI: true
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
},
{
"name": "Run Synchronizer Tests",
"type": "go",
"request": "launch",
"mode": "test",
"program": "${workspaceFolder}/sequencer/synchronizer",
"envFile": "${workspaceFolder}/sequencer/.env",
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"solidity.compileUsingRemoteVersion": "v0.8.23+commit.f704f362"
}
19 changes: 18 additions & 1 deletion sequencer/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
APP_MODE=dev # dev, prod

BootCoordinator=
BootCoordinatorURL=

Expand All @@ -6,5 +8,20 @@ PGUSER=postgres
PGPASSWORD=123
PGDATABASE=statedb

# Logging
# Logging for testing
DEBUG=false

# Logging for app
LOG_LEVEL=debug # debug, info, warn, error
OUT_PATH=stdout
MEDDLER_LOGS=false # Enables meddler debug mode, where unused columns and struct fields will be logged

# Keystore
KEYSTORE_PATH="./var/tokamak/ethkeystore"
KEYSTORE_PASSWORD="123"
FORGER_ADDRESS=

# Coordinator Etherscan
# If this parameter is set, specifies the etherscan endpoint to get the gas estimations for that momment
ETHERSCAN_URL="https://api.etherscan.io"
ETHERSCAN_API_KEY=
16 changes: 8 additions & 8 deletions sequencer/api/stateapiupdater/stateapiupdater.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package stateapiupdater

import (
"database/sql"
"fmt"
"sync"
"tokamak-sybil-resistance/common"
"tokamak-sybil-resistance/database/historydb"
Expand All @@ -24,7 +23,6 @@ type Updater struct {
vars common.SCVariablesPtr
consts historydb.Constants
rw sync.RWMutex
rfp *RecommendedFeePolicy
maxTxPerBatch int64
}

Expand Down Expand Up @@ -86,11 +84,14 @@ func (u *Updater) SetSCVars(vars *common.SCVariablesPtr) {
}

// NewUpdater creates a new Updater
func NewUpdater(hdb *historydb.HistoryDB, config *historydb.NodeConfig, vars *common.SCVariables,
consts *historydb.Constants, rfp *RecommendedFeePolicy, maxTxPerBatch int64) (*Updater, error) {
if ok := rfp.valid(); !ok {
return nil, common.Wrap(fmt.Errorf("Invalid recommended fee policy: %v", rfp.PolicyType))
}
func NewUpdater(
hdb *historydb.HistoryDB,
config *historydb.NodeConfig,
vars *common.SCVariables,
consts *historydb.Constants,
// rfp *RecommendedFeePolicy,
maxTxPerBatch int64,
) (*Updater, error) {
u := Updater{
hdb: hdb,
config: *config,
Expand All @@ -100,7 +101,6 @@ func NewUpdater(hdb *historydb.HistoryDB, config *historydb.NodeConfig, vars *co
ForgeDelay: config.ForgeDelay,
},
},
rfp: rfp,
maxTxPerBatch: maxTxPerBatch,
}
u.SetSCVars(vars.AsPtr())
Expand Down
Loading

0 comments on commit 32b447d

Please sign in to comment.