Skip to content

Commit

Permalink
merged with develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemmsilva committed Feb 20, 2024
2 parents ea1ad92 + 3c5dcc8 commit 7a22247
Show file tree
Hide file tree
Showing 218 changed files with 3,747 additions and 1,332 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ snapshot
tools
wal
wasp
wasp-cli
!tools/wasp-cli
wasp-cluster
waspdb
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Bug report
about: Found an issue with the node software? Let us know!
title: ''
labels: bug
assignees: fijter

assignees: jorgemmsilva
---

**Describe the bug**
Expand Down
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: Feature request
about: Suggest a new feature
title: ''
labels: feature
assignees: fijter

assignees: jorgemmsilva
---

**Is your feature request related to a problem? Please describe.**
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v4

- name: install golang
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"

Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go
Expand All @@ -95,14 +95,14 @@ jobs:
uses: actions/checkout@v4

- name: Run global scope golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
args: --timeout 15m0s
skip-pkg-cache: true

- name: Run golangci-lint on wasp-cli
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
working-directory: tools/wasp-cli
version: v1.54.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-mod-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.actor == 'renovate[bot]'
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"
id: go
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/heavy-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ jobs:
uses: actions/checkout@v4
- name: install go
id: go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Run global scope golangci-lint
id: global_lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
args: --timeout 10m0s
skip-pkg-cache: true

- name: Run golangci-lint on wasp-cli
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
working-directory: tools/wasp-cli
version: v1.54.2
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
- name: The job has failed
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.24.0
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
uses: actions/checkout@v4
- name: install golang
id: go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"

Expand Down Expand Up @@ -224,7 +224,7 @@ jobs:
- name: The job has failed
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.24.0
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
Expand Down Expand Up @@ -260,13 +260,13 @@ jobs:

- name: Set up Go 1.x
id: go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Cache Hornet
id: cache_hornet
uses: actions/cache@v3.3.2
uses: actions/cache@v4.0.0
with:
key: hornet-${{ hashFiles('**/go.mod', '**/go.sum') }}
path: |
Expand Down Expand Up @@ -398,7 +398,7 @@ jobs:
- name: The job has failed
if: ${{ failure() }}
uses: slackapi/slack-github-action@v1.24.0
uses: slackapi/slack-github-action@v1.25.0
with:
payload: |
{
Expand Down
61 changes: 56 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,29 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Pull IOTA SDK bindings
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: 'iotaledger/iota-sdk-native-bindings'
# For now use 'latest'
#version: 'tags/v0.1.0'
regex: true
file: ".*"
target: 'sdk/'
token: ${{ secrets.GITHUB_TOKEN }}

- name: Tar temporary artifacts
run: tar --exclude='temp.tar' -cf temp.tar ./

- name: Upload temporary artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: wasp
path: temp.tar
retention-days: 1

- name: Set up Node
uses: actions/[email protected].0
uses: actions/[email protected].2
with:
node-version: "14"

Expand All @@ -41,7 +52,7 @@ jobs:
run: mkdir /dist && cd /dist/

- name: Download temporary artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wasp

Expand All @@ -61,7 +72,7 @@ jobs:
version: ${{ steps.tagger.outputs.tag }}
steps:
- name: Download temporary artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: wasp

Expand Down Expand Up @@ -96,13 +107,26 @@ jobs:
type=match,pattern=v(\d+.\d+),suffix=-beta,group=1,enable=${{ contains(github.ref, '-beta') }}
type=match,pattern=v(\d+.\d+),suffix=-rc,group=1,enable=${{ contains(github.ref, '-rc') }}
- name: Extract CLI metadata (tags, labels) for Docker
id: meta-cli
uses: docker/metadata-action@v5
with:
images: iotaledger/sandbox-wasp-cli
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=match,pattern=v(\d+.\d+),suffix=-alpha,group=1,enable=${{ contains(github.ref, '-alpha') }}
type=match,pattern=v(\d+.\d+),suffix=-beta,group=1,enable=${{ contains(github.ref, '-beta') }}
type=match,pattern=v(\d+.\d+),suffix=-rc,group=1,enable=${{ contains(github.ref, '-rc') }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
password: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}

- name: Build and push to Dockerhub
- name: Build and push WASP to Dockerhub
uses: docker/build-push-action@v5
with:
context: .
Expand All @@ -114,6 +138,33 @@ jobs:
build-args: |
BUILD_LD_FLAGS=-X=github.com/iotaledger/wasp/components/app.Version=${{ steps.tagger.outputs.tag }}
- name: Build and push WASP CLI to Dockerhub
uses: docker/build-push-action@v5
with:
context: .
file: ./tools/wasp-cli/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-cli.outputs.tags }},iotaledger/sandbox-wasp-cli:latest
labels: ${{ steps.meta-cli.outputs.labels }}
build-args: |
BUILD_LD_FLAGS=-X=github.com/iotaledger/wasp/components/app.Version=${{ steps.tagger.outputs.tag }}
# Push wasp-cli README to Docker Hub
- name: git checkout
uses: actions/checkout@v4

