Skip to content

Commit

Permalink
Merge branch 'develop' into serialization-test
Browse files Browse the repository at this point in the history
  • Loading branch information
howjmay committed Jul 13, 2023
2 parents b56e3bc + 29db418 commit 8ed3202
Show file tree
Hide file tree
Showing 92 changed files with 3,181 additions and 1,506 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/go-mod-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Go mod tidy

on:
pull_request:
branches: [develop]

jobs:
build:
name: run go mod tidy
runs-on: ubuntu-latest
# don't run on PRs from forks (it will fail because secrets won't be available), run only on renovate bot PRs
if: github.actor == 'renovate[bot]'
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go

- name: Generate token # generate a token to trigger the rest of the CI tasks... https://github.com/tibdex/github-app-token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.IOTA_GH_APP_ID }}
private_key: ${{ secrets.IOTA_GH_APP_PRIVATE_KEY }}

- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.generate_token.outputs.token }}

- name: Run go mod tidy script
run: ./scripts/go_mod_tidy.sh

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Actions
committer_email: [email protected]
message: "go mod tidy"
add: "."
2 changes: 1 addition & 1 deletion .github/workflows/heavy-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
args: --timeout 10m0s
skip-pkg-cache: true

- name: Run golangci-lint on wasp-cli
- name: Run golangci-lint on wasp-cli
uses: golangci/golangci-lint-action@v3
with:
working-directory: tools/wasp-cli
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
retention-days: 1

- name: Set up Node
uses: actions/setup-node@v3.6.0
uses: actions/setup-node@v3.7.0
with:
node-version: '14'

