diff --git a/.github/workflows/protect-main.yaml b/.github/workflows/protect-main.yaml new file mode 100644 index 0000000000..83adadb9eb --- /dev/null +++ b/.github/workflows/protect-main.yaml @@ -0,0 +1,26 @@ +name: Protect main + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + - reopened + - edited + +jobs: + require-development: + name: Require development source branch + runs-on: ubuntu-latest + steps: + - name: Check source branch + env: + HEAD_REF: ${{ github.head_ref }} + run: | + if [ "$HEAD_REF" != "development" ]; then + echo "::error::PRs targeting main must come from the development branch (got '$HEAD_REF'). Open this PR against development instead, then promote development to main." + exit 1 + fi + echo "PR is from development → main. OK." diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85de74592d..0493fafd11 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,9 +84,10 @@ discuss your intended approach for solving the problem in the comments for an ex - **Update the CHANGELOG** for all enhancements and bug fixes. Include the corresponding date, issue number if one exists and current version if any. Check the format of the [CHANGELOG](.docs/CHANGELOG.md). -- **Use the repo's default main branch.** Branch from and +- **Target the `development` branch.** The repo's default branch is still `main`, but do **not** + open pull requests against `main`. Branch from and [submit your pull request](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) - to the repo's default branch `main`. + to `development`. - **[Resolve any merge conflicts](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github)** diff --git a/controller/block.go b/controller/block.go index 04d702b6ad..e078f4b671 100644 --- a/controller/block.go +++ b/controller/block.go @@ -333,8 +333,8 @@ func (c *Controller) CommitCertificate(qc *lib.QuorumCertificate, block *lib.Blo // reset mempool FSM c.Mempool.FSM.Reset() } - // update telemetry (using proper defer to ensure time.Since is evaluated at defer execution) - defer c.UpdateTelemetry(qc, block, time.Since(start)) + // update telemetry at return time so the duration includes all commit work + defer func() { c.UpdateTelemetry(qc, block, time.Since(start)) }() if !syncing { // publish root chain information to all nested chain subscribers for _, id := range c.RCManager.ChainIds() { @@ -819,4 +819,4 @@ func (c *Controller) debugDumpHeaderDiff(candidate, compare *lib.BlockHeader) { c.log.Errorf("Candidate:\n:%s", cand) c.log.Errorf("Compare:\n:%s", comp) c.log.Errorf("State:\n:%s", state) -} +} \ No newline at end of file