Questions tagged [memory]

Questions related to memory use in Solidity or by nodes

Filter by
Sorted by
Tagged with
4
votes
2answers
446 views

How to pop from (decrease the length of) a memory array in Solidity

I have a function that gets an address array from another contract, conditionally deletes the msg.sender from the array, then saves the new array back to that contract. Because the array backerList ...
2
votes
1answer
285 views

Always use “memory” for variables created within functions. Bad practice?

Is it bad practice to systematically use the memory keyword for variables declared within a function (other than constructor)?
1
vote
1answer
170 views

Compare memory pointers in Solidity

Is there a way to compare pointers in Solidity? I have two local variables: uint256[] memory a = new uint256[](256); uint256[] memory b = a; If I try a == b I get this compiler error: TypeError: ...
6
votes
2answers
7k views

The difference between contract address and wallet address

Disclaimer: this is a rather long question. To my understanding, contract address and wallet address are two profoundly different concepts, with the only thing in common being the fact that they are ...
0
votes
1answer
287 views

Why do arrays declared within functions reference storage point 0 by default?

According to the Solidity Documentation, for the following code, ". . . the compiler interprets x as a storage pointer and will make it point to the storage slot 0 by default. This has the effect ...
0
votes
1answer
158 views

how to replace an array in a mapping?

I'm learning solidity right now and making a dApp where users get paid to perform actions. Actions are paid based on certain criteria. Since I can't schedule a cron job on ethereum, I can only pay ...
1
vote
2answers
1k views

Why cryptokitties uses storage instead of memory?

There are a lot of explainations of storage and memory out there like this question or this question. But I'm wondering why cryptokitties for example uses storage instead of memory in many functions. ...
0
votes
1answer
157 views

Solidity memory pointer

Is there any way I can use a local parameter within multiple functions? The idea is to save gas when calling functions. A parameter wouldn't have to be copied and be returned every time. Here's some ...
1
vote
1answer
6k views

GPU'S Failed cannot create DAG

Last night everything is fine and then this morning I check my mining its's closed I think it was restarted or close accidentally then when I open my pool I have this error. ETH: 5 pools are ...
1
vote
3answers
367 views

value types(uint, bool, etc) as local variable is set to memory initially?

According to this answer, it says simpler variables like bool, uint, et cetera are not variable in length, and are therefore defaulted to memory, whereas this one mentions uint256 v; is default to ...
3
votes
0answers
162 views

Quorum failure - Failed to decode message from payload

We use in our project -JP Morgan Quorum (Ethereum based) bloackchain - with istanbul voting mode. We have 4 nodes (3 of them are validators - hard coded, nonchangable) And from time to time (...
7
votes
2answers
4k views

How to fill dynamic in-memory array

For some reason solidity doesn't allow to push values into memory array Member "push" is not available in bytes32[] memory outside of storage. Here is sample contract code: pragma solidity ^0.4....
1
vote
0answers
45 views

Solidity VM memory management

I'm trying to do an external function call in assembly. So I have to prepare a memory area that store the input args. But where's the address that I should start with mstore? I mean, there are some ...
0
votes
1answer
526 views

I got “ TypeError: Storage location can only ..”

Here is my sample contract code, but I got an error, TypeError: Storage location can only be given for array or struct types. I just wannted to define some element of a structure in a function, ...
2
votes
1answer
237 views

Can marking object as 'memory' before pushing in Array save gas?

We have a struct: struct structEx { uint num; } And an array: structEx[] arr; Have a look at this code snippet, which just instantiates the struct and push: function f() public { structEx s =...
2
votes
1answer
704 views

Delete an entry in a mapping

To my understanding, delete x merely sets the value of x to the default value defined for the type of x (which is typically 0 in one way or another). For example: uint x = 1; delete x; // sets x = 0 ...
1
vote
0answers
27 views

How load out data from blockchain when it occupies too much space?

If the blockchain working long enough it fills the memory of the mining device, how to load out the data and then rerun the system? and why does my mining device has different miner address every time ...
4
votes
3answers
369 views

convert bytes to uint8[8] using mstore()

I know how to convert bytes to uint8[8] using mload but mstore seemed like it could be more gas efficient. Is something like this possible? function bytesToUintArray(bytes input) returns (uint8[8])) ...
3
votes
1answer
87 views

Are balances of all accounts in memory or disk (storage)?

I simulated two contracts that sending balance to another and simply setting value of a variable(var a = 5;). In contrast my expectation, {var a = 5;} contract consumed more gas than the other. In my ...
2
votes
1answer
93 views

Examples of functions limitations?

I coded different functions and didn't find a standard that define crystal clear how many variables you can use (fields, local or as parameters of modifiers inside this function? Do you know a ...
1
vote
1answer
7k views

Type error: memory is not implicitly convertible to expected type

I have a function that returns a list of BetProposition smart contracts: function getBetsForMatchup(uint matchupIdentifier) public returns (BetProposition[]) { return bets[matchupIdentifier]; ...
1
vote
2answers
1k views

Convert 'bytes memory' to 'bytes8'

In solidity, how can I convert bytes memory buffer to bytes8 type? Example: bytes8 buf2 = bytes8(memory_buf); // TypeError: Explicit type conversion not allowed
1
vote
1answer
2k views

Memory usage and limits for go-ethereum

geth (and swarm) seem to require a lot of memory, and there are also reports that they tend to an all you can eat approach to system limits. 1) What are the actual memory requirements for geth? 2) ...
5
votes
2answers
633 views

