Skip to content

Commit

Permalink
Merge pull request #198 from tqtezos/krendelhoff/chore-add-kathmandu
Browse files Browse the repository at this point in the history
[Chore] Add kathmandu protocol support for CI
  • Loading branch information
dcastro authored Oct 20, 2022
2 parents bc167c9 + ede94c5 commit 7b9f33d
Show file tree
Hide file tree
Showing 33 changed files with 2,464 additions and 1,679 deletions.
74 changes: 41 additions & 33 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ env:
&& cp "./nix/sources.json" "./haskell/test/resources/"
TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER: "Y"

.local-chain-env: &local-chain-env
TASTY_CLEVELAND_NODE_ENDPOINT: "http://localhost:8733"
CHAIN_TEST_MONEYBAG_SECRET_KEY: "unencrypted:edsk3AvAoPS5jFov49aWBQ9oVtCPwNSne2CriHvkFxfeCg4Srr5bak"
# this key is defined in local-chain bootstrap accounts list in
# https://github.com/serokell/aquarius-infra/blob/master/servers/albali/chain.nix

.kathmandunet-env: &kathmandunet-env
TASTY_CLEVELAND_NODE_ENDPOINT: "https://kathmandu.testnet.tezos.serokell.team"
CHAIN_TEST_MONEYBAG_SECRET_KEY: "$TESTNET_MONEYBAG"
CHAIN_TEST_MONEYBAG_PASSWORD: "$TESTNET_MONEYBAG_PASSWORD"

.network-tests: &network-tests
commands:
- eval "$FETCH_CONTRACT"
- cd haskell/
- export PATH=$(nix-build ../ -A stablecoin-client)/bin:$PATH
- nix build -L -f .. test
# Note that 'refill-balance' below is the initial 'TASTY_CLEVELAND_MONEYBAG_SECRET_KEY' balance
# which may need to be adjusted in case of insufficient balance errors
- $(nix-build ../ -A run-chain-tests
--argstr refill-balance 1100
--argstr node-endpoint "$$TASTY_CLEVELAND_NODE_ENDPOINT"
--argstr step-moneybag "$$CHAIN_TEST_MONEYBAG_SECRET_KEY"
--argstr step-moneybag-password "$$CHAIN_TEST_MONEYBAG_PASSWORD"
--no-out-link
--argstr scenario './result/bin/stablecoin-test --cleveland-mode=only-network')
retry:
automatic:
limit: 1

steps:
- label: hlint
if: &not_scheduled
Expand Down Expand Up @@ -71,47 +101,25 @@ steps:
- nix build -L -f .. test
- ./result/bin/stablecoin-test --cleveland-mode=disable-network

- label: nettest-local-chain-013
key: nettest-local-chain-013
- label: nettest-local-chain-014
key: nettest-local-chain-014
if: *not_scheduled
depends_on: build_library
<<: *network-tests
env:
TASTY_CLEVELAND_NODE_ENDPOINT: "http://localhost:8734"
# this key is defined in local-chain bootstrap accounts list in
# https://github.com/serokell/aquarius-infra/blob/master/servers/albali/chain.nix
CHAIN_TEST_MONEYBAG_SECRET_KEY: "unencrypted:edsk3GjD83F7oj2LrnRGYQer99Fj69U2QLyjWGiJ4UoBZNQwS38J4v"
commands: &run-nettest
- eval "$FETCH_CONTRACT"
- cd haskell/
- export PATH=$(nix-build ../ -A stablecoin-client)/bin:$PATH
- nix build -L -f .. test
# Note that 'refill-balance' below is the initial 'TASTY_CLEVELAND_MONEYBAG_SECRET_KEY' balance
# which may need to be adjusted in case of insufficient balance errors
- $(nix-build ../ -A run-chain-tests
--argstr refill-balance 1100
--argstr node-endpoint "$$TASTY_CLEVELAND_NODE_ENDPOINT"
--argstr step-moneybag "$$CHAIN_TEST_MONEYBAG_SECRET_KEY"
--argstr step-moneybag-password "$$CHAIN_TEST_MONEYBAG_PASSWORD"
--no-out-link
--argstr scenario './result/bin/stablecoin-test --cleveland-mode=only-network')
retry: &retry-nettest
automatic:
limit: 1

- label: nettest-scheduled-jakartanet
key: nettest-scheduled-jakartanet
<<: *local-chain-env

- label: nettest-scheduled-kathmandunet
key: nettest-scheduled-kathmandunet
if: build.source == "schedule"
depends_on:
- build_library
- LIGO-contract
<<: *network-tests
env:
TASTY_CLEVELAND_NODE_ENDPOINT: "https://jakarta.testnet.tezos.serokell.team"
CHAIN_TEST_MONEYBAG_SECRET_KEY: "$JAKARTANET_MONEYBAG"
CHAIN_TEST_MONEYBAG_PASSWORD: "$JAKARTANET_MONEYBAG_PASSWORD"
<<: *kathmandunet-env
# Running all of the tests on network will end up draining the moneybag; for now, only FA1.2 tests are run
TASTY_PATTERN: '/Test.FA1_2/||/Lorentz.Contracts.Nettest/'
commands: *run-nettest
retry: *retry-nettest
timeout_in_minutes: 360

