Skip to content
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

Owned Proxy - update scripts and associated docs #20

Merged
merged 43 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
29d289d
Use current nightly forc
sdankel Aug 5, 2024
91b3644
Merge branch 'sophie/latest-forc' into K1-R1/updates
K1-R1 Aug 6, 2024
b6db5d1
chore: update contract to forc 0.63.1
K1-R1 Aug 21, 2024
ac1f0fd
chore: update scripts
K1-R1 Aug 21, 2024
938b2e8
chore: updated tests and removed copied test
K1-R1 Aug 21, 2024
b1a2264
docs: updated badges and replace version message with badge
K1-R1 Aug 21, 2024
06cb885
chore: changelog
K1-R1 Aug 21, 2024
3ef6f41
Update ci.yml
K1-R1 Aug 21, 2024
6163f8e
Update CHANGELOG.md
K1-R1 Aug 21, 2024
07ae6c3
docs: updated Owned Proxy usage docs
K1-R1 Aug 22, 2024
a0ea885
chore: changelog
K1-R1 Aug 22, 2024
5df64be
chore: update CI rust ver
K1-R1 Aug 30, 2024
bde6d1a
feat: update to latest deps, pin owner slot
K1-R1 Aug 30, 2024
d0d55a3
docs: updated forc version
K1-R1 Aug 30, 2024
d617a70
chore: updated forc ver in tests
K1-R1 Aug 30, 2024
18da14d
Resolve failed to run custom build command for fuel-core-upgradable-e…
bitzoic Aug 30, 2024
edbb615
Use master branch of Sway-Libs
bitzoic Aug 30, 2024
fb41501
Merge branch 'K1-R1/updates' into K1-R1-20
bitzoic Aug 30, 2024
be8f77d
Update to Sway-Libs v0.24.0
bitzoic Sep 2, 2024
a54724b
Udpate Forc.lock
bitzoic Sep 2, 2024
78626cb
chore: updated script dependencies
K1-R1 Sep 5, 2024
01ba4a2
chore: updated test dependencies
K1-R1 Sep 5, 2024
d508b8b
chore: fix clippy lint
K1-R1 Sep 5, 2024
5c65a67
chore: fix spelling
K1-R1 Sep 5, 2024
39b0746
chore: use default node and chain config
K1-R1 Sep 5, 2024
b2805f9
chore: use latest nightly chain
K1-R1 Sep 5, 2024
1a34ae5
fix ci
K1-R1 Sep 5, 2024
fb558e0
Merge pull request #25 from FuelLabs/K1-R1-CI-debug
K1-R1 Sep 8, 2024
29214f1
chore: update CI rust version
K1-R1 Sep 8, 2024
4b77760
chore: updated owned proxy forc version
K1-R1 Sep 8, 2024
21d53da
chore: updated owned_proxy scripts fuel-rs version
K1-R1 Sep 8, 2024
515e7a0
chore: updated test harness forc and fuels-rs versions
K1-R1 Sep 8, 2024
a7fbfb3
Merge branch 'K1-R1/updates' into K1-R1-CI-warnings
K1-R1 Sep 8, 2024
ce9c248
Merge branch 'K1-R1-CI-warnings' into K1-R1-20
K1-R1 Sep 8, 2024
8d939be
docs: updated owned_proxy scripts to point to new proxy guide
K1-R1 Sep 8, 2024
8252485
Merge branch 'master' into K1-R1-20
bitzoic Sep 9, 2024
53d25c2
Merge branch 'master' into K1-R1-20
bitzoic Sep 9, 2024
52eb37a
Update src14/owned_proxy/README.md
K1-R1 Sep 12, 2024
de394cb
Update src14/owned_proxy/README.md
K1-R1 Sep 12, 2024
aac4f87
Update src14/owned_proxy/README.md
K1-R1 Sep 12, 2024
9fb4ebb
Update src14/owned_proxy/scripts/README.md
K1-R1 Sep 12, 2024
e63d582
Update README.md
K1-R1 Sep 12, 2024
2c5f95a
Update README.md
K1-R1 Sep 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Description of the upcoming release here.
- [#10](https://github.com/FuelLabs/sway-standard-implementations/pull/10) Sets owned_proxy sway-libs dependency to version v0.23.0.
- [#17](https://github.com/FuelLabs/sway-standard-implementations/pull/17) Update Owned Proxy to support `forc`'s deploy proxy feature.
- [#19](https://github.com/FuelLabs/sway-standard-implementations/pull/19) Adds CI checks for `forc` compiler warnings.
- [#20](https://github.com/FuelLabs/sway-standard-implementations/pull/20) Update Owned Proxy usage docs.

### Changed

Expand Down
58 changes: 5 additions & 53 deletions src14/owned_proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,12 @@
</a>
</p>

- The [Owned Proxy Contract](./contract/src/main.sw) is an opinionated implementation of the [extended SRC-14 standard](https://docs.fuel.network/docs/sway-standards/src-14-simple-upgradeable-proxies/). It utilises the [Upgradability library from sway-libs](https://github.com/FuelLabs/sway-libs) and includes initialization functionality that allows for secure ownership upon deployment.
- The [Owned Proxy Contract](./contract/src/main.sw) is an opinionated implementation of the [extended SRC-14 standard](https://docs.fuel.network/docs/sway-standards/src-14-simple-upgradeable-proxies/). It utilises the [Upgradability library from sway-libs](https://docs.fuel.network/docs/sway-libs/upgradability/) and includes initialization functionality that allows for secure ownership upon deployment.

## Usage instructions
## Recommended Usage

Clone the repository and move into it:
The recommended way to utilize the [Owned Proxy Contract](./contract/src/main.sw) is with [forc-deploy's proxy feature](https://docs.fuel.network/docs/forc/plugins/forc_client/#proxy-contracts). A guide on recommended usage of proxies and large contracts is available at: [How To Use Proxy contracts & large contract chunking](https://github.com/FuelLabs/proxy-chunks-minimal-example/tree/main).

```bash
git clone -b master https://github.com/FuelLabs/sway-standard-implementations.git && cd sway-standard-implementations
```
## Manual utility scripts

### Rust scripts

> **Warning:** These scripts are temporary. Proxy contract deployment and interactions will be integrated into `Forc` in the near future.

A suite of Rust scripts are included to assist in the usage of the contract. In order to use them navigate to the [owned-proxy/scripts](./scripts/) directory. From `sway-standard-implementations/<you are here>`:

```bash
cd src14/owned_proxy/scripts
```

#### Deploy and initialize

As described in the [SRC-14 standard](https://docs.fuel.network/docs/sway-standards/src-14-simple-upgradeable-proxies/); this proxy contract implementation works via The FuelVM's LDC instruction that is used by Sway's `std::execution::run_external` functionality to execute instructions from a target contract while retaining the proxy contract's storage context. As such a target contract must be deployed to be used alongside this proxy contract. There are two options to achieve this:

- The target contract can be deployed _before_ the proxy contract; in this case set the target contract's ID as the `<INITIAL_TARGET>` when deploying the proxy contract.
- The target contract can be deployed _after_ the proxy contract; in this case set the target contract via the `set_proxy_target` method, a script for which is provided [below](#updating-the-target-contract).

To deploy and initialize the proxy contract the `deploy_and_init` script is available. It will use the arguments `--initial-target` and `--initial-owner` as configurables in the proxy contract. From `sway-standard-implementations/src14/owned_proxy/scripts/<you are here>`:

```bash
SIGNING_KEY=<SIGNING_KEY> cargo run -r --bin deploy_and_init -- --initial-target <INITIAL_TARGET> --initial-owner <INITIAL_OWNER> --provider-url <PROVIDER_URL>
```

> **Note:** The optional flag `--provider-url <PROVIDER_URL>` sets the URL of the provider to be used in the script. If not manually set, it defaults to `127.0.0.1:4000` which is the default `fuel-core` URL.
> **Note:** There is also the optional flag `--signing-key <SIGNING_KEY>` which can be used instead of the environment variable `SIGNING_KEY`. However use of the environment variable `SIGNING_KEY` is preferred.

#### Updating the proxy owner

To update the proxy contract's owner the `set_proxy_owner` script is available. It will use the argument `--new-owner` as the new owner in the proxy contract. From `sway-standard-implementations/src14/owned_proxy/scripts/<you are here>`:

```bash
SIGNING_KEY=<SIGNING_KEY> cargo run -r --bin set_proxy_owner -- --proxy-contract-id <PROXY_CONTRACT_ID> --new-owner <NEW_OWNER> --provider-url <PROVIDER_URL>
```

> **Note:** The optional flag `--provider-url <PROVIDER_URL>` sets the URL of the provider to be used in the script. If not manually set, it defaults to `127.0.0.1:4000` which is the default `fuel-core` URL.
> **Note:** There is also the optional flag `--signing-key <SIGNING_KEY>` which can be used instead of the environment variable `SIGNING_KEY`. However use of the environment variable `SIGNING_KEY` is preferred.

#### Updating the target contract

To update the proxy contract's target the `set_proxy_target` script is available. It will use the argument `--new-target-id` as the new target contract in the proxy contract. From `sway-standard-implementations/src14/owned_proxy/scripts/<you are here>`:

```bash
SIGNING_KEY=<SIGNING_KEY> cargo run -r --bin set_proxy_target -- --proxy-contract-id <PROXY_CONTRACT_ID> --new-target-id <NEW_TARGET_ID> --provider-url <PROVIDER_URL>
```

> **Note:** The optional flag `--provider-url <PROVIDER_URL>` sets the URL of the provider to be used in the script. If not manually set, it defaults to `127.0.0.1:4000` which is the default `fuel-core` URL.
> **Note:** There is also the optional flag `--signing-key <SIGNING_KEY>` which can be used instead of the environment variable `SIGNING_KEY`. However use of the environment variable `SIGNING_KEY` is preferred.
This project does provide some [simple Rust scripts](./scripts/README.md) as examples for basic deployment and interaction functionality. However; this is NOT the recommended way of utilizing the [Owned Proxy Contract](./contract/src/main.sw).
50 changes: 50 additions & 0 deletions src14/owned_proxy/scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SRC-14: Manual utility scripts

> **Warning:** The recommended way of utilizing Proxy Contracts is with [forc-deploy](https://docs.fuel.network/docs/forc/plugins/forc_client/#proxy-contracts). A guide on recommended usage of proxies and large contracts is available at: [How To Use Proxy contracts & large contract chunking](https://github.com/FuelLabs/proxy-chunks-minimal-example/tree/main).

## Utility scripts usage

Clone the repository and move into it:

```bash
git clone -b master https://github.com/FuelLabs/sway-standard-implementations.git && cd sway-standard-implementations
```

Navigate to the [owned-proxy/scripts](./scripts/) directory. From `sway-standard-implementations/<you are here>`:

```bash
cd src14/owned_proxy/scripts
```

> **Note:** The optional flag `--provider-url <PROVIDER_URL>` sets the URL of the provider to be used in the script. If not manually set, it defaults to `127.0.0.1:4000` which is the default `fuel-core` URL.

> **Note:** There is also the optional flag `--signing-key <SIGNING_KEY>` which can be used instead of the environment variable `SIGNING_KEY`. However use of the environment variable `SIGNING_KEY` is preferred.

#### Deploy and initialize

As described in the [SRC-14 standard](https://docs.fuel.network/docs/sway-standards/src-14-simple-upgradeable-proxies/); this proxy contract implementation works via The FuelVM's LDC instruction that is used by Sway's `std::execution::run_external` functionality to execute instructions from a target contract while retaining the proxy contract's storage context. As such a target contract must be deployed to be used alongside this proxy contract. There are two options to achieve this:

- The target contract can be deployed _before_ the proxy contract; in this case set the target contract's ID as the `<INITIAL_TARGET>` when deploying the proxy contract.
- The target contract can be deployed _after_ the proxy contract; in this case set the target contract via the `set_proxy_target` method, a script for which is provided [below](#updating-the-target-contract).

To deploy and initialize the proxy contract the `deploy_and_init` script is available. It will use the arguments `--initial-target` and `--initial-owner` as configurables in the proxy contract. From `sway-standard-implementations/src14/owned_proxy/scripts/<you are here>`:

```bash
SIGNING_KEY=<SIGNING_KEY> cargo run -r --bin deploy_and_init -- --initial-target <INITIAL_TARGET> --initial-owner <INITIAL_OWNER> --provider-url <PROVIDER_URL>
```

#### Updating the proxy owner

To update the proxy contract's owner the `set_proxy_owner` script is available. It will use the argument `--new-owner` as the new owner in the proxy contract. From `sway-standard-implementations/src14/owned_proxy/scripts/<you are here>`:

```bash
SIGNING_KEY=<SIGNING_KEY> cargo run -r --bin set_proxy_owner -- --proxy-contract-id <PROXY_CONTRACT_ID> --new-owner <NEW_OWNER> --provider-url <PROVIDER_URL>
```

#### Updating the target contract

To update the proxy contract's target the `set_proxy_target` script is available. It will use the argument `--new-target-id` as the new target contract in the proxy contract. From `sway-standard-implementations/src14/owned_proxy/scripts/<you are here>`:

```bash
SIGNING_KEY=<SIGNING_KEY> cargo run -r --bin set_proxy_target -- --proxy-contract-id <PROXY_CONTRACT_ID> --new-target-id <NEW_TARGET_ID> --provider-url <PROVIDER_URL>
```
Loading