Stack too deep | Use memory array to store many “local” variables?

I have a contract that's doing a fairly complex calculation with some intermediate calculations, and I'm running into the "stack too deep" problem. I've tried to use a memory array within the ...
1
vote
2answers
69 views

Function that adds struct to an array in the blockchain does not execute when called by another function

I have a problem that's probably very basic, but I cannot seem to figure the issue out function _CreateBike(uint id, uint generation, string model, string ability, uint8 tier) internal returns(Bike){ ...
1
vote
2answers
373 views

Is the EVM memory model a word array or byte array?

The yellow paper says that the memory model for the EVM is a word-addressed byte array (YP 9.1), but when I run debug.traceTransaction in Geth, the memory looks more like an array of words, maybe a ...
0
votes
1answer
1k views

string memory[3] memory is not implicitly convertible to expected type bytes32[] storage ref

I have the following (array of bytes32 types): bytes32[] public allTokenSymbols = ["0x4554480000000000000000000000000000000000000000000000000000000000", "...
1
vote
0answers
268 views

For what data does Ethereum use Memory Database, and for what does it use Level Database

Ethereum uses two databases Memory database and Level Database. Is data stored in MemoryDatabase different than LevelDb? In what cases is one database used over other? The question is different from -...
0
votes
1answer
112 views

Writing to contract struct via function parameter, memory vs storage, “memory outside of storage”

This is my first contract ever (building on an own example learning case I made up). Given this Contract (simplified): unit gEval = 0; contract Group { struct Grp { string name; uint ...
2
votes
0answers
75 views

Is it possible for a mapping to run out of space?

Can storage mappings in a contract run out of space? Say that mapping was keyed to an address and the value as the following struct: User bytes32 name uint8 age Theoretically, if there was a ...
1
vote
2answers
269 views

If we create a ERC20 compliant token, how do we optimize address-balance mapping storage if we have a large user base?

I assume that the address-balance mapping array in ERC20 is considered as a storage variable. So say if 1 million users start to use token A, then there would be 1 million entries in the balance ...
1
vote
1answer
2k views

Hidden problems in “set array to empty array to clear it” approach

I needed a way to clear a storage array in my contract. I've seen this answer, but I tried to think of different approach (My arrays are most probably will contain enormous amount of elements) and ...
8
votes
2answers
7k views

How to initialize an empty array inside a struct?

Is there a mistake in the way I initialize Bar b in the function foobar? contract Foo { struct Bar { address owner; uint[] x; } Bar[] public bars; function foobar(...
1
vote
2answers
572 views

Examples to clarify Storage vs Memory assignments / return parameters

Is there a mistake in funcB? I do not understand why/when to mention the variable name of the return parameter in the function signature. contract Foo { // State variables go to Storage uint[...
1
vote
1answer
872 views

Is there a maximum size for arrays in Solidity?

In my solidity code I define 3 arrays with around 700 elements inside. However, when I try to deploy the contract using Geth I am having the following error message: Error: oversized data undefined ...
4
votes
2answers
2k views

Assigning memory variable to storage variable, what happens?

I'm curious what happens if you try to do the next thing: contract C { Struct S { uint a; uint b; } mapping(address => s) structs; function updateStructs(S ...
2
votes
1answer
55 views

Is memory logged in a transaction?

Data in memory during a transaction is deleted when execution stops. This means this information is not stored in the contract state, but is the information that was in memory during the transaction ...
2
votes
1answer
117 views

Why is the cost of memory non-linear, while the cost of storage is linear?

Why is the cost of memory non-linear, while the cost of storage is linear? I wonder why the cost function of memory vs. storage differ? While storage is associated with a constant cost, this is not ...
6
votes
1answer
347 views

How does dynamic array memory reallocating work?

Let's say I have a dynamic array of some length and I want to push a new element, but memory after last elem is already used. What would happen in such case? Compiler would find a new 'chunk' of ...
1
vote
1answer
197 views

Where does mapping store a variable if an address is already used?

I know that mapping use addresses, based on a hash of key + position of mapping storage variable keccak256(bytes32(variable_address) + bytes32(key)) And I want to know where variable would be stored ...
3
votes
1answer
415 views

Why does PUSH1 0x60 PUSH1 x40 MSTORE store 0x60 at memory location 0x50 (and not 0x40)?

According to browser solidity, after executing 000 PUSH1 60 002 PUSH1 40 004 MSTORE Memory is: 0x00: 00000000000000000000000000000000 ???????????????? 0x10: 00000000000000000000000000000000 ?????...
4
votes
1answer
863 views

Assigning an array creates a pointer or copies an array? (Solidity)

Here is the code: pragma solidity^0.4.16; contract Test { struct SomeData { address[] users; } address[] nullArray; mapping(uint => SomeData) SomeDataList; function ...
3
votes
1answer
2k views

Restrict CPU/memory usage of geth while syncing

I'm trying to run a geth node and a bitcoin core node on one server. I started with a DigitalOcean droplet with 2 CPU and 2GB memory, but both the geth and bitcoin node would run out of memory. I ...
5
votes
3answers
331 views

Why memory arrays are unresizable?

I don't know the required length of my array before execution of the function.. why technically can't I resize my memory array? What is the common way to go around of this problem, if you are also ...
2
votes
2answers
893 views

Is it possible to copy the internal storage of a smart contract to a new contract?

Assume that I want to implement my own version of a suicide contract function with extended functionality. More specifically, I want to copy the internal storage state of the contract to a new ...
2
votes
0answers
78 views

Assembly operations throw warnings during compiling

Leveraging the following common string utility has been quite helpful, but would like to get rid of a warning: function stringToBytes32(string memory source) returns (bytes32 result) { assembly ...
2
votes
2answers
454 views

How much memory do I need to mine any blocks on my lockal network?

I have linux box with 5Gb of memory: osboxes@osboxes ~/node1 $ free total used free shared buff/cache available Mem: 5176876 158360 3536464 ...
3
votes
1answer
750 views

Can I reduce the space chaindata takes up?

So the size of my chaindata folder has snowballed to close to 80GB. Is there a way to reduce it or is the only way to delete it and resync geth with --syncmode fast? Thanks!
26
votes
6answers
8k views

How to store IPFS hash using bytes32?

Following Q/A (What datatype should I use for an IPFS address hash?) recommend us to use bytes to store IPFS hash. I was using following example(https://github.com/AdrianClv/ethereum-ipfs/blob/master/...
1
vote
0answers
559 views

Extreme memory consumption by geth

I'm using geth's traceTransaction() API to index certain opcodes that are used in transactions. When I request traces from some transactions (e.g. ...