Expand Down
5 changes: 5 additions & 0 deletions components/chains/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func provide(c *dig.Container) error {
deps.NetworkProvider,
deps.TrustedNetworkManager,
deps.ChainStateDatabaseManager.ChainStateKVStore,
ParamsWAL.LoadToStore,
ParamsWAL.Enabled,
ParamsWAL.Path,
ParamsStateManager.BlockCacheMaxSize,
Expand All @@ -111,6 +112,10 @@ func provide(c *dig.Container) error {
ParamsStateManager.StateManagerTimerTickPeriod,
ParamsStateManager.PruningMinStatesToKeep,
ParamsStateManager.PruningMaxStatesToDelete,
ParamsSnapshotManager.Period,
ParamsSnapshotManager.LocalPath,
ParamsSnapshotManager.NetworkPaths,
ParamsSnapshotManager.UpdatePeriod,
deps.ChainRecordRegistryProvider,
deps.DKShareRegistryProvider,
deps.NodeIdentityProvider,
Expand Down
22 changes: 16 additions & 6 deletions components/chains/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ type ParametersChains struct {
}

type ParametersWAL struct {
Enabled bool `default:"true" usage:"whether the \"write-ahead logging\" is enabled"`
Path string `default:"waspdb/wal" usage:"the path to the \"write-ahead logging\" folder"`
LoadToStore bool `default:"false" usage:"load blocks from \"write-ahead log\" to the store on node start-up"`
Enabled bool `default:"true" usage:"whether the \"write-ahead logging\" is enabled"`
Path string `default:"waspdb/wal" usage:"the path to the \"write-ahead logging\" folder"`
}

type ParametersValidator struct {
Expand All @@ -36,11 +37,19 @@ type ParametersStateManager struct {
PruningMaxStatesToDelete int `default:"1000" usage:"on single store pruning attempt at most this number of states will be deleted"`
}

type ParametersSnapshotManager struct {
Period uint32 `default:"0" usage:"how often state snapshots should be made: 1000 meaning \"every 1000th state\", 0 meaning \"making snapshots is disabled\""`
LocalPath string `default:"waspdb/snap" usage:"the path to the snapshots folder in this node's disk"`
NetworkPaths []string `default:"" usage:"the list of paths to the remote (http(s)) snapshot locations; each of listed locations must contain 'INDEX' file with list of snapshot files"`
UpdatePeriod time.Duration `default:"5m" usage:"how often known snapshots list should be updated"`
}

var (
ParamsChains = &ParametersChains{}
ParamsWAL = &ParametersWAL{}
ParamsValidator = &ParametersValidator{}
ParamsStateManager = &ParametersStateManager{}
ParamsChains = &ParametersChains{}
ParamsWAL = &ParametersWAL{}
ParamsValidator = &ParametersValidator{}
ParamsStateManager = &ParametersStateManager{}
ParamsSnapshotManager = &ParametersSnapshotManager{}
)

var params = &app.ComponentParams{
Expand All @@ -49,6 +58,7 @@ var params = &app.ComponentParams{
"wal": ParamsWAL,
"validator": ParamsValidator,
"stateManager": ParamsStateManager,
"snapshots": ParamsSnapshotManager,
},
Masked: nil,
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This is the actual client to interact with the fairroulette smart contract.

It uses the wasp_client library for the low level interaction. In the future, this won't be nessecary,
It uses the wasp_client library for the low level interaction. In the future, this won't be necessary,
as we will provide an external library at some point.


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface IOffLedger {
nonce: bigint;
balances: Balance[];

// Public Key and Signature will get set in the Sign function, so no inital set is required
// Public Key and Signature will get set in the Sign function, so no initial set is required
publicKey?: Buffer;
signature?: Buffer;
}
104 changes: 77 additions & 27 deletions contracts/wasm/testcore/rs/testcoreimpl/src/funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,38 @@ pub fn func_call_on_chain(ctx: &ScFuncContext, f: &CallOnChainContext) {
}

let counter = f.state.counter();
ctx.log(&format!("call depth = {}, hnameContract = {}, hnameEP = {}, counter = {}",
&f.params.n().to_string(),
&hname_contract.to_string(),
&hname_ep.to_string(),
&counter.to_string()));
ctx.log(&format!(
"call depth = {}, hnameContract = {}, hnameEP = {}, counter = {}",
&f.params.n().to_string(),
&hname_contract.to_string(),
&hname_ep.to_string(),
&counter.to_string()
));

counter.set_value(counter.value() + 1);

let parms = ScDict::new(&[]);
let params = ScDict::new(&[]);
let key = string_to_bytes(PARAM_N);
parms.set(&key, &uint64_to_bytes(param_int));
let ret = ctx.call(hname_contract, hname_ep, Some(parms), None);
params.set(&key, &uint64_to_bytes(param_int));
let ret = ctx.call(hname_contract, hname_ep, Some(params), None);
let ret_val = uint64_from_bytes(&ret.get(&key));
f.results.n().set_value(ret_val);
}

pub fn func_check_context_from_full_ep(ctx: &ScFuncContext, f: &CheckContextFromFullEPContext) {
ctx.require(f.params.agent_id().value() == ctx.account_id(), "fail: agentID");
ctx.require(
f.params.agent_id().value() == ctx.account_id(),
"fail: agentID",
);
ctx.require(f.params.caller().value() == ctx.caller(), "fail: caller");
ctx.require(f.params.chain_id().value() == ctx.current_chain_id(), "fail: chainID");
ctx.require(f.params.chain_owner_id().value() == ctx.chain_owner_id(), "fail: chainOwnerID");
ctx.require(
f.params.chain_id().value() == ctx.current_chain_id(),
"fail: chainID",
);
ctx.require(
f.params.chain_owner_id().value() == ctx.chain_owner_id(),
"fail: chainOwnerID",
);
}

pub fn func_claim_allowance(ctx: &ScFuncContext, _f: &ClaimAllowanceContext) {
Expand All @@ -58,7 +69,10 @@ pub fn func_do_nothing(ctx: &ScFuncContext, _f: &DoNothingContext) {
ctx.log("doing nothing...");
}

pub fn func_estimate_min_storage_deposit(ctx: &ScFuncContext, _f: &EstimateMinStorageDepositContext) {
pub fn func_estimate_min_storage_deposit(
ctx: &ScFuncContext,
_f: &EstimateMinStorageDepositContext,
) {
let provided = ctx.allowance().base_tokens();
let dummy = ScFuncs::estimate_min_storage_deposit(ctx);
let required = ctx.estimate_storage_deposit(&dummy.func);
Expand Down Expand Up @@ -89,13 +103,19 @@ pub fn func_pass_types_full(ctx: &ScFuncContext, f: &PassTypesFullContext) {
ctx.require(f.params.int64_zero().value() == 0, "int64-0 wrong");
ctx.require(f.params.string().value() == PARAM_STRING, "string wrong");
ctx.require(f.params.string_zero().value() == "", "string-0 wrong");
ctx.require(f.params.hname().value() == ScHname::new(PARAM_HNAME), "Hname wrong");
ctx.require(
f.params.hname().value() == ScHname::new(PARAM_HNAME),
"Hname wrong",
);
ctx.require(f.params.hname_zero().value() == ScHname(0), "Hname-0 wrong");
}

pub fn func_ping_allowance_back(ctx: &ScFuncContext, _f: &PingAllowanceBackContext) {
let caller = ctx.caller();
ctx.require(caller.is_address(), "pingAllowanceBack: caller expected to be a L1 address");
ctx.require(
caller.is_address(),
"pingAllowanceBack: caller expected to be a L1 address",
);
let transfer = wasmlib::ScTransfer::from_balances(&ctx.allowance());
ctx.transfer_allowed(&ctx.account_id(), &transfer);
ctx.send(&caller.address(), &transfer);
Expand All @@ -109,7 +129,10 @@ pub fn func_run_recursion(ctx: &ScFuncContext, f: &RunRecursionContext) {

let call_on_chain = ScFuncs::call_on_chain(ctx);
call_on_chain.params.n().set_value(depth - 1);
call_on_chain.params.hname_ep().set_value(HFUNC_RUN_RECURSION);
call_on_chain
.params
.hname_ep()
.set_value(HFUNC_RUN_RECURSION);
call_on_chain.func.call();
let ret_val = call_on_chain.results.n().value();
f.results.n().set_value(ret_val);
Expand All @@ -134,7 +157,10 @@ pub fn func_send_to_address(_ctx: &ScFuncContext, _f: &SendToAddressContext) {
}

pub fn func_set_int(_ctx: &ScFuncContext, f: &SetIntContext) {
f.state.ints().get_int64(&f.params.name().value()).set_value(f.params.int_value().value());
f.state
.ints()
.get_int64(&f.params.name().value())
.set_value(f.params.int_value().value());
}

pub fn func_spawn(ctx: &ScFuncContext, f: &SpawnContext) {
Expand Down Expand Up @@ -189,7 +215,10 @@ pub fn func_test_call_panic_full_ep(ctx: &ScFuncContext, _f: &TestCallPanicFullE
ScFuncs::test_panic_full_ep(ctx).func.call();
}

pub fn func_test_call_panic_view_ep_from_full(ctx: &ScFuncContext, _f: &TestCallPanicViewEPFromFullContext) {
pub fn func_test_call_panic_view_ep_from_full(
ctx: &ScFuncContext,
_f: &TestCallPanicViewEPFromFullContext,
) {
ScFuncs::test_panic_view_ep(ctx).func.call();
}

Expand Down Expand Up @@ -242,15 +271,25 @@ pub fn func_withdraw_from_chain(ctx: &ScFuncContext, f: &WithdrawFromChainContex
// NOTE: make sure you READ THE DOCS before calling this function
let xfer = coreaccounts::ScFuncs::transfer_account_to_chain(ctx);
xfer.params.gas_reserve().set_value(gas_reserve);
xfer.func.transfer_base_tokens(storage_deposit + gas_fee + gas_reserve).
allowance_base_tokens(withdrawal + storage_deposit + gas_reserve).
post_to_chain(target_chain);
xfer.func
.transfer_base_tokens(storage_deposit + gas_fee + gas_reserve)
.allowance_base_tokens(withdrawal + storage_deposit + gas_reserve)
.post_to_chain(target_chain);
}

pub fn view_check_context_from_view_ep(ctx: &ScViewContext, f: &CheckContextFromViewEPContext) {
ctx.require(f.params.agent_id().value() == ctx.account_id(), "fail: agentID");
ctx.require(f.params.chain_id().value() == ctx.current_chain_id(), "fail: chainID");
ctx.require(f.params.chain_owner_id().value() == ctx.chain_owner_id(), "fail: chainOwnerID");
ctx.require(
f.params.agent_id().value() == ctx.account_id(),
"fail: agentID",
);
ctx.require(
f.params.chain_id().value() == ctx.current_chain_id(),
"fail: chainID",
);
ctx.require(
f.params.chain_owner_id().value() == ctx.chain_owner_id(),
"fail: chainOwnerID",
);
}

fn fibonacci(n: u64) -> u64 {
Expand Down Expand Up @@ -292,7 +331,10 @@ pub fn view_get_counter(_ctx: &ScViewContext, f: &GetCounterContext) {
pub fn view_get_int(ctx: &ScViewContext, f: &GetIntContext) {
let name = f.params.name().value();
let value = f.state.ints().get_int64(&name);
ctx.require(value.exists(), &("param '".to_string() + &name + "' not found"));
ctx.require(
value.exists(),
&("param '".to_string() + &name + "' not found"),
);
f.results.values().get_int64(&name).set_value(value.value());
}

Expand All @@ -317,11 +359,17 @@ pub fn view_pass_types_view(ctx: &ScViewContext, f: &PassTypesViewContext) {
ctx.require(f.params.int64_zero().value() == 0, "int64-0 wrong");
ctx.require(f.params.string().value() == PARAM_STRING, "string wrong");
ctx.require(f.params.string_zero().value() == "", "string-0 wrong");
ctx.require(f.params.hname().value() == ScHname::new(PARAM_HNAME), "Hname wrong");
ctx.require(
f.params.hname().value() == ScHname::new(PARAM_HNAME),
"Hname wrong",
);
ctx.require(f.params.hname_zero().value() == ScHname(0), "Hname-0 wrong");
}

pub fn view_test_call_panic_view_ep_from_view(ctx: &ScViewContext, _f: &TestCallPanicViewEPFromViewContext) {
pub fn view_test_call_panic_view_ep_from_view(
ctx: &ScViewContext,
_f: &TestCallPanicViewEPFromViewContext,
) {
ScFuncs::test_panic_view_ep(ctx).func.call();
}

Expand All @@ -336,5 +384,7 @@ pub fn view_test_panic_view_ep(ctx: &ScViewContext, _f: &TestPanicViewEPContext)
pub fn view_test_sandbox_call(ctx: &ScViewContext, f: &TestSandboxCallContext) {
let get_chain_info = coregovernance::ScFuncs::get_chain_info(ctx);
get_chain_info.func.call();
f.results.sandbox_call().set_value(&get_chain_info.results.chain_id().value().to_string());
f.results
.sandbox_call()
.set_value(&get_chain_info.results.chain_id().value().to_string());
}
Loading

0 comments on commit 8ed3202

Please sign in to comment.