question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sum from mapping of structs?

See original GitHub issue

Is it possible to achieve something like this?

contract Vault {
  struct Account {
    uint256 id;
    uint256 shares;
  }

  mapping(address => Account) accounts;
  uint256 totalShares;

  /// #invariant unchecked_sum(accounts.shares) == totalShares;
  function deposit() {
    /// ...
  }
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
naps62commented, Feb 7, 2022

@GNSPS thanks for the offer (I will hold you up to that 😄 )

It’s both for a production project, and to potentially use in yAcademy which just started I had scribble on my todo list for a few months now, and decided to give it a try these days to see if it could be a better fit than echidna

0reactions
cd1m0commented, Feb 26, 2022

@nettrino you’re correct - it is not currently possible. However could you post a sample of what you would like supported? If there is enough interest in this feature, and if we can figure out a way to implement it thats friendly to underlying tools (fuzzers/sym. exec engines/verifiers for example) then we can consider it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grouping maps/structs by key, and summing the associated ...
go - Grouping maps/structs by key, and summing the associated values for an array - Stack Overflow. Stack Overflow for Teams – Start ......
Read more >
How to sum up values of a struct? - Elixir Forum
I have a struct. s = %S{a: 1, b: 2} and, a list. l = [3, 4] and, I want a fn() to...
Read more >
How to loop through mapping in solidity?
mapping (address => uint) public voterCount;. To calculate the total votes, I would like to loop through the mapping and sum the uint...
Read more >
Solidity Tutorial: all about Mappings | by Jean Cvllr - Medium
This article covers in depth the mapping type in Solidity, how they are represented in a smart contract storage, getters, setters, ...
Read more >
Summing up numeric properties of objects in an array in Swift
This a solution on how to sum up numeric properties of objects within an array. You can test the code with there snippet...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found