-
Notifications
You must be signed in to change notification settings - Fork 970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Soroban settings upgrade contract and script #3843
Conversation
scripts/README.md
Outdated
- Description - A python script that can setup a setting upgrade or retrieve | ||
current settings for Futurenet through Soroban RPC. The next step is to submit all transactions directly to stellar-core's `tx` endpoint. Note that the actual upgrade command will have to be | ||
submitted manually on the core nodes. | ||
- Prerequisites - run `make build` under `soroban-settings/write_upgrade_bytes` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make build
wanted me to install the target wasm32-unknown-unknown
so we can add a pre-requisite to run rustup target add wasm32-unknown-unknown
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
scripts/README.md
Outdated
submitted manually on the core nodes. | ||
- Prerequisites - run `make build` under `soroban-settings/write_upgrade_bytes` | ||
to the build WASM contract used to write the proposed upgrade. | ||
- Usage - Ex. `SorobanSettingsUpgrade.py getSettings -id 10` to print out the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe mention to install python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added python3
to the commands.
from stellar_sdk.soroban import SorobanServer | ||
from stellar_sdk.soroban.types import Address, Int128, Bytes | ||
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus | ||
from stellar_sdk.xdr import TransactionMeta, LedgerKey, ConfigUpgradeSet, ConfigSettingContractExecutionLanesV0, ConfigUpgradeSetKey, ConfigSettingEntry, StateExpirationSettings, Uint32, Uint64, Int64, Hash, LedgerKeyConfigSetting, ConfigSettingID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding ConfigSettingContractLedgerCostV0 since that has read/write bytes and ledger settings there? We can throttle those using this script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can add this in next iteration of the script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I see what the id argument corresponds to ConfigSettingEntry XDR union. So passing 9 would fetch us contract_data_entry_size_bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quick drive-by review 🏎️💨
from stellar_sdk.soroban import SorobanServer | ||
from stellar_sdk.soroban.types import Address, Int128, Bytes | ||
from stellar_sdk.soroban.soroban_rpc import GetTransactionStatus | ||
from stellar_sdk.xdr import TransactionMeta, LedgerKey, ConfigUpgradeSet, ConfigSettingContractExecutionLanesV0, ConfigUpgradeSetKey, ConfigSettingEntry, StateExpirationSettings, Uint32, Uint64, Int64, Hash, LedgerKeyConfigSetting, ConfigSettingID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you from stellar_sdk.xdr import *
and then you don't need that weird alias at the top heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Fixed
import argparse | ||
import time | ||
import sys | ||
sys.path.append("/Users/siddharthsuresh/dev/py-stellar-base") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this has no effect if it's after the imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This wasn't necessary.
|
||
assert wasm_id, "wasm id should not be empty" | ||
|
||
print("creating contract...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're gonna wanna check the GetTransactionStatus.FAILED
case here heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Updated to assert success.
Not sure if you want to do this in this PR, but there is a section on network upgrades https://github.com/stellar/stellar-core/blob/master/docs/software/admin.md#network-configuration that needs to updated for Soroban (it's the operator user guide) |
Updated. |
import sys | ||
|
||
# The soroban branch of py-stellar-base hasn't been merged into main and released yet, so we have to install it locally. | ||
sys.path.append("/Users/dev/py-stellar-base") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can install from the branch via pip
, if you want to add that to the instructions
pip install git+https://github.com/StellarCN/py-stellar-base.git@soroban
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I'm a python noob. This is good to know. Thanks!
I removed this line here and added instructions yesterday for installing from source but the PR isn't updating for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh this is thanks to @overcat, from here: stellar/sorobanathon#20. I do see it's gone from the branch, though 👍
# Get upgrade xdr | ||
|
||
upgrade = get_upgrade_set() | ||
upgrade_xdr = upgrade.to_xdr() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: unused
# Get upgrade | ||
upgrade_key = get_upgrade_key(contract_id_hash, upgrade_hash).to_xdr() | ||
url_encoded_key = urllib.parse.quote(upgrade_key) | ||
print(f"url encoded upgrade: {url_encoded_key}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure, Core's http server can handle the /
s in the encoded key and won't treat them as endpoint paths? You can pass safe=''
to quote
if not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah core handles it
r+ a8ef9cc |
Description
This is still a work in progress.
What it can do -
What we can't do yet -
tx
endpoint to reduce dependencies during emergencies.ConfigUpgradeSetKey
and returns what the upgrade diff will be.Checklist
clang-format
v8.0.0 (viamake format
or the Visual Studio extension)