Skip to content

Commit

Permalink
218 deploy thyra on innonet 15 (#253)
Browse files Browse the repository at this point in the history
uses testnet 15

Co-authored-by: Grégory Libert <[email protected]>
Co-authored-by: Sebastien Valla <[email protected]>
  • Loading branch information
3 people authored Nov 15, 2022
1 parent 66c133c commit f62cefb
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 199 deletions.
89 changes: 3 additions & 86 deletions api/swagger/server/restapi/operations/cmd_execute_function.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 4 additions & 14 deletions api/swagger/server/restapi/resource/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,7 @@ paths:
gaz:
price: 0
limit: 700000000
coins:
parallel: 0
sequential: 0
coins: 0
expiry: 3
fee: 0
keyId: default
Expand Down Expand Up @@ -476,17 +474,9 @@ paths:
description: Maximum number of gaz unit that a node will be able consume.
default: 700000000
coins:
type: object
description: Coins to be send from caller to smart contract address.
properties:
parallel:
description: Number of parallel coins to transfer from the caller to the smart contract address.
type: number
default: 0
sequential:
description: Number of sequential coins to transfer from the caller to the smart contract address.
type: number
default: 0
description: Set the fee amount (in massa) that will be given to the block creator.
type: number
default: 0
expiry:
description: Set the expiry duration (in number of slots) of the transaction.
type: integer
Expand Down
2 changes: 1 addition & 1 deletion cmd/callSC/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {
callSC := callSC.New(
addr, "set_dots", NoArgument,
sendOperation.NoGazFee, sendOperation.DefaultGazLimit,
sendOperation.NoSequentialCoin, sendOperation.NoParallelCoin)
0)

opID, err := sendOperation.Call(client, sendOperation.DefaultSlotsDuration, sendOperation.NoFee, callSC,
wlt.KeyPairs[0].PublicKey, wlt.KeyPairs[0].PrivateKey)
Expand Down
2 changes: 1 addition & 1 deletion cmd/executeSC/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {

exeSC := executesc.New(websiteStorer,
sendOperation.DefaultGazLimit, sendOperation.NoGazFee,
sendOperation.NoParallelCoin)
0, make(map[[3]uint8][]uint8))

opID, err := sendOperation.Call(
client,
Expand Down
Binary file modified cmd/executeSC/sc/websiteStorer.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions int/api/cmd/execute_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func ExecuteFunctionHandler(params operations.CmdExecuteFunctionParams, app *fyn
[]byte(params.Body.Args),
uint64(params.Body.Gaz.Price),
uint64(*params.Body.Gaz.Limit),
uint64(params.Body.Coins.Sequential),
uint64(params.Body.Coins.Parallel))
uint64(params.Body.Coins))

c := node.NewDefaultClient()

Expand Down
2 changes: 1 addition & 1 deletion int/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func parseNetworkFlag(massaNodeServerPtr *string) {
case "LABNET":
*massaNodeServerPtr = "https://labnet.massa.net/"
case "INNONET":
*massaNodeServerPtr = "https://inno.massa.net/test13"
*massaNodeServerPtr = "https://inno.massa.net/test15"
case "LOCALHOST":
*massaNodeServerPtr = "http://127.0.0.1"
}
Expand Down
53 changes: 22 additions & 31 deletions pkg/node/sendoperation/callsc/callsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ const CallSCOpID = uint64(4)

//nolint:tagliatelle
type OperationDetails struct {
MaxGaz int64 `json:"max_gas"`
GazPrice string `json:"gas_price"`
ParallelCoins string `json:"parallel_coins"`
SequentialCoins string `json:"sequential_coins"`
TargetAddr string `json:"target_addr"`
TargetFunc string `json:"target_func"`
Param interface{} `json:"param"`
MaxGaz int64 `json:"max_gas"`
GazPrice string `json:"gas_price"`
Coins string `json:"coins"`
TargetAddr string `json:"target_addr"`
TargetFunc string `json:"target_func"`
Param interface{} `json:"param"`
}

//nolint:tagliatelle
Expand All @@ -27,35 +26,31 @@ type Operation struct {
}

type CallSC struct {
address []byte
function string
parameters []byte
gazPrice uint64
gazLimit uint64
nbSequentialCoins uint64
nbParallelCoins uint64
address []byte
function string
parameters []byte
gazPrice uint64
gazLimit uint64
coins uint64
}

func New(address []byte, function string, parameters []byte, gazPrice uint64, gazLimit uint64, nbSequentialCoins uint64,
nbParallelCoins uint64,
func New(address []byte, function string, parameters []byte, gazPrice uint64, gazLimit uint64, coins uint64,
) *CallSC {
return &CallSC{
address: address, function: function, parameters: parameters,
gazPrice: gazPrice, gazLimit: gazLimit, nbSequentialCoins: nbSequentialCoins,
nbParallelCoins: nbParallelCoins,
gazPrice: gazPrice, gazLimit: gazLimit, coins: coins,
}
}

func (c *CallSC) Content() interface{} {
return &Operation{
CallSC: OperationDetails{
MaxGaz: int64(c.gazLimit),
GazPrice: fmt.Sprint(c.gazPrice),
ParallelCoins: fmt.Sprint(c.nbParallelCoins),
SequentialCoins: fmt.Sprint(c.nbSequentialCoins),
TargetAddr: "A" + base58.CheckEncode(append(make([]byte, 1), c.address...)),
TargetFunc: c.function,
Param: hex.EncodeToString(c.parameters),
MaxGaz: int64(c.gazLimit),
GazPrice: fmt.Sprint(c.gazPrice),
Coins: fmt.Sprint(c.coins),
TargetAddr: "A" + base58.CheckEncode(append(make([]byte, 1), c.address...)),
TargetFunc: c.function,
Param: hex.EncodeToString(c.parameters),
},
}
}
Expand All @@ -72,12 +67,8 @@ func (c *CallSC) Message() []byte {
nbBytes = binary.PutUvarint(buf, c.gazLimit)
msg = append(msg, buf[:nbBytes]...)

// ParallelCoins
nbBytes = binary.PutUvarint(buf, c.nbParallelCoins)
msg = append(msg, buf[:nbBytes]...)

// SequentialCoins
nbBytes = binary.PutUvarint(buf, c.nbSequentialCoins)
// Coins
nbBytes = binary.PutUvarint(buf, c.coins)
msg = append(msg, buf[:nbBytes]...)

// gazPrice
Expand Down
64 changes: 46 additions & 18 deletions pkg/node/sendoperation/executesc/executesc.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package executesc

import (
"bytes"
"encoding/binary"
"encoding/gob"
"fmt"
)

Expand All @@ -11,7 +13,8 @@ type OperationDetails struct {
Data []byte `json:"data"`
MaxGas uint64 `json:"max_gas"`
GasPrice string `json:"gas_price"`
Coins string `json:"coins"`
//nolint:tagliatelle
DataStore map[[3]uint8][]uint8 `json:"datastore"`
}

//nolint:tagliatelle
Expand All @@ -20,28 +23,30 @@ type Operation struct {
}

type ExecuteSC struct {
data []byte
maxGas uint64
gasPrice uint64
Coins uint64
data []byte
maxGas uint64
gasPrice uint64
dataStore map[[3]uint8][]uint8
}

func New(data []byte, maxGas uint64, gasPrice uint64, coins uint64) *ExecuteSC {
func New(data []byte, maxGas uint64, gasPrice uint64, coins uint64, dataStore map[[3]uint8][]uint8) *ExecuteSC {
gob.Register(map[[3]uint8]interface{}{})

return &ExecuteSC{
data: data,
maxGas: maxGas,
gasPrice: gasPrice,
Coins: coins,
data: data,
maxGas: maxGas,
gasPrice: gasPrice,
dataStore: dataStore,
}
}

func (e *ExecuteSC) Content() interface{} {
return &Operation{
ExecuteSC: OperationDetails{
Data: e.data,
MaxGas: e.maxGas,
GasPrice: fmt.Sprint(e.gasPrice),
Coins: fmt.Sprint(e.Coins),
Data: e.data,
MaxGas: e.maxGas,
GasPrice: fmt.Sprint(e.gasPrice),
DataStore: e.dataStore,
},
}
}
Expand All @@ -58,10 +63,6 @@ func (e *ExecuteSC) Message() []byte {
nbBytes = binary.PutUvarint(buf, e.maxGas)
msg = append(msg, buf[:nbBytes]...)

// Coins
nbBytes = binary.PutUvarint(buf, e.Coins)
msg = append(msg, buf[:nbBytes]...)

// GasPrice
nbBytes = binary.PutUvarint(buf, e.gasPrice)
msg = append(msg, buf[:nbBytes]...)
Expand All @@ -71,5 +72,32 @@ func (e *ExecuteSC) Message() []byte {
msg = append(msg, buf[:nbBytes]...)
msg = append(msg, e.data...)

// datastore
// Number of entries in the datastore
nbBytes = binary.PutUvarint(buf, uint64(len(e.dataStore)))
msg = append(msg, buf[:nbBytes]...)

for key, value := range e.dataStore {
compactAndAppendBytes(&msg, key)
compactAndAppendBytes(&msg, value)
}

return msg
}

func compactAndAppendBytes(msg *[]byte, value interface{}) {
buf := make([]byte, binary.MaxVarintLen64)
bytesBuffer := new(bytes.Buffer)
encoder := gob.NewEncoder(bytesBuffer)
err := encoder.Encode(value)
//nolint:golang-ci
if err != nil {
panic(err)
}

nbBytes := binary.PutUvarint(buf, uint64(bytesBuffer.Len()))
// Value length
*msg = append(*msg, buf[:nbBytes]...)
// Value in bytes
*msg = append(*msg, bytesBuffer.Bytes()...)
}
Loading

0 comments on commit f62cefb

Please sign in to comment.