I'm having lint check warning in Remix for my smart contract in Solidity: addFeature(int128,uint256,bool,uint256,uint256,uint16,uint16,address) high: infinite. If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)
Feature
is a struct with lot's of fields:
struct Feature {
int128 key;
uint256 goal;
bool finishOnGoal;
uint campaignStart; // timestamp
uint campaignFinish; // timestamp
PledgeType pledgeType; // enum
FixedPledge fixedPledge; // description for enum value #1
VariablePledge variablePledge; // description for enum value #2
PrepaymentType prepaymentType; // enum
FixedPrepayment fixedPrepayment; // description for enum value #1
PercentPrepayment percentPrepayment; // description for enum value #2
uint16 maxDevelopmentDelay; // days
uint16 developmentDuration; // days
ConfirmationType confirmationType; // enum
UserConfirmation userConfirmation; // description for enum value #1
address developer;
}
...
// featureKey => feature
mapping (int128 => Feature) features;
// featureKey => feature
mapping (int128 => FeatureData) data;
...
// common feature data
function addFeature(
int128 key,
uint256 goal,
bool finishOnGoal,
uint campaignStart, // timestamp
uint campaignFinish, // timestamp
uint16 maxDevelopmentDelay,
uint16 developmentDuration,
address developer) public
ownerOnly
withState(key, State.NotSet)
{
Feature memory feature;
feature.key = key;
feature.goal = goal;
feature.finishOnGoal = finishOnGoal;
feature.campaignStart = campaignStart;
feature.campaignFinish = campaignFinish;
feature.maxDevelopmentDelay = maxDevelopmentDelay;
feature.developmentDuration = developmentDuration;
feature.developer = developer;
FeatureData memory featureData;
featureData.state = State.Deployment;
featureData.backers = new address[](0);
featureData.raised = 0;
featureData.prepaid = 0;
features[key] = feature;
data[key] = featureData;
}
Why do i have this warning? What can/should be changed to fix it (without loosing of functionality)? AFAIK there are neither loops nor arrays modifications here (maps only).
FeatureData
in memory is supposed to be copied into storage due to the dynamically-sizedbackers
array. Could you share enough code that it's possible to compile this?