コード例 #1
0
        public FaucetResponse Decode(RlpStream rlpStream,
                                     RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            FaucetRequestStatus  status  = (FaucetRequestStatus)rlpStream.DecodeInt();
            FaucetRequestDetails request = Serialization.Rlp.Rlp.Decode <FaucetRequestDetails>(rlpStream);

            return(new FaucetResponse(status, request));
        }
コード例 #2
0
        public static GetReceiptsMessage Deserialize(RlpStream rlpStream)
        {
            GetReceiptsMessage getReceiptsMessage = new GetReceiptsMessage();

            rlpStream.ReadSequenceLength();
            getReceiptsMessage.RequestId  = rlpStream.DecodeLong();
            getReceiptsMessage.EthMessage = Eth.V63.GetReceiptsMessageSerializer.Deserialize(rlpStream);
            return(getReceiptsMessage);
        }
コード例 #3
0
        public DataDeliveryReceiptToMerge Decode(RlpStream rlpStream,
                                                 RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            UnitsRange unitsRange = Serialization.Rlp.Rlp.Decode <UnitsRange>(rlpStream);
            Signature  signature  = SignatureDecoder.DecodeSignature(rlpStream);

            return(new DataDeliveryReceiptToMerge(unitsRange, signature));
        }
コード例 #4
0
        private static NewBlockMessage Deserialize(RlpStream rlpStream)
        {
            NewBlockMessage message = new NewBlockMessage();

            rlpStream.ReadSequenceLength();
            message.Block           = Rlp.Decode <Block>(rlpStream);
            message.TotalDifficulty = rlpStream.DecodeUInt256();
            return(message);
        }
コード例 #5
0
        public ParityLikeTxTrace Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            ParityLikeTxTrace trace = new ParityLikeTxTrace();

            rlpStream.ReadSequenceLength();
            trace.BlockHash       = rlpStream.DecodeKeccak();
            trace.BlockNumber     = (long)rlpStream.DecodeUInt256();
            trace.TransactionHash = rlpStream.DecodeKeccak();
            Span <byte> txPosBytes = rlpStream.DecodeByteArraySpan();

            trace.TransactionPosition = txPosBytes.Length == 0 ? (int?)null : txPosBytes.ReadEthInt32();
            rlpStream.ReadSequenceLength();
            trace.Action       = DecodeAction(rlpStream);
            trace.StateChanges = DecodeStateDiff(rlpStream);
            // stateChanges

            return(trace);
        }
コード例 #6
0
        private static GetBlockHeadersMessage Deserialize(RlpStream rlpStream)
        {
            GetBlockHeadersMessage getBlockHeadersMessage = new();

            rlpStream.ReadSequenceLength();
            getBlockHeadersMessage.RequestId  = rlpStream.DecodeLong();
            getBlockHeadersMessage.EthMessage = Eth.V62.Messages.GetBlockHeadersMessageSerializer.Deserialize(rlpStream);
            return(getBlockHeadersMessage);
        }
        public DataAssetStateChangedMessage Deserialize(byte[] bytes)
        {
            RlpStream context = bytes.AsRlpStream();

            context.ReadSequenceLength();
            Keccak?        dataAssetId = context.DecodeKeccak();
            DataAssetState state       = (DataAssetState)context.DecodeInt();

            return(new DataAssetStateChangedMessage(dataAssetId, state));
        }
コード例 #8
0
    public PingMsg Deserialize(byte[] msgBytes)
    {
        (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes);
        RlpStream rlp = results.Data.AsRlpStream();

        rlp.ReadSequenceLength();
        int version = rlp.DecodeInt();

        rlp.ReadSequenceLength();
        ReadOnlySpan <byte> sourceAddress = rlp.DecodeByteArraySpan();

        // TODO: please note that we decode only one field for port and if the UDP is different from TCP then
        // our discovery messages will not be routed correctly (the fix will not be part of this commit)
        rlp.DecodeInt();               // UDP port
        int tcpPort = rlp.DecodeInt(); // we assume here that UDP and TCP port are same

        IPEndPoint source = GetAddress(sourceAddress, tcpPort);

        rlp.ReadSequenceLength();
        ReadOnlySpan <byte> destinationAddress = rlp.DecodeByteArraySpan();
        IPEndPoint          destination        = GetAddress(destinationAddress, rlp.DecodeInt());

        rlp.DecodeInt(); // UDP port

        long    expireTime = rlp.DecodeLong();
        PingMsg msg        = new(results.FarPublicKey, expireTime, source, destination, results.Mdc);

        msg.Version = version;
        if (version == 4)
        {
            if (!rlp.HasBeenRead)
            {
                long enrSequence = rlp.DecodeLong();
                msg.EnrSequence = enrSequence;
            }
        }
        else
        {
            // what do we do when receive version 5?
        }

        return(msg);
    }
