-
Notifications
You must be signed in to change notification settings - Fork 121
38 lines (32 loc) · 1.4 KB
/
enforce-evm-migration.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Ensure EVM module migration when bytecode changes
on:
- pull_request
jobs:
ensure-evm-migration:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: '0'
ref: ${{ inputs.branch }}
submodules: recursive
- name: Compare bytecode version to previous tagged version
run: |
tag=$(git tag --list --merged HEAD --sort=-v:refname | head -n 1)
current_commit=$(git rev-parse HEAD)
evm_module=./x/evm/module.go
echo "Comparing current branch with tag $tag"
if git diff -s --exit-code "$tag" -- ./contract-artifacts; then
echo "The contract version has not changed, no need to enforce a migration"
exit 0
fi
echo "The contract version has changed"
# Check out the latest tag, increment the consensus version and check if it matches the version in the current commit
git checkout -q "$tag" $evm_module
perl -i -pe 's/(?<=^func \(AppModule\) ConsensusVersion\(\) uint64 \{ return )(\b\d+\b)(?= }$)/$1+1/me' $evm_module
if git diff "$current_commit" --exit-code $evm_module | grep ConsensusVersion > /dev/null; then
echo "EVM module consensus version needs to be incremented"
exit 1
fi
echo "EVM module consensus version has been incremented"