Skip to content

Commit

Permalink
Merge branch 'master' into bastian/webassembly
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Jun 25, 2024
2 parents b4c634b + aeef038 commit cbfcbd3
Show file tree
Hide file tree
Showing 984 changed files with 123,806 additions and 23,371 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'v**'

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand Down
17 changes: 13 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'v**'

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand All @@ -39,12 +39,18 @@ jobs:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"

- name: Build
run: make -j8 build

- name: Test
run: make ci

- name: Cadence Testing Framework
run: cd runtime/stdlib/contracts && flow-c1 test --cover --covercode="contracts" crypto_test.cdc

- name: Upload coverage report
uses: codecov/codecov-action@v2
with:
Expand Down Expand Up @@ -88,10 +94,13 @@ jobs:
semgrep:
name: Semgrep
runs-on: ubuntu-latest
container:
image: returntocorp/semgrep
# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')
steps:
- name: Clone
uses: actions/checkout@v3

- uses: returntocorp/semgrep-action@v1
with:
config: semgrep.yaml
- name: semgrep ci
run: semgrep ci --config semgrep.yaml
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'v**'

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/compatibility-check-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ on:
chain:
required: true
type: string
url:
secrets:
FLOWDIVER_API_KEY:
required: true
type: string

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ inputs.base-branch || github.run_id }}-${{ inputs.chain }}
Expand All @@ -35,9 +35,6 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
# Checkout the branch where the compatibility check tool is available.
# Usually this is the master branch.
ref: master

- uses: actions/setup-go@v3
with:
Expand All @@ -64,9 +61,11 @@ jobs:

- name: Download contracts
if: ${{ steps.restore-cached-contracts.outputs.cache-hit != 'true' }}
working-directory: ./tools/batch-script
env:
FLOWDIVER_API_KEY: ${{ secrets.FLOWDIVER_API_KEY }}
working-directory: ./tools/get-contracts
run: |
go run ./cmd/get_contracts/main.go --chain=${{ inputs.chain }} --u=${{ inputs.url }} > ../../tmp/contracts.csv
go run . --chain=${{ inputs.chain }} --apiKey="$FLOWDIVER_API_KEY" > ../../tmp/contracts.csv
- name: Cache Contracts
id: cache-contracts
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/compatibility-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- 'v**'

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ inputs.base || github.run_id }}
Expand Down Expand Up @@ -64,8 +64,9 @@ jobs:
repo: ${{ needs.setup.outputs.repo }}
base-branch: ${{ needs.setup.outputs.base }}
current-branch: ${{ needs.setup.outputs.branch }}
chain: flow-mainnet
url: access.mainnet.nodes.onflow.org:9000
chain: mainnet
secrets:
FLOWDIVER_API_KEY: ${{ secrets.FLOWDIVER_API_KEY }}

testnet:
needs: setup
Expand All @@ -74,5 +75,6 @@ jobs:
repo: ${{ needs.setup.outputs.repo }}
base-branch: ${{ needs.setup.outputs.base }}
current-branch: ${{ needs.setup.outputs.branch }}
chain: flow-testnet
url: access.testnet.nodes.onflow.org:9000
chain: testnet
secrets:
FLOWDIVER_API_KEY: ${{ secrets.FLOWDIVER_API_KEY }}
9 changes: 2 additions & 7 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- 'v**'

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand All @@ -28,25 +28,21 @@ jobs:
uses: actions/checkout@v3
with:
repository: 'onflow/flow-go'
ref: ${{ github.base_ref == 'feature/stable-cadence' && 'feature/stable-cadence' || 'master' }}

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Build relic
run: sh crypto_setup.sh

- name: Update Cadence
run: go mod edit -replace github.com/onflow/cadence=github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }}@${{ github.event.pull_request.head.sha || github.sha }}

- name: Tidy up
run: go mod tidy

- name: Build
run: go build -v --tags relic ./...
run: go build -v ./...

flow-emulator:
name: Emulator
Expand All @@ -56,7 +52,6 @@ jobs:
uses: actions/checkout@v3
with:
repository: 'onflow/flow-emulator'
ref: ${{ github.base_ref == 'feature/stable-cadence' && 'feature/stable-cadence' || 'master' }}

- name: Setup Go
uses: actions/setup-go@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ on:
default: 'master'