コード例 #9
0
        public static ContractCodesMessage Deserialize(RlpStream rlpStream)
        {
            ContractCodesMessage contractCodesMessage = new ContractCodesMessage();

            rlpStream.ReadSequenceLength();
            contractCodesMessage.RequestId   = rlpStream.DecodeLong();
            contractCodesMessage.BufferValue = rlpStream.DecodeInt();
            contractCodesMessage.Codes       = rlpStream.DecodeArray(stream => stream.DecodeByteArray());
            return(contractCodesMessage);
        }
コード例 #10
0
        public DataStreamDisabledMessage Deserialize(byte[] bytes)
        {
            RlpStream context = bytes.AsRlpStream();

            context.ReadSequenceLength();
            Keccak?depositId = context.DecodeKeccak();
            string client    = context.DecodeString();

            return(new DataStreamDisabledMessage(depositId, client));
        }
コード例 #11
0
        private static BlockBodiesMessage Deserialize(RlpStream rlpStream)
        {
            BlockBodiesMessage blockBodiesMessage = new BlockBodiesMessage();

            rlpStream.ReadSequenceLength();
            blockBodiesMessage.RequestId   = rlpStream.DecodeLong();
            blockBodiesMessage.BufferValue = rlpStream.DecodeInt();
            blockBodiesMessage.EthMessage  = Eth.V62.BlockBodiesMessageSerializer.Deserialize(rlpStream);
            return(blockBodiesMessage);
        }
コード例 #12
0
        public AckEip8Message Deserialize(byte[] bytes)
        {
            RlpStream      rlpStream       = bytes.AsRlpStream();
            AckEip8Message authEip8Message = new AckEip8Message();

            rlpStream.ReadSequenceLength();
            authEip8Message.EphemeralPublicKey = new PublicKey(rlpStream.DecodeByteArray());
            authEip8Message.Nonce = rlpStream.DecodeByteArray();
            return(authEip8Message);
        }
コード例 #13
0
        public DataAvailabilityMessage Deserialize(byte[] bytes)
        {
            RlpStream context = bytes.AsRlpStream();

            context.ReadSequenceLength();
            Keccak?          depositId = context.DecodeKeccak();
            DataAvailability reason    = (DataAvailability)context.DecodeInt();

            return(new DataAvailabilityMessage(depositId, reason));
        }
コード例 #14
0
        public AddCapabilityMessage Deserialize(byte[] msgBytes)
        {
            RlpStream context = msgBytes.AsRlpStream();

            context.ReadSequenceLength();
            string protocolCode = context.DecodeString();
            byte   version      = context.DecodeByte();

            return(new AddCapabilityMessage(new Capability(protocolCode, version)));
        }
コード例 #15
0
        public RequestDepositApprovalMessage Deserialize(byte[] bytes)
        {
            RlpStream context = bytes.AsRlpStream();

            context.ReadSequenceLength();
            Keccak? dataAssetId = context.DecodeKeccak();
            Address?consumer    = context.DecodeAddress();
            string  kyc         = context.DecodeString();

            return(new RequestDepositApprovalMessage(dataAssetId, consumer, kyc));
        }
