Skip to content

Commit

Permalink
Merge pull request #5486 from oasisprotocol/peternose/bugfix/eden-gen…
Browse files Browse the repository at this point in the history
…esis-sigs

rhp: Add extra signatures to Eden genesis block
  • Loading branch information
kostko authored Nov 29, 2023
2 parents 5100999 + 42893b2 commit 6f9d3d2
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/5486.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rhp: Add extra signatures to Eden genesis block
125 changes: 125 additions & 0 deletions go/runtime/registry/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package registry

import (
"context"
"encoding/hex"
"errors"
"fmt"
"math/rand"
"sync"
"time"

cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/eapache/channels"

beacon "github.com/oasisprotocol/oasis-core/go/beacon/api"
Expand Down Expand Up @@ -306,6 +308,129 @@ func (h *runtimeHostHandler) handleHostFetchConsensusBlock(
return nil, fmt.Errorf("light block fetch failure: %w", err)
}

// Add extra signatures collected offline to Eden genesis light block.
chainContext, err := h.consensus.GetChainContext(ctx)
if err != nil {
return nil, err
}
edenChainContext := "bb3d748def55bdfb797a2ac53ee6ee141e54cd2ab2dc2375f4a0703a178e6e55"
edenGenesisHeight := uint64(16817956)
if chainContext == edenChainContext && rq.Height == edenGenesisHeight {
var pb cmtproto.LightBlock
if err = pb.Unmarshal(blk.Meta); err != nil {
return nil, fmt.Errorf("failed to unmarshal cometbft light block: %w", err)
}

// Missing signatures.
encSigs := map[int]string{
3: "", // 1D695FD854E1D39EFB14B6051484AB3A3E946D42 Mars Staking | Long term fee 1%
6: "", // DB155AD2D2B42EBB8D96171421F71CEBFCCE9443 GoStaking
9: "2a393a32f69087fc6bcd7aa60d3a1c9a427229b0e851a89610598538ab712c81d2a61d8114dbff8b2a3ad109ae964cb72ea73f651c1699a81580dfdd5acdf30c", // 3C7535AD5A1CEE0DF1F5A9D0FBB7F115597D694D Bit Cat🐱
11: "c2400d5300267aeef1c6841387ab7f4e52678465446963052744a9c557db5d4956cebd440c0e38e05f7beabfa07c752043db6e5fb9df417b5e4e062ec525f00b", // B98AC6369C28A836D1767B5FB0DDB09B641F59FD Doorgod
13: "33b7b68929ff47ea7cde731fbd243564e3bd1c3b1ce3f877907858e52c9392733b422b9eb856ec1c2edf8a77fade798a6813f35601e950a015dda6ad9c943201", // D7E17A746BA033183C6D631DBEBF95593FF12303 Spectrum Staking
15: "02524bd3e8512ad57504f6f090322e7c8640b2df6edaf69f519fd0ff543e8306c19256ec08f11b3371f504cb5e064c3c80bdff99ab1190789eda1b5782c89a08", // 46B86E7BAAEBE7083422979EC56DDC9B332A9236 Princess Stake
16: "", // A3077AE4E4622C68E41E8BF9C6CDAC3396478D3B Everstake
18: "", // 031530A0C5735775A2B75137DCB2B3A58E3DCE21 Tessellated Geometry
20: "faa447cbb617fb7c7d603cba86e42d7e9c04e292030ec6921217d629081d1a4cef8193161f5d573645f03844776bbe9a8ab2483463868406efdbd200775a3d01", // 139F7714CD1FC8012B68D79BCB5CBDAF25C0139F Dobrynya Hukutu4
21: "", // 44C6F655469D0FB5BAC6AA95DAF21566911C5346 <none>
22: "238a8cbed6b4515ed17defb89b38e02c84e2b25da61ec09cf73d7b99009ced290e34535257e2732ff3bc699a62aa1ae9850e99dcd4e75aca985f73cf57f67203", // AFA000D76FAE365C7AFCF77EA378DA2AD51AA852 Alexander (aka Bambarello) Validator
32: "0d5128d9018f59a8880c893ed86b4b41cd5fe8eedf11f39621ee1dd89a07292b99fde5419d63a1766ff6df147d0e48acc8178f1965088234d8291815cc875406", // 5D9CCE6B571A19368F49986A55A084DAFC16FF67 glebanyy
36: "", // E13CCC629C674390A001CF09896F2E579C5BC0B8 Ocean Stake
37: "", // CB7C4EFA3CC0CF13D5D276F3933A3FCA41B48DC9 AutoStake 🛡️ Slash Protected
39: "30c4ec9766caf84945efc3f130e41c8879704d3140805559cce773a00f49fe7a1d71233c86cbf3bf334ca178dcc252ef92f06d3c75db80aa506c848989bb4309", // AC6FD590781448186B9D5990E7D8A5154E32CC97 0base.vc
40: "", // C0F7D1DF00612C3099B05020802891C8F142E7C5 Staky.io
42: "", // 672FD177BE6DCE12743638C338EDF53EDA3E5C92 Hashed x DELIGHT
43: "", // E81A0385D14F085B778A6CA065BB71CEDE8BD1BB itokenpool
58: "33d3402c351fcb15bdbc69be53dba8beac4a4005a51c9f1edc4479a3924aa4cdaedfdc2ab44792aaf4123945859cc88874dc9b9186f5ecf2e8a109bfca05710b", // 916DC43DC0D9D80669A4CF096F82F45618A11D6F Stardust
61: "", // C6A279F20AFE19744F163FC252E7B8485839C7D6 Wetez
62: "", // 7954EE2396125ED080B0EF500D71ECA7176F0C00 <none>
63: "ccf304e4737e0363c0b1d462d87674987b1a4c9566c22a8a70f6455a7525a040f02024e7aa43f8e1a16e89d595148e7d1dd2ac2a1e0ce84c2789dc635096280b", // CBB0BDE73E1ECCCA26CA9F99A2251B5DCCBCA803 <none>
65: "", // 4F4B50D08E0D5CE2D2FF0B0C7A50DD52E11B791B DCC Capital
66: "", // B600F97DD0D38027824EF9DF5EF7EEE235025A15 HashQuark
67: "", // DD84C10CE13D57B69DF63C992DC6E34AEAA4F88B WolfEdge Capital
68: "", // 396361E55E55FA3C6BFAA0C44E1F41B4DB7D1187 <none>
69: "", // 198FEE1CDDF99D4EC9246ACEA150131E39319D04 <none>
72: "", // C130071B3ACC17434AC02E4E9703C40B060518DD BlockOG Capital
73: "", // 90D04059E345E74F5CFF9F82B33E32FE02692B98 Datax Staking
74: "", // 8114E8BE22380A11996CEA93D98A0E1C8BA323A2 Strata One
75: "", // ADA4C52F122FD76ACBFD1D658EF7A3A336D6AFE9 InfStones
76: "", // 7AC5014F77E02CC9B503F5D748BEA2D889AF3F16 <none>
77: "", // 28B637520B7DC7853FB0259A104FFF2E0EC165B1 Ubik Capital
79: "", // 8A40E18A0904D1876AF5557A0C156AB2D4E05893 <none>
82: "", // D6F5A43D5C99CC6C3D63AE88AB3B287C01AE795B <none>
83: "", // 9B5FE068239F5C866903DAF2CA7BCBCABDD314E4 <none>
84: "", // 86AE5099F1313FA685B1856F1952F982155546ED Aptemuyc🌹
85: "", // 8885B8729A2EB95EBBC1D48CB86FD0C29979AB24 hybridx.exchange
87: "", // 60A4964BE14FF231A3494AA1D4077F483E68EDE5 Blockscale - Planet-Scale Blockchain Services
91: "", // 250CEEEA6C409B23F6107D32A01CD0A6AF0FE6EC Bi23 Labs
93: "", // 9EC5FC5676DA8167CD2BEDF2DE91EA97745BCF6B 01node
94: "", // 44687C15D1BD79E7D369C0ADEFDAEC218B5B7A11 Kiln
95: "", // BD798061A0F78C0AE199F28BE0ACC98FBC0EFD3B <none>
96: "", // BB7DB41FFF58D8EF6199616EF13E05D952B7BD73 Terminet
97: "", // A743D637323C6ABFFB624858894366AFE2CF385F Maria Mirabella❤️ ROSE
98: "", // 75EBFB35260AD902BC16F15ACD393293C19DDC36 <none>
99: "", // 3B9EA83997FA0434AA9AD0AE19EFE6003EBCE348 Coinpayu
100: "", // 636CB5449716C3F320257466277097E0F9BA8514 RoseDrop
101: "", // E509726BE1CFFB3EADDF0903A8A9E917544DD6E9 AndromedaPool | Zero fee to 2025
102: "", // 0F3B35C317478369535094440A5E41E2DE2DB05A Hammerfest
104: "", // BFD76834515381BDC8B542B9EEA5BFB5F4B2DA02 0% Fee StakeSeeker by BTCS
105: "", // 88399F3514B019F93BF924395A275D7C017DD8EF Hyperblockspro
106: "", // FACE3B7A56347F073429544A409C29EE77A44EEC Second State
107: "ab8fc5b6a852f5847805e8653aa590e982bcc48d45887a036bb2fc33fb673f5c6e69119a9feaa9c04a97fa76442f6a10198250f452a45d226d267bd120094d00", // E13306587B4245312A57F696DCB5BC407E0CD0F4 LaunchGarden
108: "", // A07B898C4B997CEE60891A05A647AADD557C8FCE Validator.ONE | 0% Fee | Trusted Validator
110: "", // CEA0F5491682A80315A81997AAF56C40F386CA22 <none>
112: "", // BD12B6312E58E2859E7C6F4E092DB9269232F99F Oasis@UBC
113: "", // 2ABE1491367ABE4B7C5FB2292ADF5E2FFFC99E59 Moonstake
115: "07417909023b5901fb6156b8b9555ee8ff286f5fa2a6a0da74d0dc5bd75b14d327c00d40e645bf5c79bef2d1d1c9e0ea8aac5278a803e671a13f995b0137f107", // F8B244ADA2FC5FC3E864838375391D470A29CC39 CryptoSJ.net
116: "", // B5391717B04E44F931FF70ACEB54AA84B38BD2B9 StakeHaven
117: "", // 7EDDB9611E5C1496C99B0DCA3D133757540DDBF1 Colossus
}

// Timestamp of missing signatures.
timeString := "2023-11-29 11:25:17.649247857 +0000 UTC"
layout := "2006-01-02 15:04:05.999999999 -0700 MST"
timestamp, err := time.Parse(layout, timeString)
if err != nil {
return nil, err
}

// Fetch validator address from the validator set.
valset := pb.GetValidatorSet()
vals := valset.GetValidators()

for index, encSig := range encSigs {
if encSig == "" {
continue
}
if index >= len(pb.SignedHeader.Commit.Signatures) {
return nil, fmt.Errorf("cometbft light block signature index %d out of bounds", index)
}
if len(pb.SignedHeader.Commit.Signatures[index].Signature) > 0 {
return nil, fmt.Errorf("cometbft light block signature %d already set", index)
}

sig, err := hex.DecodeString(encSig)
if err != nil {
return nil, fmt.Errorf("failed to decode cometbft light block signature: %w", err)
}

comSig := cmtproto.CommitSig{
BlockIdFlag: 2,
ValidatorAddress: vals[index].GetAddress(),
Timestamp: timestamp,
Signature: sig,
}
pb.SignedHeader.Commit.Signatures[index] = comSig
}

meta, err := pb.Marshal()
if err != nil {
return nil, fmt.Errorf("failed to marshal cometbft light block: %w", err)
}

blk.Meta = meta
}

return &protocol.HostFetchConsensusBlockResponse{Block: *blk}, nil
}

Expand Down

0 comments on commit 6f9d3d2

Please sign in to comment.