-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add stake controlled governance contract #51
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
51ed8cd
to
a8b8913
Compare
a8b8913
to
827766f
Compare
be39adf
to
143f000
Compare
a2eadd2
to
39f693f
Compare
8d3d2ea
to
76e2312
Compare
e07babc
to
ce216b4
Compare
…t clients for cross contract interactions. Sharing types in cross contract interactions with contractimport! causes a false sense of interoperability, as they work in unit tests but not in futurenet. The error was: thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: MissingEntry("ProposalPayload")' The solution reached here was to: 1. Create a third crate "shared" that will hold the shared structures per contract until we find a better solution. 2. Remove the use of contract clients for cross contract interactions. Now we need to convert all the types to `Val` before interacting with the dependent contract and sending them through env.invoke_contract(...)
Now that we are using a third crate for sharing common types across contracts, we are allowed to access the types implementations (methods) . That allows us to reduce calls among contracts, since we can directly return that types and use their methods.
8003cb7
to
d40397c
Compare
I'm having problems with integration tests: [cargo-make] INFO - Running Task: invoke_init
2023-10-09T08:42:34.279065Z ERROR soroban_cli::log::diagnostic_event: 0: "AAAAAAAAAAAAAAAAAAAAAgAAAAAAAAADAAAADwAAAAdmbl9jYWxsAAAAAA0AAAAgZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAAPAAAABGluaXQAAAAQAAAAAQAAAAUAAAASAAAAAAAAAAAZBisi/w+3Ls+TCbj0Rnum3idac9ln9om6jCwcrqNOLAAAABIAAAABfcHs35M1GZ/JkY2+DHMs4dEUaqjynMnDYK/Gp0eulN8AAAAFAAAAAAAADhAAAAADAAATiAAAAA0AAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAO8="
2023-10-09T08:42:34.279511Z ERROR soroban_cli::log::diagnostic_event: 1: "AAAAAAAAAAAAAAABZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAACAAAAAAAAAAMAAAAPAAAAB2ZuX2NhbGwAAAAADQAAACBERVWYP/MPT5tnobJ2SVA+DUl1y81j0G+KF7bXd8aSRAAAAA8AAAAEaW5pdAAAABAAAAABAAAABQAAABIAAAABZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAAFAAAAAAAADhAAAAADAAATiAAAAAn/////////////////////AAAAAAAAAAE="
2023-10-09T08:42:34.279522Z ERROR soroban_cli::log::diagnostic_event: 2: "AAAAAAAAAAAAAAABREVVmD/zD0+bZ6GydklQPg1JdcvNY9Bvihe213fGkkQAAAACAAAAAAAAAAIAAAAPAAAABWVycm9yAAAAAAAAAgAAAAEAAAAHAAAAEAAAAAEAAAACAAAADgAAAC1WTSBjYWxsIGZhaWxlZDogRnVuYyhNaXNtYXRjaGluZ1BhcmFtZXRlckxlbikAAAAAAAAPAAAABGluaXQ="
2023-10-09T08:42:34.279542Z ERROR soroban_cli::log::diagnostic_event: 3: "AAAAAAAAAAAAAAABZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAACAAAAAAAAAAIAAAAPAAAABWVycm9yAAAAAAAAAgAAAAEAAAAHAAAAEAAAAAEAAAADAAAADgAAABRjb250cmFjdCBjYWxsIGZhaWxlZAAAAA8AAAAEaW5pdAAAABAAAAABAAAABQAAABIAAAABZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAAFAAAAAAAADhAAAAADAAATiAAAAAn/////////////////////AAAAAAAAAAE="
2023-10-09T08:42:34.279551Z ERROR soroban_cli::log::diagnostic_event: 4: "AAAAAAAAAAAAAAABZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAACAAAAAAAAAAIAAAAPAAAABWVycm9yAAAAAAAAAgAAAAEAAAAHAAAADgAAAEBlc2NhbGF0aW5nIGVycm9yIHRvIFZNIHRyYXAgZnJvbSBmYWlsZWQgaG9zdCBmdW5jdGlvbiBjYWxsOiBjYWxs"
2023-10-09T08:42:34.279557Z ERROR soroban_cli::log::diagnostic_event: 5: "AAAAAAAAAAAAAAABZVOfSltKPhdkgbreSXQ4FZrQ3UMK4sFIlI5jxdm9aSMAAAACAAAAAAAAAAEAAAAPAAAAA2xvZwAAAAAQAAAAAQAAAAMAAAAOAAAAHlZNIGNhbGwgdHJhcHBlZCB3aXRoIEhvc3RFcnJvcgAAAAAADwAAAARpbml0AAAAAgAAAAEAAAAH"
error: transaction simulation failed: host invocation failed
Caused by:
HostError: Error(WasmVm, InternalError)
Event log (newest first):
0: [Diagnostic Event] contract:65539f4a5b4a3e176481bade497438159ad0dd430ae2c148948e63c5d9bd6923, topics:[error, Error(WasmVm, InternalError)], data:"escalating error to VM trap from failed host function call: call"
1: [Diagnostic Event] contract:65539f4a5b4a3e176481bade497438159ad0dd430ae2c148948e63c5d9bd6923, topics:[error, Error(WasmVm, InternalError)], data:["contract call failed", init, [Address(Contract(65539f4a5b4a3e176481bade497438159ad0dd430ae2c148948e63c5d9bd6923)), 3600, 5000, 340282366920938463463374607431768211455, true]]
2: [Failed Diagnostic Event (not emitted)] contract:444555983ff30f4f9b67a1b27649503e0d4975cbcd63d06f8a17b6d777c69244, topics:[error, Error(WasmVm, InternalError)], data:["VM call failed: Func(MismatchingParameterLen)", init]
3: [Diagnostic Event] contract:65539f4a5b4a3e176481bade497438159ad0dd430ae2c148948e63c5d9bd6923, topics:[fn_call, Bytes(444555983ff30f4f9b67a1b27649503e0d4975cbcd63d06f8a17b6d777c69244), init], data:[Address(Contract(65539f4a5b4a3e176481bade497438159ad0dd430ae2c148948e63c5d9bd6923)), 3600, 5000, 340282366920938463463374607431768211455, true]
4: [Diagnostic Event] topics:[fn_call, Bytes(65539f4a5b4a3e176481bade497438159ad0dd430ae2c148948e63c5d9bd6923), init], data:[Address(Account(19062b22ff0fb72ecf9309b8f4467ba6de275a73d967f689ba8c2c1caea34e2c)), Address(Contract(7dc1ecdf9335199fc9918dbe0c732ce1d1146aa8f29cc9c360afc6a747ae94df)), 3600, 5000, Bytes(00000000000000000000000000000000000000000000000000000000000000ef)]
Backtrace (newest first):
0: soroban_wasmi::engine::EngineExecutor::execute_wasm_func
1: soroban_wasmi::engine::EngineInner::execute_func
2: soroban_wasmi::func::Func::call
3: soroban_env_host::vm::Vm::invoke_function_raw
4: soroban_env_host::host::frame::<impl soroban_env_host::host::Host>::with_frame
5: soroban_env_host::host::frame::<impl soroban_env_host::host::Host>::call_n_internal
6: soroban_env_host::host::frame::<impl soroban_env_host::host::Host>::invoke_function
7: preflight::preflight::preflight_invoke_hf_op
8: preflight::preflight_invoke_hf_op::{{closure}}
9: core::ops::function::FnOnce::call_once{{vtable.shim}}
10: preflight::catch_preflight_panic
11: _cgo_0b49d6ed4a0b_Cfunc_preflight_invoke_hf_op
at tmp/go-build/cgo-gcc-prolog:103:11
12: runtime.asmcgocall
at ./runtime/asm_amd64.s:848
[cargo-make] ERROR - Error while executing command, exit code: 1
[cargo-make] WARN - Build Failed. |
Hello @mariopil , in tried to replicate this error by executing: $ cargo make run_test At least three times, but without problems. Could it be a Maybe its a matter of having the voting contract outdated (the resulting wasm file) . Could you try again with: $ cargo clean
$ soroban contract build --package voting
$ soroban contract build --package governance
$ cargo make run_test Sometimes happened to me i did not update the voting contract compilation, on which depends the governance one. |
Hmm, after cleaning everything and rebuilding it works now... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few notes.
pub fn init( | ||
env: Env, | ||
admin: Address, | ||
voting_period_secs: u64, | ||
target_approval_rate_bps: u32, | ||
total_voters: u32, | ||
participation: u128, | ||
admin_mode: bool, | ||
) { | ||
let storage = env.storage().persistent(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you suggested we use:
if storage
.get::<_, ()>(&DataKey::AlreadyInitialized)
.is_some()
instead of
if storage
.get::<_, bool>(&DataKey::AlreadyInitialized)
.is_some()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed at f191d32
proposer: Address, | ||
id: u64, | ||
payload: ProposalPayload, | ||
) -> Result<(), Error> { | ||
let storage = env.storage().persistent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check initialization?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed at 3182bee
Referenced issue
Closes #36
Summary of changes
voting
contract.Reviewer recommendations
Currenttly this is a WIP, reviewers can check the stream of commits as they go.
The author will try to commit small and early.
EDIT - A initial POC was reached. Reviewer is ecouraged to:
governance
contracts are prefixed with[GC]
governance
contracts are prefixed with[VC]