Does ethereum geth compress old blocks in blockchain ? Why I ask it: I saw that my blockchain has size on Disk around 40Gb, but once it down to 20Gb.
There are three types of syncronization:
Full Sync: Gets the block headers, the block bodies, and validates every element from genesis block.
Fast Sync: Gets the block headers, the block bodies, it processes no transactions until current block - 1024. Then it gets a snapshot state and goes like a full synchronization.
Light Sync: Gets only the current state. To verify elements, it needs to ask to full (archive) nodes for the corresponding tree leaves.
So answerring your question,
Does ethereum geth compress old blocks in blockchain ?
in light and fast sync the answer is yes. But not literally compress. It just takes part of blocks (e.g. the block headers, the block bodies, the current state).
Why I ask it: I saw that my blockchain has size on Disk around 40Gb, but once it down to 20Gb.
I have no idea how to describe this event, but this shouldn't be possible, because the blockchain is growing monthly and even in light and fast sync modes it won't drop like this without any major changes in blockchain. (I can assume this scenario can possibly happen not in mainnet).
Short definitions from this answer.
In addition to the other answer...
The state data is stored as a set of LevelDB files, which is itself already compressed using Google's Snappy compression algorithm. Trying to compress this again wouldn't save you any more space.
(So the answer is 'no', as Roman said in his explanations about pruning.)