Skip to content

Commit d7f5d2b

Browse files
authored
New host functions and delegations (#46)
* Delegating and rewards. * More host functions in testing
1 parent 4071acb commit d7f5d2b

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

docusaurus/docs/advanced/08-delegating-cspr.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,30 @@ specific to the network or backend.
124124

125125
We used `currently_delegated_amount` in the example, it uses `delegated_amount` method from ContractEnv, but it is also
126126
possible to query this information from the HostEnv using `delegated_amount` method.
127+
128+
## Implementation details
129+
130+
To keep the parity of behaviour between Odra VM and Casper VM,
131+
we implemented some not-so-obvious behaviours and parameters that
132+
can influence your code.
133+
134+
### Minimum delegation amount
135+
136+
Each validator can define the minimum delegation amount. Delegator
137+
cannot delegate a smaller amount but can increase the delegation
138+
in smaller steps.
139+
140+
If the delegation amount falls below it, all the delegated
141+
funds will be undelegated.
142+
143+
By default, the Odra VM and Casper VM are booted up with
144+
5 validators, each with `MINIMUM_DELEGATION_AMOUNT` set to
145+
500 CSPR.
146+
147+
### Rewards calculation
148+
149+
As mentioned above, VMs are started with 5 validators, each
150+
is delegating `DEFAULT_BID_AMOUNT`, which is set to `5_000_000_000_000_000_000u64` (5 000 000 000 CSPR).
151+
152+
At each auction `DEFAULT_REWARD_AMOUNT` (2500 CSPR) is divided equally between
153+
all validators and delegators based on their share in the pool.

docusaurus/docs/basics/07-testing.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ the function we are calling inside the contract.
121121

122122
- `fn set_caller(&self, address: Address)` - you've seen it in action just now
123123
- `fn balance_of<T: Addressable>(&self, addr: &T) -> U512` - returns the balance of the account associated with the given address
124-
- `fn advance_block_time(&self, time_diff: u64)` - increases the current value of `block_time`
124+
- `fn block_time(&self) -> u64` - returns the current value of `block_time` in milliseconds, alias: `block_time_millis`
125+
- `fn block_time_secs(&self) -> u64` - retuns the current value of `block_time` in seconds
126+
- `fn advance_block_time(&self, time_diff: u64)` - increases the current value of `block_time` by `time_diff` in milliseconds
125127
- `fn get_account(&self, n: usize) -> Address` - returns an n-th address that was prepared for you by Odra in advance;
126128
by default, you start with the 0-th account
127129
- `fn emitted_event<T: ToBytes + EventInstance, R: Addressable>(&self, contract_address: &R, event: T) -> bool` - verifies if the event was emitted by the contract

0 commit comments

Comments
 (0)