- name: push README to Dockerhub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.IOTALEDGER_DOCKER_USERNAME }}
DOCKER_PASS: ${{ secrets.IOTALEDGER_DOCKER_PASSWORD }}
with:
destination_container_repo: iotaledger/sandbox-wasp-cli
provider: dockerhub
short_description: 'wasp-cli is a command line tool for interacting with IOTA Wasp and its smart contracts.'
readme_file: 'tools/wasp-cli/README.md'

release-iscmagic:
uses: ./.github/workflows/publish-iscmagic.yml
needs: release-docker
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ go.work
go.work.sum
TMP*
tmp.*
sdk/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
ARG GOLANG_IMAGE_TAG=1.21-bullseye
ARG GOLANG_IMAGE_TAG=1.22-bullseye

# Build stage
FROM golang:${GOLANG_IMAGE_TAG} AS build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.noncached
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
ARG GOLANG_IMAGE_TAG=1.21-bullseye
ARG GOLANG_IMAGE_TAG=1.22-bullseye

# Build stage
FROM golang:${GOLANG_IMAGE_TAG} AS build
Expand Down
4 changes: 2 additions & 2 deletions clients/chainclient/chainclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ type Client struct {
Layer1Client l1connection.Client
WaspClient *apiclient.APIClient
ChainID isc.ChainID
KeyPair *cryptolib.KeyPair
KeyPair cryptolib.VariantKeyPair
}

