5

The documentation for upgrades states (in reference to the transaction version):

This number must be bumped when there is a change in the index of the pallets in the construct_runtime! macro or when any dispatchable changes, such as the number of parameters or any parameter type changes. This includes any change in pallet and dispatchable runtime parameter types

Does renaming an extrinsic, but leaving it otherwise unchanged, count as a dispatchable change that requires a transaction version bump?

1 Answer 1

5

No it does not!

Extrinsics are encoded as two bytes:

  1. First byte as an index into the pallet
  2. Second byte as an index into the extrinsic

So the actual name of the extrinsic does not effect the final call encoding, and thus just changing it's name will not impact anything.

For complete sanity, probably you should run a CI check to make sure your new commits are not breaking the transaction versioning. We do this automatically in the Polkadot CI pipeline:

.gitlab-ci.yml

check-transaction-versions:
  stage:                           build
  <<:                              *test-refs
  <<:                              *docker-env
  image:                           node:15
  needs:
    - job:                         test-build-linux-stable
      artifacts:                   true
  before_script:
    - apt-get -y update; apt-get -y install jq lsof
    - npm install --ignore-scripts -g @polkadot/metadata-cmp
    # Set git config
    - git config remote.origin.url "https://github.com/paritytech/polkadot.git"
    - git fetch origin release
  script:
    - scripts/gitlab/check_extrinsics_ordering.sh

check_extrinsics_ordering.sh

#!/usr/bin/env bash
set -e

# Include the common functions library
#shellcheck source=../common/lib.sh
. "$(dirname "${0}")/../common/lib.sh"

HEAD_BIN=./artifacts/polkadot
HEAD_WS=ws://localhost:9944
RELEASE_WS=ws://localhost:9945

runtimes=(
  "westend"
  "kusama"
  "polkadot"
)

# First we fetch the latest released binary
latest_release=$(latest_release 'paritytech/polkadot')
RELEASE_BIN="./polkadot-$latest_release"
echo "[+] Fetching binary for Polkadot version $latest_release"
curl -L "https://github.com/paritytech/polkadot/releases/download/$latest_release/polkadot" > "$RELEASE_BIN" || exit 1
chmod +x "$RELEASE_BIN"


for RUNTIME in "${runtimes[@]}"; do
  echo "[+] Checking runtime: ${RUNTIME}"

  release_transaction_version=$(
    git show "origin/release:runtime/${RUNTIME}/src/lib.rs" | \
      grep 'transaction_version'
  )

  current_transaction_version=$(
    grep 'transaction_version' "./runtime/${RUNTIME}/src/lib.rs"
  )

  echo "[+] Release: ${release_transaction_version}"
  echo "[+] Ours: ${current_transaction_version}"

  if [ ! "$release_transaction_version" = "$current_transaction_version" ]; then
    echo "[+] Transaction version for ${RUNTIME} has been bumped since last release."
    exit 0
  fi

  # Start running the nodes in the background
  $HEAD_BIN --chain="$RUNTIME-local" --tmp &
  $RELEASE_BIN --chain="$RUNTIME-local" --ws-port 9945 --tmp &
  jobs

  # Sleep a little to allow the nodes to spin up and start listening
  TIMEOUT=5
  for i in $(seq $TIMEOUT); do
    sleep 1
      if [ "$(lsof -nP -iTCP -sTCP:LISTEN | grep -c '994[45]')" == 2 ]; then
        echo "[+] Both nodes listening"
        break
      fi
      if [ "$i" == $TIMEOUT ]; then
        echo "[!] Both nodes not listening after $i seconds. Exiting"
        exit 1
      fi
  done
  sleep 5

  changed_extrinsics=$(
    polkadot-js-metadata-cmp "$RELEASE_WS" "$HEAD_WS" \
      | sed 's/^ \+//g' | grep -e 'idx: [0-9]\+ -> [0-9]\+' || true
  )

  if [ -n "$changed_extrinsics" ]; then
    echo "[!] Extrinsics indexing/ordering has changed in the ${RUNTIME} runtime! If this change is intentional, please bump transaction_version in lib.rs. Changed extrinsics:"
    echo "$changed_extrinsics"
    exit 1
  fi

  echo "[+] No change in extrinsics ordering for the ${RUNTIME} runtime"
  jobs -p | xargs kill; sleep 5
done

# Sleep a little to let the jobs die properly
sleep 5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.