コード例 #16
0
    public PongMsg Deserialize(byte[] msgBytes)
    {
        (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes);

        RlpStream rlp = results.Data.AsRlpStream();

        rlp.ReadSequenceLength();
        rlp.ReadSequenceLength();

        // GetAddress(rlp.DecodeByteArray(), rlp.DecodeInt());
        rlp.DecodeByteArraySpan();
        rlp.DecodeInt(); // UDP port (we ignore and take it from Netty)
        rlp.DecodeInt(); // TCP port
        byte[] token          = rlp.DecodeByteArray();
        long   expirationTime = rlp.DecodeLong();

        PongMsg msg = new(results.FarPublicKey, expirationTime, token);

        return(msg);
    }
コード例 #17
0
        public Consumer Decode(RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            _ = rlpStream.ReadSequenceLength();
            var depositId             = rlpStream.DecodeKeccak();
            var verificationTimestamp = rlpStream.DecodeUInt();
            var dataRequest           = Nethermind.Serialization.Rlp.Rlp.Decode <DataRequest>(rlpStream);
            var dataAsset             = Nethermind.Serialization.Rlp.Rlp.Decode <DataAsset>(rlpStream);
            var hasAvailableUnits     = rlpStream.DecodeBool();

            return(new Consumer(depositId, verificationTimestamp, dataRequest, dataAsset, hasAvailableUnits));
        }
コード例 #18
0
        private ParityAccountStateChange DecodeAccountStateChange(RlpStream rlpStream)
        {
            rlpStream.ReadSequenceLength();
            ParityAccountStateChange change = new ParityAccountStateChange();

            change.Balance = DecodeChange(rlpStream);
            change.Code    = DecodeByteChange(rlpStream);
            change.Nonce   = DecodeChange(rlpStream);
            change.Storage = DecodeStorageChange(rlpStream);
            return(change);
        }
コード例 #19
0
        public Deposit Decode(RlpStream rlpStream,
                              RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            Keccak  id         = rlpStream.DecodeKeccak();
            uint    units      = rlpStream.DecodeUInt();
            uint    expiryTime = rlpStream.DecodeUInt();
            UInt256 value      = rlpStream.DecodeUInt256();

            return(new Deposit(id, units, expiryTime, value));
        }
コード例 #20
0
        private PathWithStorageSlot DecodeSlot(RlpStream stream)
        {
            stream.ReadSequenceLength();
            Keccak path = stream.DecodeKeccak();

            byte[] value = stream.DecodeByteArray();

            PathWithStorageSlot data = new(path, value);

            return(data);
        }
コード例 #21
0
        public DataDeliveryReceiptRequest Decode(RlpStream rlpStream,
                                                 RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            rlpStream.ReadSequenceLength();
            uint       number       = rlpStream.DecodeUInt();
            Keccak     depositId    = rlpStream.DecodeKeccak();
            UnitsRange unitsRange   = Serialization.Rlp.Rlp.Decode <UnitsRange>(rlpStream);
            bool       isSettlement = rlpStream.DecodeBool();
            var        receipts     = Serialization.Rlp.Rlp.DecodeArray <DataDeliveryReceiptToMerge>(rlpStream);

            return(new DataDeliveryReceiptRequest(number, depositId, unitsRange, isSettlement, receipts));
        }
コード例 #22
0
        public ReceiptsMessage Deserialize(RlpStream rlpStream)
        {
            ReceiptsMessage receiptsMessage = new ReceiptsMessage();

            Eth.V63.ReceiptsMessageSerializer ethSerializer = new Eth.V63.ReceiptsMessageSerializer(_specProvider);

            rlpStream.ReadSequenceLength();
            receiptsMessage.RequestId   = rlpStream.DecodeLong();
            receiptsMessage.BufferValue = rlpStream.DecodeInt();
            receiptsMessage.EthMessage  = ethSerializer.Deserialize(rlpStream);
            return(receiptsMessage);
        }
コード例 #23
0
        private static StatusMessage Deserialize(RlpStream rlpStream)
        {
            StatusMessage statusMessage = new StatusMessage();

            rlpStream.ReadSequenceLength();
            statusMessage.ProtocolVersion = rlpStream.DecodeByte();
            statusMessage.ChainId         = rlpStream.DecodeUInt256();
            statusMessage.TotalDifficulty = rlpStream.DecodeUInt256();
            statusMessage.BestHash        = rlpStream.DecodeKeccak();
            statusMessage.GenesisHash     = rlpStream.DecodeKeccak();
            return(statusMessage);
        }
