Skip to content

Commit

Permalink
Merge pull request #776 from iotaledger/develop
Browse files Browse the repository at this point in the history
Develop to Master merge, new release
  • Loading branch information
fijter authored Feb 2, 2022
2 parents 8cd6ecd + cc7a412 commit f1ac0ed
Show file tree
Hide file tree
Showing 478 changed files with 17,313 additions and 3,662 deletions.
34 changes: 34 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Description of change

Please write a summary of your changes and why you made them.

## Links to any relevant issues

Be sure to reference any related issues by adding `fixes issue #`.

## Type of change

Choose a type of change, and delete any options that are not relevant.

- Bug fix (a non-breaking change which fixes an issue)
- Enhancement (a non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- Documentation Fix

## How the change has been tested

Describe the tests that you ran to verify your changes.

Make sure to provide instructions for the maintainer as well as any relevant configurations.

## Change checklist

Tick the boxes that are relevant to your changes, and delete any items that are not.

- [ ] I have followed the [contribution guidelines](https://wiki.iota.org/smart-contracts/contribute) for this project
- [ ] I have performed a self-review of my own code
- [ ] I have selected the `develop` branch as the target branch
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have checked that new and existing unit tests pass locally with my changes
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: ^1.15
-
name: Run GoReleaser
run: goreleaser --rm-dist
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ wasp-cli.json
.DS_Store
./tools/wasp-cli/wasp-cli
.docusaurus
node_modules
**/node_modules/
goshimmer.log
/*.sh
8 changes: 5 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ builds:
- -tags=builtin_static,rocksdb
goos:
- linux
- windows
- darwin
# Disabled until the grocksdb supports darwin and windows:
# See: https://github.com/gohornet/grocksdb/commit/0ad7d027aa822e322cd81b2ef7e6696b675472b6
# - windows
# - darwin
goarch:
- amd64

Expand All @@ -39,7 +41,7 @@ archives:
format: zip
wrap_in_directory: true
files:
- readme.md
- README.md
- config.json
- LICENSE

Expand Down
2 changes: 1 addition & 1 deletion client/callview.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *WaspClient) CallView(chainID *iscp.ChainID, hContract iscp.Hname, funct
var res dict.Dict
var err error
for {
err = c.do(http.MethodGet, routes.CallView(chainID.Base58(), hContract.String(), functionName), arguments, &res)
err = c.do(http.MethodPost, routes.CallView(chainID.Base58(), hContract.String(), functionName), arguments, &res)
switch {
case err == nil:
return res, err
Expand Down
21 changes: 21 additions & 0 deletions client/chain_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package client

import (
"net/http"

"github.com/iotaledger/wasp/packages/iscp"
"github.com/iotaledger/wasp/packages/webapi/model"
"github.com/iotaledger/wasp/packages/webapi/routes"
)

// GetChainRecord fetches ChainInfo by address
func (c *WaspClient) GetChainInfo(chID *iscp.ChainID) (*model.ChainInfo, error) {
res := &model.ChainInfo{}
if err := c.do(http.MethodGet, routes.GetChainInfo(chID.Base58()), nil, res); err != nil {
return nil, err
}
return res, nil
}
3 changes: 3 additions & 0 deletions client/chain_record.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package client

import (
Expand Down
34 changes: 0 additions & 34 deletions client/committee_record.go

This file was deleted.

38 changes: 35 additions & 3 deletions client/goshimmer/goshimmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,49 @@ func (c *Client) GetConfirmedOutputs(address ledgerstate.Address) ([]ledgerstate
if err != nil {
return nil, fmt.Errorf("GetUnspentOutputs: %w", err)
}
ret := make([]ledgerstate.Output, len(r.Outputs))
for i, out := range r.Outputs {

// prevent calling c.IsTransactionConfirmed() twice for the same tx
confirmedCache := map[string]bool{}
isConfirmed := func(txID string) (bool, error) {
confirmed, ok := confirmedCache[txID]
if ok {
return confirmed, nil
}
confirmed, err = c.IsTransactionConfirmed(txID)
if err != nil {
return false, err
}
confirmedCache[txID] = confirmed
return confirmed, nil
}

var ret []ledgerstate.Output
for _, out := range r.Outputs {
var err error
ret[i], err = out.ToLedgerstateOutput()
confirmed, err := isConfirmed(out.OutputID.TransactionID)
if err != nil {
return nil, err
}
if !confirmed {
continue
}
output, err := out.ToLedgerstateOutput()
if err != nil {
return nil, err
}
ret = append(ret, output)
}
return ret, nil
}

func (c *Client) IsTransactionConfirmed(txID string) (bool, error) {
r, err := c.api.GetTransactionInclusionState(txID)
if err != nil {
return false, fmt.Errorf("IsTransactionConfirmed: %w", err)
}
return r.Confirmed && !r.Rejected, nil
}

func (c *Client) postTx(tx *ledgerstate.Transaction) error {
data := tx.Bytes()
if len(data) > parameters.MaxSerializedTransactionToGoshimmer {
Expand Down
9 changes: 9 additions & 0 deletions client/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ func (c *WaspClient) GetChainNodeConnectionMetrics(chID *iscp.ChainID) (*model.N
}
return ncmm, nil
}

// GetNodeConnectionMetrics fetches a consensus workflow status by address
func (c *WaspClient) GetChainConsensusWorkflowStatus(chID *iscp.ChainID) (*model.ConsensusWorkflowStatus, error) {
ncmm := &model.ConsensusWorkflowStatus{}
if err := c.do(http.MethodGet, routes.GetChainConsensusWorkflowStatus(chID.Base58()), nil, ncmm); err != nil {
return nil, err
}
return ncmm, nil
}
13 changes: 0 additions & 13 deletions client/multiclient/committee_record.go

This file was deleted.

26 changes: 26 additions & 0 deletions client/node_ownership.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

package client

import (
"net/http"

"github.com/iotaledger/goshimmer/packages/ledgerstate"
"github.com/iotaledger/hive.go/crypto/ed25519"
"github.com/iotaledger/wasp/packages/vm/core/governance"
"github.com/iotaledger/wasp/packages/webapi/model"
"github.com/iotaledger/wasp/packages/webapi/routes"
)

func (c *WaspClient) NodeOwnershipCertificate(nodePubKey ed25519.PublicKey, ownerAddress ledgerstate.Address) (governance.NodeOwnershipCertificate, error) {
req := model.NodeOwnerCertificateRequest{
NodePubKey: model.NewBytes(nodePubKey.Bytes()),
OwnerAddress: model.NewAddress(ownerAddress),
}
res := model.NodeOwnerCertificateResponse{}
if err := c.do(http.MethodPost, routes.AdmNodeOwnerCertificate(), req, &res); err != nil {
return nil, err
}
return governance.NewNodeOwnershipCertificateFromBytes(res.Certificate.Bytes()), nil
}
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@
},
"nanomsg":{
"port": 5550
},
"metrics":{
"bindAddress": "127.0.0.1:2112",
"enabled": true
}
}
4 changes: 2 additions & 2 deletions contracts/wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ Prerequisites:
[downloaded here](https://rustwasm.github.io/wasm-pack/).

Building a Rust smart contract is very simple when using the Rust plugin in any
IntelliJ based development environment. Open the _contracts/rust_ sub folder in
IntelliJ based development environment. Open the _contracts/wasm_ sub folder in
your IntelliJ, which then provides you with the Rust workspace.

The easiest way to create a new contract is to copy the _helloworld_ folder to a
properly named new folder within the _rust_ sub folder. Next, change the fields
in the first section of the new folder's _cargo.toml_ file to match your
preferences. Make sure the package name equals the folder name. Finally, add the
new folder to the workspace in the _cargo.toml_ in the _contracts/rust_ folder.
new folder to the workspace in the _cargo.toml_ in the _contracts/wasm_ folder.

To build the new smart contract select _Run->Edit Configurations_. Add a new
configuration based on the _wasmpack_ template, type the _name_ of the new
Expand Down
4 changes: 3 additions & 1 deletion contracts/wasm/core_build.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@echo off
cd ..\..\packages\vm\wasmlib
schema -core -go -rust -ts -force
schema -core -go -rust -ts -client -force
del /s /q d:\work\node_modules\wasmlib\*.* >nul:
del /s /q d:\work\node_modules\wasmclient\*.* >nul:
xcopy /s /q d:\Work\go\github.com\iotaledger\wasp\packages\vm\wasmlib\ts\wasmclient d:\work\node_modules\wasmclient
xcopy /s /q d:\Work\go\github.com\iotaledger\wasp\packages\vm\wasmlib\ts\wasmlib d:\work\node_modules\wasmlib
cd ..\..\..\contracts\wasm
16 changes: 8 additions & 8 deletions contracts/wasm/dividend/go/dividend/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,53 +30,53 @@ type ImmutableMemberParams struct {
}

func (s ImmutableMemberParams) Address() wasmlib.ScImmutableAddress {
return wasmlib.NewScImmutableAddress(s.id, idxMap[IdxParamAddress])
return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress))
}

func (s ImmutableMemberParams) Factor() wasmlib.ScImmutableInt64 {
return wasmlib.NewScImmutableInt64(s.id, idxMap[IdxParamFactor])
return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ParamFactor))
}

type MutableMemberParams struct {
id int32
}

func (s MutableMemberParams) Address() wasmlib.ScMutableAddress {
return wasmlib.NewScMutableAddress(s.id, idxMap[IdxParamAddress])
return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress))
}

func (s MutableMemberParams) Factor() wasmlib.ScMutableInt64 {
return wasmlib.NewScMutableInt64(s.id, idxMap[IdxParamFactor])
return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ParamFactor))
}

type ImmutableSetOwnerParams struct {
id int32
}

func (s ImmutableSetOwnerParams) Owner() wasmlib.ScImmutableAgentID {
return wasmlib.NewScImmutableAgentID(s.id, idxMap[IdxParamOwner])
return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ParamOwner))
}

type MutableSetOwnerParams struct {
id int32
}

func (s MutableSetOwnerParams) Owner() wasmlib.ScMutableAgentID {
return wasmlib.NewScMutableAgentID(s.id, idxMap[IdxParamOwner])
return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ParamOwner))
}

type ImmutableGetFactorParams struct {
id int32
}

func (s ImmutableGetFactorParams) Address() wasmlib.ScImmutableAddress {
return wasmlib.NewScImmutableAddress(s.id, idxMap[IdxParamAddress])
return wasmlib.NewScImmutableAddress(s.id, wasmlib.KeyID(ParamAddress))
}

type MutableGetFactorParams struct {
id int32
}

func (s MutableGetFactorParams) Address() wasmlib.ScMutableAddress {
return wasmlib.NewScMutableAddress(s.id, idxMap[IdxParamAddress])
return wasmlib.NewScMutableAddress(s.id, wasmlib.KeyID(ParamAddress))
}
8 changes: 4 additions & 4 deletions contracts/wasm/dividend/go/dividend/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@ type ImmutableGetFactorResults struct {
}

func (s ImmutableGetFactorResults) Factor() wasmlib.ScImmutableInt64 {
return wasmlib.NewScImmutableInt64(s.id, idxMap[IdxResultFactor])
return wasmlib.NewScImmutableInt64(s.id, wasmlib.KeyID(ResultFactor))
}

type MutableGetFactorResults struct {
id int32
}

func (s MutableGetFactorResults) Factor() wasmlib.ScMutableInt64 {
return wasmlib.NewScMutableInt64(s.id, idxMap[IdxResultFactor])
return wasmlib.NewScMutableInt64(s.id, wasmlib.KeyID(ResultFactor))
}

type ImmutableGetOwnerResults struct {
id int32
}

func (s ImmutableGetOwnerResults) Owner() wasmlib.ScImmutableAgentID {
return wasmlib.NewScImmutableAgentID(s.id, idxMap[IdxResultOwner])
return wasmlib.NewScImmutableAgentID(s.id, wasmlib.KeyID(ResultOwner))
}

type MutableGetOwnerResults struct {
id int32
}

func (s MutableGetOwnerResults) Owner() wasmlib.ScMutableAgentID {
return wasmlib.NewScMutableAgentID(s.id, idxMap[IdxResultOwner])
return wasmlib.NewScMutableAgentID(s.id, wasmlib.KeyID(ResultOwner))
}
Loading

0 comments on commit f1ac0ed

Please sign in to comment.