Translate c++ function into python: sha256 hash mismatch

This is not related to bitcoin but it uses most of the bitcoin codebase. I would like to translate some c++ code into python but struggle really hard to get the hashes right.

This is the function I try go get. Hash is doing a double sha256

uint256 CalcKernelHash(const uint256& stakeModifier, int64_t height, int64_t coinstakeTime, const uint256& masternodeID, const Consensus::Params& params) {
        // Calculate hash
        CDataStream ss(SER_GETHASH, 0);
        ss << stakeModifier << coinstakeTime << GetMnCollateralAmount(int(height)) << masternodeID;
        std::cout << "n--------------------------------n";
        std::cout << "DEBUG(" << coinstakeTime << ") collateral: " << GetMnCollateralAmount(int(height)) << "n";
        std::cout << "DEBUG(" << coinstakeTime << ") ss: " << stakeModifier.ToString() << coinstakeTime << GetMnCollateralAmount(int(height)) << masternodeID.ToString() << "n";
        std::cout << "DEBUG(" << coinstakeTime << ") HASH: " << Hash(ss.begin(), ss.end()).ToString() << "n";
        return Hash(ss.begin(), ss.end());
    }

And here it is called

const auto hashProofOfStake = UintToArith256(CalcKernelHash(stakeModifier, height, coinstakeTime, masternodeID, params));
    
std::cout << "DEBUG(" << coinstakeTime << ") coinstakeTime: " << coinstakeTime << "n";
std::cout << "DEBUG(" << coinstakeTime << ") nbits: " << nBits << "n";
std::cout << "DEBUG(" << coinstakeTime << ") hashProofOfStake: " << hashProofOfStake.ToString() << "n";
std::cout << "DEBUG(" << coinstakeTime << ") stakeModifier: " << stakeModifier.ToString() << "n";
std::cout << "DEBUG(" << coinstakeTime << ") masternodeId: " << masternodeID.ToString() << "n";

I have added some debug statement to check the output and have a reference

--------------------------------
DEBUG(1622528110) collateral: 2000000000000
DEBUG(1622528110) ss: f541f372005beeb8952f964ea638527341c3b3a6eebb0c0309e4f092bd6c1b0e16225281102000000000000e2cfe3f576da4999ea2268224f34efdd3b0d567841d561b41b3ab67976c977d1
DEBUG(1622528110) HASH: e4b0d1b01a99d00e44d41eeb37c81d19940bf71270994fff53ea5caa1c79f663
DEBUG(1622528110) coinstakeTime: 1622528110
DEBUG(1622528110) nbits: 419654358
DEBUG(1622528110) hashProofOfStake: e4b0d1b01a99d00e44d41eeb37c81d19940bf71270994fff53ea5caa1c79f663
DEBUG(1622528110) stakeModifier: f541f372005beeb8952f964ea638527341c3b3a6eebb0c0309e4f092bd6c1b0e
DEBUG(1622528110) masternodeId: e2cfe3f576da4999ea2268224f34efdd3b0d567841d561b41b3ab67976c977d1

This is my trial in python

def rotate(x):
    s2 = bytearray.fromhex(x)
    s2.reverse()
    return binascii.hexlify(s2).decode()

def padhexa(s):
    return s(2:).zfill(16)

def CalcKernelHash(stakeModifier, coinstakeTime, masternodeId):
    stakeModifier = binascii.unhexlify(stakeModifier)
    coinstakeTime = binascii.unhexlify("%x" % coinstakeTime)
    collateral = binascii.unhexlify("0%x" % 2000000000000)
    masternodeId = binascii.unhexlify(masternodeId)
    
    bin_s = stakeModifier(::-1) + coinstakeTime(::-1) + collateral(::-1) + masternodeId(::1)
    return rotate(hashlib.sha256(hashlib.sha256(bin_s).digest()).hexdigest())

When I execute with the parameter from the debug output I get

CalcKernelHash('f541f372005beeb8952f964ea638527341c3b3a6eebb0c0309e4f092bd6c1b0e', 1622528110, 'e2cfe3f576da4999ea2268224f34efdd3b0d567841d561b41b3ab67976c977d1')

'f01ba34ac7a897a1e37d61bac3a8ea6f0126c2ae883a2d75dab1f407d40aad0b'

Where I should get hashProofOfStake e4b0d1b01a99d00e44d41eeb37c81d19940bf71270994fff53ea5caa1c79f663

EDIT:

bin_s returns b'x0ex1blxbdx92xf0xe4tx03x0cxbbxeexa6xb3xc3AsR8xa6Nx96/x95xb8xee(x00rxf3Axf5nxd0xb5`x00 Jxa9xd1x01xe2xcfxe3xf5vxdaIx99xea"h"O4xefxdd;rVxAxd5axb4x1b:xb6yvxc9wxd1'