コード例 #24
0
        private static HiMessage Deserialize(RlpStream rlpStream)
        {
            rlpStream.ReadSequenceLength();
            var protocolVersion = rlpStream.DecodeByte();
            var providerAddress = rlpStream.DecodeAddress();
            var consumerAddress = rlpStream.DecodeAddress();
            var nodeId          = new PublicKey(rlpStream.DecodeByteArray());
            var signature       = SignatureDecoder.DecodeSignature(rlpStream);

            return(new HiMessage(protocolVersion, providerAddress, consumerAddress,
                                 nodeId, signature));
        }
コード例 #25
0
        protected override GetByteCodesMessage Deserialize(RlpStream rlpStream)
        {
            GetByteCodesMessage message = new ();

            rlpStream.ReadSequenceLength();

            message.RequestId = rlpStream.DecodeLong();
            message.Hashes    = rlpStream.DecodeArray(_ => rlpStream.DecodeKeccak());
            message.Bytes     = rlpStream.DecodeLong();

            return(message);
        }
コード例 #26
0
        private static StatusMessage Deserialize(RlpStream rlpStream)
        {
            StatusMessage statusMessage = new StatusMessage();

            rlpStream.ReadSequenceLength();
            statusMessage.ProtocolVersion = rlpStream.DecodeByte();
            statusMessage.ChainId         = rlpStream.DecodeUInt256();
            statusMessage.TotalDifficulty = rlpStream.DecodeUInt256();
            statusMessage.BestHash        = rlpStream.DecodeKeccak();
            statusMessage.GenesisHash     = rlpStream.DecodeKeccak();
            if (rlpStream.Position < rlpStream.Length)
            {
                rlpStream.ReadSequenceLength();
                byte[] forkHash = rlpStream.DecodeByteArray();
                long   next     = (long)rlpStream.DecodeUlong();
                ForkId forkId   = new(forkHash, next);
                statusMessage.ForkId = forkId;
            }

            return(statusMessage);
        }
コード例 #27
0
        public static T[] DecodeArray <T>(this IRlpStreamDecoder <T> decoder, RlpStream rlpStream, RlpBehaviors rlpBehaviors = RlpBehaviors.None)
        {
            int checkPosition = rlpStream.ReadSequenceLength() + rlpStream.Position;

            T[] result = new T[rlpStream.ReadNumberOfItemsRemaining(checkPosition)];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = decoder.Decode(rlpStream, rlpBehaviors);
            }

            return(result);
        }
コード例 #28
0
    public EnrRequestMsg Deserialize(byte[] msgBytes)
    {
        (PublicKey FarPublicKey, byte[] Mdc, byte[] Data)results = PrepareForDeserialization(msgBytes);
        RlpStream rlpStream = results.Data.AsRlpStream();

        rlpStream.ReadSequenceLength();
        long expirationTime = rlpStream.DecodeLong();

        EnrRequestMsg msg = new (results.FarPublicKey, expirationTime);

        return(msg);
    }
コード例 #29
0
        protected override GetAccountRangeMessage Deserialize(RlpStream rlpStream)
        {
            GetAccountRangeMessage message = new ();

            rlpStream.ReadSequenceLength();

            message.RequestId     = rlpStream.DecodeLong();
            message.AccountRange  = new(rlpStream.DecodeKeccak(), rlpStream.DecodeKeccak(), rlpStream.DecodeKeccak());
            message.ResponseBytes = rlpStream.DecodeLong();

            return(message);
        }
コード例 #30
0
        public EnableDataStreamMessage Deserialize(byte[] bytes)
        {
            RlpStream context = bytes.AsRlpStream();

            context.ReadSequenceLength();
            Keccak?depositId = context.DecodeKeccak();
            string client    = context.DecodeString();

            string?[] args = context.DecodeArray(c => c.DecodeString());

            return(new EnableDataStreamMessage(depositId, client, args));
        }