Skip to content

Commit

Permalink
Merge branch 'develop' into simulate-basic-pc
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Jul 31, 2023
2 parents a2f2c94 + 6153f44 commit f2432a1
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
version: 2.1
orbs:
slack: circleci/[email protected]

workflows:
version: 2
Expand Down Expand Up @@ -31,7 +33,7 @@ jobs:
python-version:
type: string
machine:
image: "ubuntu-2004:202104-01"
image: "ubuntu-2204:2022.04.2"
steps:
- checkout
- run: PYTHON_VERSION=<< parameters.python-version >> make docker-test
Expand Down
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# .git-blame-ignore-revs
# Exclude formatting commits made by black
# more black formatting Aug 17, 2021
a9facdf30ca467b6e16d13ce88d8889bba7f2e1c
# formatting Aug 16, 2021
ea81ba259216b8be7fb86ef5d3e9c151a94edf87
# apply black Aug 11, 2021
81fe44f0dd9785b1665bbbea047aed591912534b
201 changes: 201 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: Create Release PR

on:
workflow_dispatch:
inputs:
release_version:
description: 'The release_version used for the release branch name, e.g. release/vx.x.x'
default: 'vx.x.x'
required: true
type: string
pre_release_version:
description: "Pre-Release version, e.g. 'b1', will be added behind the release_version in setup.py."
required: false
type: string

env:
RELEASE_VERSION: ${{ inputs.release_version }}
PRE_RELEASE_VERSION: ${{ inputs.pre_release_version }}
RELEASE_BRANCH: release/${{ inputs.release_version }}

jobs:
create-release-pr:
runs-on: ubuntu-latest

