Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curly Bracket in a solidity function

I would like to know what curly brackets mean in that case ?

uint64 configCount = s_configCount;
    {
      s_hotVars.latestConfigDigest = configDigestFromConfigData(
        address(this),
        configCount,
        _signers,
        _transmitters,
        _threshold,
        _encodedConfigVersion,
        _encoded
      );
      s_hotVars.latestEpochAndRound = 0;
    }```

Why did they use {} ? why they didn't wrote the code like this :

uint64 configCount = s_configCount;
s_hotVars.latestConfigDigest = configDigestFromConfigData(address(this),configCount,_signers,_transmitters,_threshold,_encodedConfigVersion,_encoded);
s_hotVars.latestEpochAndRound = 0;
like image 730
Quentin Perrot-Minnot Avatar asked Feb 04 '26 11:02

Quentin Perrot-Minnot


1 Answers

Curly braces are for the scoping rules.

They also allocate a new stack frame. Because the small stack is a pain for developers in EVM. Scoping is needed with deep call structures to avoid stack too deep error.

like image 76
Mikko Ohtamaa Avatar answered Feb 06 '26 04:02

Mikko Ohtamaa