- label: weeder
Expand All @@ -130,8 +138,8 @@ steps:
if: *not_scheduled
depends_on:
- test
- nettest-local-chain-013
- nettest-scheduled-jakartanet
- nettest-local-chain-014
- nettest-scheduled-kathmandunet
- weeder
commands:
- eval "$FETCH_CONTRACT"
Expand Down
20 changes: 17 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,26 @@ you must be able to justify that.

- Documentation
- [ ] I checked whether I should update the docs and did so if necessary:
- [README](../tree/master/README.md)
- [README](https://github.com/tqtezos/stablecoin/tree/master/README.md)
- Haddock
- [ ] I updated [changelog](../tree/master/ChangeLog.md) unless I am sure my changes are
- [ ] I updated [changelog](https://github.com/tqtezos/stablecoin/tree/master/ChangeLog.md) unless I am sure my changes are
not essential.

#### Stylistic guide (mandatory)

- [ ] My commits comply with [the policy used in Serokell](https://www.notion.so/serokell/Where-and-how-to-commit-your-work-58f8973a4b3142c8abbd2e6fd5b3a08e).
- [ ] My code complies with the [style guide](../tree/master/docs/code-style.md).
- [ ] My code complies with the [style guide](https://github.com/tqtezos/stablecoin/tree/master/docs/code-style.md).

#### ✓ Release Checklist

- [ ] I updated the [Gas / Transaction costs](https://github.com/tqtezos/stablecoin/tree/master/README.md#gas--transaction-costs) table in the README.
- [ ] I updated the version number in `package.yaml`.
- [ ] I updated the [changelog](https://github.com/tqtezos/stablecoin/tree/master/ChangeLog.md) and moved everything
under the "Unreleased" section to a new section for this release version.
- [ ] (After merging) I created a new entry in the [releases](https://github.com/tqtezos/stablecoin/releases) page,
with a summary of all user-facing changes.
* I made sure a tag was created using the format `vX.Y.Z`
* I attached the following artifacts from [buildkite](https://buildkite.com/serokell/stablecoin)
* `stablecoin-client`
* `stablecoin.fa1.2.tz`
* `stablecoin.tz`
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ SPDX-License-Identifier: MIT
<!-- Don't forget to update the gas/transaction costs tables in the
README when a new version is released. -->

## 1.7.4

* [#198](https://github.com/tqtezos/stablecoin/pull/198)
* Add support for the kathmandu protocol.

## 1.7.3

* [#196](https://github.com/tqtezos/stablecoin/pull/196)
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,33 @@ Please refer to the [`haskell/`](/haskell/) directory for details.
## Gas / Transaction costs

The tables below show the gas and transaction costs of both versions (FA1.2 and FA2) of
the stablecoin contract [v1.7.3](https://github.com/tqtezos/stablecoin/releases/tag/v1.7.3) in jakartanet.
the stablecoin contract [v1.7.4](https://github.com/tqtezos/stablecoin/releases/tag/v1.7.4) in kathmandunet.

### jakartanet
### kathmandunet

* [FA1.2 operations](https://better-call.dev/jakartanet/KT1ASuzkJzZ2pCqYVKeV48p5yxunynrjmdGE/operations)
* [FA2 operations](https://better-call.dev/jakartanet/KT19mksNfM9XjWqapR2iMywM1ic5kbVQwpjB/operations)
* [FA1.2 operations](https://better-call.dev/kathmandunet/KT19nHidwLXgGCEPgm2ZVMsmgzowsqEGFyKG/operations)
* [FA2 operations](https://better-call.dev/kathmandunet/KT1RxTmLHfCRfvCP7WFSSCftxLNQNfKPqDTo/operations)

| | FA1.2 Gas cost | FA2 Gas cost | FA1.2 Tx cost | FA2 Tx cost |
| ----------- | -------------- | ------------ | ------------- | ----------- |
| origination | 5743 | 5809 | 2.381299| 2.414438|
| transfer | 6659 | 7003 | 0.001001| 0.001053|
| origination | 7,131 | 7,052 | 2.381438| 2.414563|
| transfer | 8,047 | 8,246 | 0.00114 | 0.001177|

### Measuring

To measure and collect these numbers:
1. Pick a testnet:
```
export STABLECOIN_TESTNET=https://jakarta.testnet.tezos.serokell.team/
export STABLECOIN_TESTNET=https://kathmandu.testnet.tezos.serokell.team/
```
1. Use a [testnet faucet](https://teztnets.xyz/) to create a test account with enough funds.
1. Activate the account:
1. Create a test account and grab its hash:
```
tezos-client -E $STABLECOIN_TESTNET activate account stablecoin-moneybag with <activation_file.json>
$ tezos-client gen keys stablecoin-moneybag --force
$ tezos-client -E $STABLECOIN_TESTNET show address stablecoin-moneybag
Hash: tz1Shin6pHETKn7EroLGyG2afTenW2zT2K6w
Public Key: edpktpFQUaRZRHPMBgk66W4jQoYK2hzZ95o9ZJrPmH38zqSzfH5Zor
```
1. Use a [testnet faucet](https://teztnets.xyz/) to add funds to your account.
1. Run:
```bash
cd haskell
Expand Down
1 change: 1 addition & 0 deletions haskell/hpack/definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ _definitions:
- RecursiveDo
- ScopedTypeVariables
- StandaloneDeriving
- StandaloneKindSignatures
- TemplateHaskell
- TupleSections
- TypeApplications
Expand Down
6 changes: 5 additions & 1 deletion haskell/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<<: !include "./hpack/module.yaml"

name: stablecoin
version: 1.7.3
version: 1.7.4

extra-source-files:
- README.md
Expand All @@ -28,13 +28,16 @@ library:
- aeson-casing
- bytestring
- cleveland
- colourista
- constraints
- containers
- directory
- fmt
- indigo
- lens
- lorentz
- megaparsec
- memory
- morley
- morley-client
- morley-ledgers
Expand All @@ -43,6 +46,7 @@ library:
- optparse-applicative
- process
- servant-client
- singletons
- template-haskell
- text
- uncaught-exception
Expand Down
11 changes: 5 additions & 6 deletions haskell/src/Lorentz/Contracts/Stablecoin/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Lorentz.Contracts.Stablecoin.Metadata

import Data.Aeson qualified as J
import Data.ByteString.Lazy qualified as BSL
import Data.Map qualified as Map
import Data.Version (showVersion)
import Fmt (pretty)
import Text.Megaparsec qualified as P
Expand All @@ -27,7 +26,7 @@ import Lorentz.Contracts.Spec.TZIP16Interface qualified as TZ
import Morley.Metadata
(ViewCode(..), compileViewCodeTH, mkMichelsonStorageView, unsafeCompileViewCode)
import Morley.Micheline (ToExpression(toExpression))
import Morley.Tezos.Address (formatAddress, parseAddress)
import Morley.Tezos.Address (ContractAddress, formatAddress, parseKindedAddress)

import Lorentz.Contracts.Stablecoin.Types
import Paths_stablecoin (version)
Expand Down Expand Up @@ -67,7 +66,7 @@ metadataMap mdata = mkBigMap $
-- Result after parsing the metadata uri from a TZIP-16 metadata bigmap.
data ParsedMetadataUri
= InCurrentContractUnderKey Text
| InRemoteContractUnderKey Address Text
| InRemoteContractUnderKey ContractAddress Text
| RawUri Text
deriving stock (Eq, Show)

Expand All @@ -85,7 +84,7 @@ remoteContractUriParser = do
_ <- string' (TZ.tezosStorageScheme <> "://")
addr <- P.manyTill P.anySingle (string' "/")
key <- P.many P.anySingle
case parseAddress (toText addr) of
case parseKindedAddress (toText addr) of
Right paddr -> pure $ InRemoteContractUnderKey paddr (toText key)
Left err -> fail $ pretty err

Expand All @@ -100,7 +99,7 @@ currentContractUriParser = do

data MetadataUri metadata
= CurrentContract metadata Bool -- ^ Metadata and a flag to denote if URI should be included
| RemoteContract Address
| RemoteContract ContractAddress
| Raw Text

-- | Make the TZIP-16 metadata. We accept a @Maybe@ @FA2.TokenMetadata@
Expand Down Expand Up @@ -269,7 +268,7 @@ mkTokenMetadataView md =
, vPure = Just True
, vImplementations = one $
VIMichelsonStorageView $
mkMichelsonStorageView @Storage @(Natural, Map.Map MText ByteString) Nothing [] vc
mkMichelsonStorageView @Storage @(Natural, FA2.TokenMetadata) Nothing [] vc
}

getDefaultExpiryView :: TZ.View (ToT Storage)
Expand Down
6 changes: 3 additions & 3 deletions haskell/src/Lorentz/Contracts/Stablecoin/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ import Lorentz.Contracts.Spec.TZIP16Interface (MetadataMap)
import Morley.AsRPC (HasRPCRepr(..), deriveRPCWithStrategy)
import Morley.Michelson.Typed (Notes(..))
import Morley.Michelson.Untyped (noAnn)
import Morley.Tezos.Address.Alias (AddressOrAlias(..))
import Morley.Tezos.Crypto qualified as Hash
import Stablecoin.Client.L1AddressOrAlias (L1AddressOrAlias)

------------------------------------------------------------------
-- Parameter

-- | Data needed to add or remove an operator.
data UpdateOperatorData
= AddOperator AddressOrAlias
| RemoveOperator AddressOrAlias
= AddOperator L1AddressOrAlias
| RemoveOperator L1AddressOrAlias
deriving stock Show

data ConfigureMinterParam = ConfigureMinterParam
Expand Down
2 changes: 1 addition & 1 deletion haskell/src/Stablecoin/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Stablecoin.Client
( module Stablecoin.Client.Impl
, InitialStorageData(..)
, InitialStorageOptions(..)
, Alias
) where

Expand Down
Loading

0 comments on commit 7b9f33d

Please sign in to comment.