// New creates a new chainclient.Client
func New(
layer1Client l1connection.Client,
waspClient *apiclient.APIClient,
chainID isc.ChainID,
keyPair *cryptolib.KeyPair,
keyPair cryptolib.VariantKeyPair,
) *Client {
return &Client{
Layer1Client: layer1Client,
Expand Down
2 changes: 1 addition & 1 deletion contracts/wasm/fairroulette/frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN mv docker/config.dev.docker.js config.dev.js
RUN npm run build_worker
RUN npm run build

FROM nginx:alpine
FROM nginx:1.25.3-alpine3.18

ARG WASP_URL=https://127.0.0.1
ARG WASP_WS_URL=wss://127.0.0.1
Expand Down
46 changes: 31 additions & 15 deletions documentation/tutorial-examples/test/tutorial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ func TestTutorialInvokeSCError(t *testing.T) {
}

func TestTutorialAccounts(t *testing.T) {
env := solo.New(t, &solo.InitOptions{AutoAdjustStorageDeposit: true})
env := solo.New(t, &solo.InitOptions{
AutoAdjustStorageDeposit: true,
GasBurnLogEnabled: true,
})
chain := env.NewChain()

// create a wallet with some base tokens on L1:
Expand All @@ -113,44 +116,57 @@ func TestTutorialAccounts(t *testing.T) {

// send 1 Mi from the L1 wallet to own account on-chain, controlled by the same wallet
req := solo.NewCallParams(accounts.Contract.Name, accounts.FuncDeposit.Name).
AddBaseTokens(1 * isc.Million)
AddBaseTokens(1 * isc.Million).
WithMaxAffordableGasBudget()

// estimate the gas fee and storage deposit
gas1, gasFee1, err := chain.EstimateGasOnLedger(req, userWallet, true)
_, receipt1, err := chain.EstimateGasOnLedger(req, userWallet)
require.NoError(t, err)
storageDeposit1 := chain.EstimateNeededStorageDeposit(req, userWallet)
require.Zero(t, storageDeposit1) // since 1 Mi is enough

// send the deposit request
req.WithGasBudget(gas1).
AddBaseTokens(gasFee1) // including base tokens for gas fee
req.WithGasBudget(receipt1.GasBurned).
AddBaseTokens(receipt1.GasFeeCharged) // including base tokens for gas fee
_, err = chain.PostRequestSync(req, userWallet)
require.NoError(t, err)

// our L1 balance is 1 Mi + gas fee short
env.AssertL1BaseTokens(userAddress, utxodb.FundsFromFaucetAmount-1*isc.Million-gasFee1)
env.AssertL1BaseTokens(userAddress, utxodb.FundsFromFaucetAmount-1*isc.Million-receipt1.GasFeeCharged)
// our L2 balance is 1 Mi
onChainBalance := 1 * isc.Million
chain.AssertL2BaseTokens(userAgentID, 1*isc.Million)
// (the gas fee went to the chain's private account)

// TODO the withdrawal part is pretty confusing for a "tutorial", this needs to be improved.

// withdraw all base tokens back to L1
req = solo.NewCallParams(accounts.Contract.Name, accounts.FuncWithdraw.Name).
WithAllowance(isc.NewAssetsBaseTokens(1 * isc.Million))
WithAllowance(isc.NewAssetsBaseTokens(onChainBalance - 1000)). // leave some tokens out of allowance, to pay for gas
WithMaxAffordableGasBudget()

// estimate the gas fee and storage deposit
gas2, gasFee2, err := chain.EstimateGasOnLedger(req, userWallet, true)
// estimate the gas fee
_, receipt2, err := chain.EstimateGasOffLedger(req, userWallet)
require.NoError(t, err)

// re-estimate with fixed budget and fee (the final fee might be smaller, because less gas will be charged when setting 0 in the user account, rather than a positive number)
req.WithGasBudget(receipt2.GasBurned).
WithAllowance(isc.NewAssetsBaseTokens(onChainBalance - (receipt2.GasFeeCharged)))
_, receipt3, err := chain.EstimateGasOffLedger(req, userWallet)
require.NoError(t, err)
storageDeposit2 := chain.EstimateNeededStorageDeposit(req, userWallet)

// send the withdraw request
req.WithGasBudget(gas2).
AddBaseTokens(gasFee2 + storageDeposit2). // including base tokens for gas fee and storage
AddAllowanceBaseTokens(storageDeposit2) // and withdrawing the storage as well
_, err = chain.PostRequestSync(req, userWallet)
req.WithGasBudget(receipt3.GasBurned).
WithAllowance(isc.NewAssetsBaseTokens(onChainBalance - (receipt3.GasFeeCharged)))
_, err = chain.PostRequestOffLedger(req, userWallet)
require.NoError(t, err)

rec := chain.LastReceipt()
require.EqualValues(t, rec.GasFeeCharged, receipt3.GasFeeCharged)
require.EqualValues(t, rec.GasBurned, receipt3.GasBurned)

// we are back to the initial situation, having been charged some gas fees
// in the process:
env.AssertL1BaseTokens(userAddress, utxodb.FundsFromFaucetAmount-gasFee1-gasFee2)
chain.AssertL2BaseTokens(userAgentID, 0)
env.AssertL1BaseTokens(userAddress, utxodb.FundsFromFaucetAmount-receipt1.GasFeeCharged-receipt3.GasFeeCharged)
}
Loading

0 comments on commit 7a22247

Please sign in to comment.