steps:
- name: Set Release Version and Branch to Check Out
id: set-release
run: |
if [[ $RELEASE_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [[ $PRE_RELEASE_VERSION =~ ^[a-z.0-9]+$ ]]; then
echo "release-tag: $RELEASE_VERSION$PRE_RELEASE_VERSION"
echo "release-tag=$RELEASE_VERSION$PRE_RELEASE_VERSION" >> $GITHUB_OUTPUT
elif [[ -n $PRE_RELEASE_VERSION ]]; then
echo "Input pre_release_version is not empty, but does not match the regex pattern ^[a-z.0-9]+$"
exit 1
else
echo "release-tag: $RELEASE_VERSION"
echo "release-tag=$RELEASE_VERSION" >> $GITHUB_OUTPUT
fi
else
echo "Version input doesn't match the regex pattern ^v[0-9]+\.[0-9]+\.[0-9]+$"
exit 1
fi
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0

- name: Create Release Branch if it does not exist
run: |
if ! git show-ref --verify --quiet "refs/remotes/origin/$RELEASE_BRANCH"; then
git checkout -b $RELEASE_BRANCH
git push --set-upstream origin $RELEASE_BRANCH
elif [[ $(git rev-parse --abbrev-ref HEAD) != "$RELEASE_BRANCH" ]]; then
echo "Current Branch: $(git rev-parse --abbrev-ref HEAD)"
echo "Release branch exists, make sure you're using the workflow from the release branch or delete the existing release branch."
exit 1
else
echo "Release branch exists and used as workflow ref."
fi
- name: Get Latest Release
id: get-release
run: |
if [[ -n $PRE_RELEASE_VERSION ]]; then
echo "Get the latest release"
tag=$(curl -L \
--header "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases" | jq -r '.[0].tag_name')
echo "latest-tag=$tag" >> $GITHUB_OUTPUT
else
echo "Get the latest stable release"
tag=$(curl -L \
--header "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r '.tag_name')
echo "latest-tag=$tag" >> $GITHUB_OUTPUT
fi
- name: Build Changelog
id: build-changelog
env:
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
run: |
CHANGELOG=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{ github.repository }}/releases/generate-notes \
-d '{"tag_name":"${{ env.RELEASE_VERSION }}","target_commitish":"${{ env.RELEASE_BRANCH }}","previous_tag_name":"${{ env.PREVIOUS_VERSION }}","configuration_file_path":".github/release.yml"}' \
| jq -r '.body')
# The EOF steps are used to save multiline string in github:
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "changelog<<$EOF" >> $GITHUB_OUTPUT
echo -e "${CHANGELOG}" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Update Changelog
if: ${{ env.PRE_RELEASE_VERSION == '' }}
env:
CHANGELOG_CONTENT: ${{ steps.build-changelog.outputs.changelog }}
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
run: |
echo "$(tail -n +2 CHANGELOG.md)" > CHANGELOG.md
echo -e "# Changelog\n\n# ${RELEASE_VERSION}\n\n${CHANGELOG_CONTENT}" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
- name: Update version in setup.py
env:
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
python3 scripts/bump_version.py ${RELEASE_TAG:1}
- name: Commit Changes
uses: EndBug/[email protected]
env:
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
with:
message: "bump up version to ${{ env.RELEASE_TAG }}"

- name: Create Pull Request to Master
env:
CHANGELOG_CONTENT: ${{ steps.build-changelog.outputs.changelog }}
PREVIOUS_VERSION: ${{ steps.get-release.outputs.latest-tag }}
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
# Note: There's an issue adding teams as reviewers, see https://github.com/cli/cli/issues/6395
PULL_REQUEST_URL=$(gh pr create --base "master" \
--title "FOR REVIEW ONLY: ${{ github.event.repository.name }} $RELEASE_TAG" \
--label "Skip-Release-Notes" \
--label "Team Hyper Flow" \
--body "${CHANGELOG_CONTENT}" | tail -n 1)
if [[ $PULL_REQUEST_URL =~ ^https://github.com/${{ github.repository }}/pull/[0-9]+$ ]]; then
PULL_REQUEST_NUM=$(echo $PULL_REQUEST_URL | sed 's:.*/::')
echo "pull-request-master=$PULL_REQUEST_URL" >> $GITHUB_ENV
echo "pull-request-master-num=$PULL_REQUEST_NUM" >> $GITHUB_ENV
echo "Pull request to Master created: $PULL_REQUEST_URL"
else
echo "There was an issue creating the pull request to master branch."
exit 1
fi
- name: Create Pull Request to Develop
if: ${{ env.PRE_RELEASE_VERSION == '' }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
run: |
# Note: There's an issue adding teams as reviewers, see https://github.com/cli/cli/issues/6395
PULL_REQUEST_URL=$(gh pr create --base "develop" \
--title "FOR REVIEW ONLY: Merge back ${{ github.event.repository.name }} $RELEASE_TAG to develop" \
--label "Skip-Release-Notes" \
--label "Team Hyper Flow" \
--body "Merge back version changes to develop." | tail -n 1)
if [[ $PULL_REQUEST_URL =~ ^https://github.com/${{ github.repository }}/pull/[0-9]+$ ]]; then
echo "Pull request to Develop created: $PULL_REQUEST_URL"
DEVELOP_PR_MESSAGE="\nPull Request to develop: $PULL_REQUEST_URL"
echo "pull-request-develop-message=$DEVELOP_PR_MESSAGE" >> $GITHUB_ENV
else
echo "There was an issue creating the pull request to develop branch."
exit 1
fi
- name: Send Slack Message
id: slack
uses: slackapi/[email protected]
env:
RELEASE_TAG: ${{ steps.set-release.outputs.release-tag }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
SDK_DEPLOYMENT_URL: ${{ secrets.SDK_DEPLOYMENT_URL }}
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "${{ github.event.repository.name }} Release PR for ${{ env.RELEASE_TAG }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Approvals needed for*:\nPull Request to master: ${{ env.pull-request-master}}${{ env.pull-request-develop-message }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*After approvals*\nDeploy SDK using the <${{ env.SDK_DEPLOYMENT_URL }}|Deployment Pipeline> with the following parameters:\n*SDK*: ${{ github.event.repository.name }}\n*RELEASE_PR_NUM*: ${{ env.pull-request-master-num }}\n*RELEASE_VERSION*: ${{ env.RELEASE_VERSION }}\n*PRE_RELEASE_VERSION*: ${{ env.PRE_RELEASE_VERSION }}"
}
}
]
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

# v2.3.0

## New Features

- Algod: Simulation run with extra budget per transaction group by ahangsu in #484

## Enhancement

- tweak: reorder GenericSignedTransaction type alias by tzaffi in #478
- Enhancement: Adding `box_reference.py` to Read The Docs by tzaffi in #481
- DevOps: Update CODEOWNERS to only refer to the devops group by onetechnical in #482
- algod: State delta endpoints by algochoi in #483
- CICD: Release PR Creation Workflow and Slack Messaging by algobarb in #497
- algod: Add msgpack query param to deltas endpoints by Eric-Warehime in #499

## Bug Fixes

- bugfix: incorrect indexer docs by tzaffi in #476

**Full Changelog**: https://github.com/algorand/py-algorand-sdk/compare/v2.2.0...v2.3.0

# v2.2.0

## What's Changed
Expand Down
27 changes: 21 additions & 6 deletions algosdk/v2client/algod.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,50 +719,65 @@ def set_timestamp_offset(
return self.algod_request("POST", req, **kwargs)

def get_ledger_state_delta(
self, round: int, **kwargs: Any
self, round: int, response_format: str = "json", **kwargs: Any
) -> AlgodResponseType:
"""
Get the ledger state delta for a round.
Args:
round (int): The round for the desired state delta
response_format (str): The format in which the response is returned: either
"json" or "msgpack"
Returns:
Dict[str, Any]: Response from algod
"""
query = {"format": response_format}
req = f"/deltas/{round}"
return self.algod_request("GET", req, **kwargs)
return self.algod_request(
"GET", req, params=query, response_format=response_format, **kwargs
)

def get_transaction_group_ledger_state_deltas_for_round(
self, round: int, **kwargs: Any
self, round: int, response_format: str = "json", **kwargs: Any
) -> AlgodResponseType:
"""
Get the ledger state deltas for all transaction groups in a given round.
Args:
round (int): The round for the desired state delta
response_format (str): The format in which the response is returned: either
"json" or "msgpack"
Returns:
Dict[str, Any]: Response from algod
"""
query = {"format": response_format}
req = f"/deltas/{round}/txn/group"
return self.algod_request("GET", req, **kwargs)
return self.algod_request(
"GET", req, params=query, response_format=response_format, **kwargs
)

def get_ledger_state_delta_for_transaction_group(
self, id: str, **kwargs: Any
self, id: str, response_format: str = "json", **kwargs: Any
) -> AlgodResponseType:
"""
Get the ledger state delta for a transaction group given the
transaction or group ID.
Args:
id (str): A transaction ID or transaction group ID
response_format (str): The format in which the response is returned: either
"json" or "msgpack"
Returns:
Dict[str, Any]: Response from algod
"""
query = {"format": response_format}
req = f"/deltas/txn/group/{id}"
return self.algod_request("GET", req, **kwargs)
return self.algod_request(
"GET", req, params=query, response_format=response_format, **kwargs
)


def _specify_round_string(
Expand Down
18 changes: 16 additions & 2 deletions algosdk/v2client/models/simulate_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict, Any, TYPE_CHECKING
from typing import List, Dict, Any, TYPE_CHECKING, Optional

if TYPE_CHECKING:
from algosdk import transaction
Expand All @@ -19,12 +19,22 @@ def dictify(self) -> Dict[str, Any]:
class SimulateTraceConfig(object):
enable: bool

def __init__(self, *, enable: bool = False) -> None:
def __init__(
self,
*,
enable: bool = False,
stack: bool = False,
scratch: bool = False,
) -> None:
self.enable = enable
self.stack = stack
self.scratch = scratch

def dictify(self) -> Dict[str, Any]:
return {
"enable": self.enable,
"stack-change": self.stack,
"scratch-change": self.scratch,
}


Expand All @@ -41,11 +51,14 @@ def __init__(
allow_more_logs: bool = False,
allow_empty_signatures: bool = False,
extra_opcode_budget: int = 0,
trace_config: Optional[SimulateTraceConfig] = None,
) -> None:
self.txn_groups = txn_groups
self.allow_more_logs = allow_more_logs
self.allow_empty_signatures = allow_empty_signatures
self.extra_opcode_budget = extra_opcode_budget
if trace_config:
self.trace_config = trace_config

def dictify(self) -> Dict[str, Any]:
return {
Expand All @@ -55,4 +68,5 @@ def dictify(self) -> Dict[str, Any]:
"allow-more-logging": self.allow_more_logs,
"allow-empty-signatures": self.allow_empty_signatures,
"extra-opcode-budget": self.extra_opcode_budget,
"exec-trace-config": self.trace_config,
}
Loading

0 comments on commit f2432a1

Please sign in to comment.