How are cosmic rays blocked?
Cosmic rays are blocked by certain materials if thick enough.
Cosmic rays are high energy atomic nuclei. A major component which is also the most hazardous are high energy protons.
Various materials can be used to block cosmic rays. Liquid water is quite effective. The Earth's atmosphere blocks most cosmic rays.
Curiously metal layers can actually make the radiation from cosmic rays worse. When a high energy protons collide with metal nuclei they can be transformed into unstable isotopes which then undergo radioactive decay.
Research has been done as to how to protect astronauts on a Mars mission from cosmic rays. There would have to be material between to metal hull and the astronauts to protect them. Water and even human waste have been considered as options.
Other options for blocking protons are magnetic fields or giving the spacecraft a positive electric charge. The problem with these is the power required.