env:
GO_VERSION: '1.20'
GO_VERSION: '1.22'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
Expand Down
3 changes: 1 addition & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* @turbolent @SupunS @dsainati1 @dreamsmasher
/docs/ @turbolent @SupunS @dsainati1 @joshuahannan @dreamsmasher
* @turbolent @SupunS @dsainati1
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Cadence - The resource-oriented smart contract programming language
#
# Copyright Dapper Labs, Inc.
# Copyright Flow Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,15 +45,15 @@ build: build-tools ./runtime/cmd/parse/parse ./runtime/cmd/parse/parse.wasm ./ru
go build -o $@ ./runtime/cmd/main

.PHONY: build-tools
build-tools: build-analysis build-batch-script
build-tools: build-analysis build-get-contracts

.PHONY: build-analysis
build-analysis:
(cd ./tools/analysis && go build .)

.PHONY: build-batch-script
build-batch-script:
(cd ./tools/batch-script && go build .)
.PHONY: build-get-contracts
build-get-contracts:
(cd ./tools/get-contracts && go build .)

.PHONY: ci
ci:
Expand Down
4 changes: 2 additions & 2 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cadence
Copyright 2019-2023 Dapper Labs, Inc.
Copyright 2019-2024 Flow Foundation

This product includes software developed at Dapper Labs, Inc. (https://www.dapperlabs.com/).
This product includes software developed at the Flow Foundation (https://flow.com/flow-foundation).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ Check out the [Cadence Docs](https://docs.onflow.org/cadence/language/).

If you would like to contribute to Cadence, have a look at the [contributing guide](https://github.com/onflow/cadence/blob/master/CONTRIBUTING.md).

Development documentation can be found in the [/docs directory](https://github.com/onflow/flow/tree/master/docs).
Development documentation can be found in the [`/docs` directory](https://github.com/onflow/cadence/tree/master/docs).
For example, it contains the source for the language reference.
31 changes: 29 additions & 2 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,33 @@ For example, a simple integer literal would be "boxed" in several outer grammar

## What is the algorithmic efficiency of operations on arrays and dictionaries?

Arrays and dictionaries are implemented [as trees](https://github.com/onflow/atree).
This means that lookup operations do not run in constant time.
Arrays and dictionaries are implemented [as trees](https://github.com/onflow/atree).
This means that lookup operations do not run in constant time.
In certain cases, a mutation operation may cause a rebalancing of the tree.

## Analyzing Cadence code

To analyze Cadence code, you can use the [Go package `github.com/onflow/cadence/analysis`](https://github.com/onflow/cadence/tree/master/tools/analysis).
It is similar to the [Go package `golang.org/x/tools/go/analysis`](https://pkg.go.dev/golang.org/x/tools/go/analysis), which allows analyzing Go code.
The blog post at https://eli.thegreenplace.net/2020/writing-multi-package-analysis-tools-for-go/ can be followed to learn more about how to write an analyzer.
The API of the analysis package for Cadence programs is fairly similar to the package for Go programs, but not identical.

To run the analyzer pass, the [Cadence linter tool](https://github.com/onflow/cadence-tools/tree/master/lint#cadence-lint) can be used.
For example, it allows running the pass over all contracts of a network.

There are several options to run the analyzer pass with the linter tool:
- The analysis pass can be written directly in the linter tool. See the existing passes in the linter tool for examples.
- The analysis pass can be written in a separate package in Cadence, and the linter tool can use it.
The go.mod `replace` statement can be used to point to a locally modified Cadence working directory.
- The linter supports [Go plugins](https://pkg.go.dev/plugin) (see e.g. https://eli.thegreenplace.net/2021/plugins-in-go/) https://github.com/onflow/cadence-tools/blob/83eb7d4d19ddf2dd7ad3fdcc6aa6451a6bc126ff/lint/cmd/lint/main.go#L48.
The analyzer pass can be written in a separate module, built as a plugin, and loaded in the linter using the `-plugin` command line option.

## Analyzing Cadence values / state snapshots

To analyze Cadence values (`interpreter.Value`), you can use the function [`interpreter.InspectValue`](https://github.com/onflow/cadence/blob/master/runtime/interpreter/inspect.go#L31).

To find static types in Cadence values (e.g. in type values, containers, capabilities), you can see which values contain static types in the [Cadence 1.0 static type migration code](https://github.com/onflow/cadence/blob/master/migrations/statictypes/statictype_migration.go#L67).

To load values from a state snapshot you can use the [flow-go `util` commad](https://github.com/onflow/flow-go/tree/master/cmd/util) to convert a state snapshot in trie format to a file which just contains the payloads.

To get a `runtime.Storage` instance from it, use `util.ReadPayloadFile`, `util.NewPayloadSnapshot`, `state.NewTransactionState`, `environment.NewAccounts`, `util.NewAccountsAtreeLedger`, and finally `runtime.NewStorage`.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Documentation

This directory documention for contributors to/developers of Cadence.
This directory contains documentation for contributors to/developers of Cadence.

If you are looking for documentation for Cadence, it can be found at https://developers.flow.com/cadence.
If you are looking for documentation for using Cadence, it can be found at https://cadence-lang.org/.

The source for the user documentation is at https://github.com/onflow/docs/tree/main/docs/cadence, not in this repository.
The source for the user documentation is at https://github.com/onflow/cadence-lang.org, not in this repository.
2 changes: 1 addition & 1 deletion docs/anti-patterns.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/anti-patterns.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/anti-patterns.mdx
2 changes: 1 addition & 1 deletion docs/contract-upgrades.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/contract-upgrades.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/contract-upgrades.mdx
2 changes: 1 addition & 1 deletion docs/design-patterns.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/design-patterns.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/design-patterns.mdx
24 changes: 0 additions & 24 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
# Development

## Running the latest version of the Language Server in the Visual Studio Code Extension

- Ensure that a `replace` statement exists in `languageserver/go.mod`, so that the language server compiles with the local changes to Cadence.

- Find the Visual Studio Code preference named "Cadence: Flow Command" and change it to:

```text
/path/to/cadence/languageserver/run.sh
```

- Restart Visual Studio Code

This will automatically recompile the language server every time it is started.

## Debugging the Language Server

- Follow the instructions above (see "Running the latest version of the Language Server in the Visual Studio Code Extension")

- Attach to the process of the language server started by Visual Studio Code.

For example, in Goland, choose Run -> Attach to Process.

This requires gops to be installed, which can be done using `go get github.com/google/gops`.

## Tools

The [`runtime/cmd` directory](https://github.com/onflow/cadence/tree/master/runtime/cmd)
Expand Down
2 changes: 1 addition & 1 deletion docs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/intro.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/intro.md
2 changes: 1 addition & 1 deletion docs/json-cadence-spec.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/json-cadence-spec.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/json-cadence-spec.md
2 changes: 1 addition & 1 deletion docs/language/access-control.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/access-control.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/access-control.md
2 changes: 1 addition & 1 deletion docs/language/accounts.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/accounts.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/accounts.mdx
2 changes: 1 addition & 1 deletion docs/language/attachments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/attachments.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/attachments.mdx
2 changes: 1 addition & 1 deletion docs/language/built-in-functions.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/built-in-functions.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/built-in-functions.mdx
2 changes: 1 addition & 1 deletion docs/language/capability-based-access-control.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/capability-based-access-control.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/capabilities.md
2 changes: 1 addition & 1 deletion docs/language/composite-types.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/composite-types.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/composite-types.mdx
2 changes: 1 addition & 1 deletion docs/language/constants-and-variables.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/constants-and-variables.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/constants-and-variables.md
2 changes: 1 addition & 1 deletion docs/language/contract-updatability.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/contract-updatability.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/contract-updatability.md
2 changes: 1 addition & 1 deletion docs/language/contracts.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/contracts.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/contracts.mdx
2 changes: 1 addition & 1 deletion docs/language/control-flow.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/control-flow.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/control-flow.md
2 changes: 1 addition & 1 deletion docs/language/core-events.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/core-events.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/core-events.md
2 changes: 1 addition & 1 deletion docs/language/crypto.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/crypto.mdx
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/crypto.mdx
2 changes: 1 addition & 1 deletion docs/language/enumerations.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This document has been moved to a new location:

https://github.com/onflow/docs/tree/main/docs/cadence/language/enumerations.md
https://github.com/onflow/cadence-lang.org/tree/main/docs/language/enumerations.md
Loading

0 comments on commit cbfcbd3

Please sign in to comment.