eos icon indicating copy to clipboard operation
eos copied to clipboard

In packed transaction, "expiration" 's output != input, I think timezone is considered in, is my understanding correct?

Open readygo586 opened this issue 8 years ago • 5 comments

I signed a transaction whose expiration is 2018-09-18T14:21:44@UTC time, after packed,I notice the bytestream is f809a15b, which indicates 2018-09-18T22:21:44@Beijing Time(UTC + 8).

I think the time zone is consider in the packed transaction, is it correct? If yes, I think it is confusing and suggest use UTC time for consistency.

sign transaction image

after packed image

readygo586 avatar Sep 18 '18 15:09 readygo586

2018-09-18T14:21:44@UTC is identical to 2018-09-18T22:21:44@Beijing Time(UTC + 8). Hour 14 UTC is hour 22 CST (UTC +8).

jgiszczak avatar Sep 18 '18 23:09 jgiszczak

@jgiszczak So my question is will the mainnet automatically detect the timezone info in packed_trx? How?

readygo586 avatar Sep 19 '18 00:09 readygo586

@jgiszczak Supposed 2 people named “Alice” and "Bob", Alice is in Beijing, and Bob in Roma. At the same moment, they each want transfer 1 EOS to Linda, in the packed_trxs, the expiration time are different, will the mainnet think both transaction happen the same time? or mainnet will not check the pack_trx data?

readygo586 avatar Sep 19 '18 00:09 readygo586

If using cleos to compose the transactions, the expiration times will not be different. Within the system, all timestamps are UTC. The transactions do not happen at the same time. If they both reach a producing node on time, they are processed sequentially. nodeos is not multithreaded. Mainnet will process the packed transaction data, validating all parts of it before completing the transaction. If either or both transactions do not reach a producer before their expiration, they will be dropped. This may happen at the same time, as the two transactions are likely taking independent paths through the network and will be dropped by different nodes.

Note that the expiration time is set by the -x parameter to cleos as an offset from current time. If Alice chooses -x 60 and Bob chooses -x 65, the transactions will expire at different times.

If the clock of the system running cleos is wrong, it's possible for cleos to never generate a valid transaction. If the system clock is 30 seconds in the past, by default every transaction generated from that system will be expired the second it is submitted. If the environment running cleos has a bad timezone set for its clock, the same problem can occur, depending on the time direction of the error. cleos uses local system time when composing the transaction, and depends on both the clock and the timezone to be accurate in order to successfully compute the UTC time it will use when submitting the transaction. If either or both are wrong, cleos will be unable to compose a valid transaction.

Third party software is subject to the same restrictions. Transactions must be submitted with valid UTC timestamps. The local system must have a correct clock, a correct timezone setting, and correct software to successfully retrieve and compute a UTC timestamp.

jgiszczak avatar Sep 20 '18 20:09 jgiszczak

@jgiszczak I suggest you can parse the first uint32 in packed_trx, the following is the python code to check, suggest to run to check the difference

import datetime time_str1= "2018-09-18T14:21:44" timestamp2 = 0x5ba109f8 //big-endian dt = datetime.datetime.fromtimestamp(timestamp2) time_str2 = dt.isoformat(timespec ="milliseconds") print("time_str1 is {}".format(time_str1)) print("time_str2 is {}".format(time_str2))

readygo586 avatar Sep 21 '18 00:09 readygo586