{"action":"created","issue":{"url":"https://api.github.com/repos/FactomProject/WorkItems/issues/626","labels_url":"https://api.github.com/repos/FactomProject/WorkItems/issues/626/labels{/name}","comments_url":"https://api.github.com/repos/FactomProject/WorkItems/issues/626/comments","events_url":"https://api.github.com/repos/FactomProject/WorkItems/issues/626/events","html_url":"https://github.com/FactomProject/WorkItems/issues/626","id":100380905,"number":626,"title":"header incorrect when building ledgerKeyMR","user":{"login":"carryforward","id":7833030,"avatar_url":"https://avatars.githubusercontent.com/u/7833030?v=3","gravatar_id":"","url":"https://api.github.com/users/carryforward","html_url":"https://github.com/carryforward","followers_url":"https://api.github.com/users/carryforward/followers","following_url":"https://api.github.com/users/carryforward/following{/other_user}","gists_url":"https://api.github.com/users/carryforward/gists{/gist_id}","starred_url":"https://api.github.com/users/carryforward/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carryforward/subscriptions","organizations_url":"https://api.github.com/users/carryforward/orgs","repos_url":"https://api.github.com/users/carryforward/repos","events_url":"https://api.github.com/users/carryforward/events{/privacy}","received_events_url":"https://api.github.com/users/carryforward/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"PaulSnow","id":95612,"avatar_url":"https://avatars.githubusercontent.com/u/95612?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulSnow","html_url":"https://github.com/PaulSnow","followers_url":"https://api.github.com/users/PaulSnow/followers","following_url":"https://api.github.com/users/PaulSnow/following{/other_user}","gists_url":"https://api.github.com/users/PaulSnow/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulSnow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulSnow/subscriptions","organizations_url":"https://api.github.com/users/PaulSnow/orgs","repos_url":"https://api.github.com/users/PaulSnow/repos","events_url":"https://api.github.com/users/PaulSnow/events{/privacy}","received_events_url":"https://api.github.com/users/PaulSnow/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/FactomProject/WorkItems/milestones/7","html_url":"https://github.com/FactomProject/WorkItems/milestones/Milestone%201:%20Central%20Server%20model","labels_url":"https://api.github.com/repos/FactomProject/WorkItems/milestones/7/labels","id":991670,"number":7,"title":"Milestone 1: Central Server model","description":"FACTOM BETA RELEASE\r\n\r\n[A]. The beta release of the Factom client includes having various subsystems operational. \r\n       (i). Packaging user Entries using Merkle Roots of Entry block structures. \r\n       (ii). Anchoring blocks into the Mainnet Bitcoin blockchain using a single server. \r\n\r\n[B]. The beta release of the Factom client includes the Factoid chain. \r\n      (i). Construct a genesis block from the Factoid software sale designated public keys. \r\n      (ii). Factoids can be reassigned to another address after checking cryptographic signatures.\r\n\r\nOUR TAKE ON THIS:\r\n\r\nIntegrated Factoid chain\r\ncensus building with Central Server model\r\nCLI factoid/EC wallet\r\nCatch up blocks from peers (Directory Block, EC Block, Factoid Block, Entry Block with entries …)\r\nValidate blocks after downloading them from peers\r\nLoad blocks into db, build meta data and cross references to support Factom Explorer\r\nNew work items from Brian\r\nFactom Explorer\r\n  New UI for Factom Explorer\r\n  Download blocks from factomd\r\n  Load blocks into db and build cross references\r\n\r\nFactom CLI and Factom API\r\n  Move entry credit wallet into CLI\r\n  Design and build required factom APIs\r\n","creator":{"login":"JackXLu","id":5152015,"avatar_url":"https://avatars.githubusercontent.com/u/5152015?v=3","gravatar_id":"","url":"https://api.github.com/users/JackXLu","html_url":"https://github.com/JackXLu","followers_url":"https://api.github.com/users/JackXLu/followers","following_url":"https://api.github.com/users/JackXLu/following{/other_user}","gists_url":"https://api.github.com/users/JackXLu/gists{/gist_id}","starred_url":"https://api.github.com/users/JackXLu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackXLu/subscriptions","organizations_url":"https://api.github.com/users/JackXLu/orgs","repos_url":"https://api.github.com/users/JackXLu/repos","events_url":"https://api.github.com/users/JackXLu/events{/privacy}","received_events_url":"https://api.github.com/users/JackXLu/received_events","type":"User","site_admin":false},"open_issues":32,"closed_issues":184,"state":"open","created_at":"2015-02-23T17:23:17Z","updated_at":"2015-08-12T03:19:25Z","due_on":"2015-06-30T05:00:00Z","closed_at":null},"comments":2,"created_at":"2015-08-11T18:51:37Z","updated_at":"2015-08-12T03:19:25Z","closed_at":"2015-08-12T03:19:25Z","body":"I had intended the ledgerKeyMR to be made with the hash of the serialized header which is stored, not one which is ephemeral.\r\n\r\nWith the current construction, getting the header hash to validate in the future is slightly more awkward.\r\n\r\nI add this code:\r\n\r\n```\r\n------------------------------- block/scblock.go -------------------------------\r\nindex 6e2c65d..000c642 100644\r\n@@ -384,9 +384,20 @@ func (b *FBlock) GetLedgerKeyMR() fct.IHash {\r\n \tif err != nil {\r\n \t\tpanic(\"Failed to create LedgerKeyMR: \" + err.Error())\r\n \t}\r\n+    fmt.Printf(\"header:\\n\")\r\n+    fmt.Printf(\"%x\\n\", data )\r\n \theaderHash := fct.Sha(data)\r\n+    fmt.Printf(\"headerhash:\\n\")\r\n+    fmt.Printf(\"%v\\n\", headerHash )\r\n+\t\r\n \tcat := append(ledgerMR.Bytes(), headerHash.Bytes()...)\r\n+\t\r\n+    fmt.Printf(\"concatenation:\\n\")\r\n+    fmt.Printf(\"%x\\n\", cat )\r\n \tlkmr := fct.Sha(cat)\r\n+    fmt.Printf(\"ledgerKeyMR:\\n\")\r\n+    fmt.Printf(\"%v\\n\", lkmr )\t\r\n+\r\n \r\n \treturn lkmr\r\n }\r\n@@ -416,7 +427,12 @@ func (b *FBlock) GetLedgerMR() fct.IHash {\r\n \t\tmarker++\r\n \t\thashes = append(hashes, fct.Sha(fct.ZERO))\r\n \t}\r\n+\t\r\n+    fmt.Printf(\"ledger hashes:\\n\")\r\n+    fmt.Printf(\"%v\\n\", hashes)\r\n \tlmr := fct.ComputeMerkleRoot(hashes)\r\n+    fmt.Printf(\"ledger mr:\\n\")\r\n+    fmt.Printf(\"%v\\n\", lmr )\r\n \treturn lmr\r\n }\r\n```\r\n\r\n\r\n\r\nand get this result:\r\n\r\n```\r\n     output:         2000.0        FA38F8fY6duMqDLyCNUYWemdFSWgXDSteeNvNCmJ1Eyb86Z3VNZo\r\n                  0000002e90edd000 9881aeb264452a4f7fafa1cc7bc4b93a05c55537c0703453e585f6d83ce77dca\r\n\r\n     output:         2000.0        FA2UojuPrDPNXMvaoNd5mV9gYrPtC8PSmb9Ku8oeCJKnWMjk7SN5\r\n                  0000002e90edd000 437fdcfec216c86a95e669c681addab17ed36be32ac4957f84a90782dbb47716\r\n\r\n     output:         2000.0        FA3Mtqn1yK1KqySDn4G6dQLjhPydNh8ue96yfgqi15KHucpvBw1u\r\n                  0000002e90edd000 b7803bc79f68679d23ec170c570cd03691b9fcbde6c2a0fea7646709179d0c2c\r\n\r\n\r\nledger hashes:\r\n[c514b61bc456abbdc5efeccb3d9c89bb17216288718906ea94d29591e9acc219 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d 6e340b9cffb37a989ca544e6bb780a2c78901d3fb33738768511a30617afa01d]\r\nledger mr:\r\n5b81ebb9c63d781763adc49d86964cb40111627c286753ad24b12098cea2dbe4\r\nheader:\r\n000000000000000000000000000000000000000000000000000000000000000f5b81ebb9c63d781763adc49d86964cb40111627c286753ad24b12098cea2dbe400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000186\r\nheaderhash:\r\n27fba47fbb50b042a18e14993778ae53885877b8d6289d01d340a19d81b0dffa\r\nconcatenation:\r\n5b81ebb9c63d781763adc49d86964cb40111627c286753ad24b12098cea2dbe427fba47fbb50b042a18e14993778ae53885877b8d6289d01d340a19d81b0dffa\r\nledgerKeyMR:\r\n97d4acf20eb3bd3d7a8e888dc4afdb4b122e61b431c6fb91f5151f01a029d06a\r\n13:01:31 2015-08-11 [INF] BTCD: Version 0.9.0-beta\r\npeers.json is disabled for Milestone1\r\n13:01:36 2015-08-11 [INF] SRVR: Server listening on [::]:8108 ; MaxPeers= 20\r\n13:01:36 2015-08-11 [INF] RPCS: RPC server listening on 127.0.0.1:8384\r\n\r\n```\r\n\r\nin the binary I see the header as:\r\n```\r\n000000000000000000000000000000000000000000000000000000000000000F15EC772F02ED7C14EAEDD3E6C01531B7A90E1A4C316FEC80BD6053576F3D68920000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000F4240000000000000000001\r\n```\r\n\r\nnotice that the binary uses 15EC77... as the BodyMR, but when the LedgerKeyMR is created, it hashes 5b81eb... in that slot.  5b81eb... is the ledgerMR, which is used to generate the ledgerKeyMR, but shouldn't be substituted for the bodyMR.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/FactomProject/WorkItems/issues/comments/130145410","html_url":"https://github.com/FactomProject/WorkItems/issues/626#issuecomment-130145410","issue_url":"https://api.github.com/repos/FactomProject/WorkItems/issues/626","id":130145410,"user":{"login":"PaulSnow","id":95612,"avatar_url":"https://avatars.githubusercontent.com/u/95612?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulSnow","html_url":"https://github.com/PaulSnow","followers_url":"https://api.github.com/users/PaulSnow/followers","following_url":"https://api.github.com/users/PaulSnow/following{/other_user}","gists_url":"https://api.github.com/users/PaulSnow/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulSnow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulSnow/subscriptions","organizations_url":"https://api.github.com/users/PaulSnow/orgs","repos_url":"https://api.github.com/users/PaulSnow/repos","events_url":"https://api.github.com/users/PaulSnow/events{/privacy}","received_events_url":"https://api.github.com/users/PaulSnow/received_events","type":"User","site_admin":false},"created_at":"2015-08-12T03:19:24Z","updated_at":"2015-08-12T03:19:24Z","body":"This is fixed."}}