diff --git a/VERSION b/VERSION index 787ffc30a..8298bb08b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.42.0 +0.43.0 diff --git a/params/config.go b/params/config.go index 0e4c35bd4..1f8c78053 100644 --- a/params/config.go +++ b/params/config.go @@ -527,6 +527,10 @@ type ShhextConfig struct { // IMPORTANT: It should always be mainnet unless used for testing VerifyENSURL string + // VerifyENSContractAddress is the address of the contract used to verify ENS + // No default is provided and if not set ENS resolution is disabled + VerifyENSContractAddress string + VerifyTransactionChainID int64 } diff --git a/protocol/contact.go b/protocol/contact.go index a12bc12c8..f36cc62a8 100644 --- a/protocol/contact.go +++ b/protocol/contact.go @@ -38,7 +38,12 @@ type Contact struct { // EnsVerified whether we verified the name of the contact ENSVerified bool `json:"ensVerified"` // EnsVerifiedAt the time we last verified the name - ENSVerifiedAt int64 `json:"ensVerifiedAt"` + ENSVerifiedAt uint64 `json:"ensVerifiedAt"` + // LastENSClockValue is the last clock value of when we + // received an ENS name for the user + LastENSClockValue uint64 `json:"lastENSClockValue"` + // ENSVerificationRetries is how many times we retried the ENS + ENSVerificationRetries uint64 `json:"ensVerificationRetries"` // Generated username name of the contact Alias string `json:"alias,omitempty"` // Identicon generated from public key @@ -76,6 +81,14 @@ func (c Contact) IsBlocked() bool { return existsInStringSlice(c.SystemTags, contactBlocked) } +func (c *Contact) ResetENSVerification(clock uint64, name string) { + c.ENSVerifiedAt = 0 + c.ENSVerified = false + c.ENSVerificationRetries = 0 + c.LastENSClockValue = clock + c.Name = name +} + // existsInStringSlice checks if a string is in a set. func existsInStringSlice(set []string, find string) bool { for _, s := range set { diff --git a/protocol/encryption/migrations/migrations.go b/protocol/encryption/migrations/migrations.go index ea0a151ab..3e93c617c 100644 --- a/protocol/encryption/migrations/migrations.go +++ b/protocol/encryption/migrations/migrations.go @@ -100,7 +100,7 @@ func _1536754952_initial_schemaDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1536754952_initial_schema.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1536754952_initial_schema.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x44, 0xcf, 0x76, 0x71, 0x1f, 0x5e, 0x9a, 0x43, 0xd8, 0xcd, 0xb8, 0xc3, 0x70, 0xc3, 0x7f, 0xfc, 0x90, 0xb4, 0x25, 0x1e, 0xf4, 0x66, 0x20, 0xb8, 0x33, 0x7e, 0xb0, 0x76, 0x1f, 0xc, 0xc0, 0x75}} return a, nil } @@ -120,7 +120,7 @@ func _1536754952_initial_schemaUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1536754952_initial_schema.up.sql", size: 962, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1536754952_initial_schema.up.sql", size: 962, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xea, 0x90, 0x5a, 0x59, 0x3e, 0x3, 0xe2, 0x3c, 0x81, 0x42, 0xcd, 0x4c, 0x9a, 0xe8, 0xda, 0x93, 0x2b, 0x70, 0xa4, 0xd5, 0x29, 0x3e, 0xd5, 0xc9, 0x27, 0xb6, 0xb7, 0x65, 0xff, 0x0, 0xcb, 0xde}} return a, nil } @@ -140,7 +140,7 @@ func _1539249977_update_ratchet_infoDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1539249977_update_ratchet_info.down.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1539249977_update_ratchet_info.down.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0xa4, 0xeb, 0xa0, 0xe6, 0xa0, 0xd4, 0x48, 0xbb, 0xad, 0x6f, 0x7d, 0x67, 0x8c, 0xbd, 0x25, 0xde, 0x1f, 0x73, 0x9a, 0xbb, 0xa8, 0xc9, 0x30, 0xb7, 0xa9, 0x7c, 0xaf, 0xb5, 0x1, 0x61, 0xdd}} return a, nil } @@ -160,7 +160,7 @@ func _1539249977_update_ratchet_infoUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1539249977_update_ratchet_info.up.sql", size: 368, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1539249977_update_ratchet_info.up.sql", size: 368, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc, 0x8e, 0xbf, 0x6f, 0xa, 0xc0, 0xe1, 0x3c, 0x42, 0x28, 0x88, 0x1d, 0xdb, 0xba, 0x1c, 0x83, 0xec, 0xba, 0xd3, 0x5f, 0x5c, 0x77, 0x5e, 0xa7, 0x46, 0x36, 0xec, 0x69, 0xa, 0x4b, 0x17, 0x79}} return a, nil } @@ -180,7 +180,7 @@ func _1540715431_add_versionDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1540715431_add_version.down.sql", size: 127, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1540715431_add_version.down.sql", size: 127, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x9, 0x4, 0xe3, 0x76, 0x2e, 0xb8, 0x9, 0x23, 0xf0, 0x70, 0x93, 0xc4, 0x50, 0xe, 0x9d, 0x84, 0x22, 0x8c, 0x94, 0xd3, 0x24, 0x9, 0x9a, 0xc1, 0xa1, 0x48, 0x45, 0xfd, 0x40, 0x6e, 0xe6}} return a, nil } @@ -200,7 +200,7 @@ func _1540715431_add_versionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1540715431_add_version.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1540715431_add_version.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc7, 0x4c, 0x36, 0x96, 0xdf, 0x16, 0x10, 0xa6, 0x27, 0x1a, 0x79, 0x8b, 0x42, 0x83, 0x23, 0xc, 0x7e, 0xb6, 0x3d, 0x2, 0xda, 0xa4, 0xb4, 0xd, 0x27, 0x55, 0xba, 0xdc, 0xb2, 0x88, 0x8f, 0xa6}} return a, nil } @@ -220,7 +220,7 @@ func _1541164797_add_installationsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1541164797_add_installations.down.sql", size: 26, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1541164797_add_installations.down.sql", size: 26, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0xfd, 0xe6, 0xd8, 0xca, 0x3b, 0x38, 0x18, 0xee, 0x0, 0x5f, 0x36, 0x9e, 0x1e, 0xd, 0x19, 0x3e, 0xb4, 0x73, 0x53, 0xe9, 0xa5, 0xac, 0xdd, 0xa1, 0x2f, 0xc7, 0x6c, 0xa8, 0xd9, 0xa, 0x88}} return a, nil } @@ -240,7 +240,7 @@ func _1541164797_add_installationsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1541164797_add_installations.up.sql", size: 216, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1541164797_add_installations.up.sql", size: 216, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2d, 0x18, 0x26, 0xb8, 0x88, 0x47, 0xdb, 0x83, 0xcc, 0xb6, 0x9d, 0x1c, 0x1, 0xae, 0x2f, 0xde, 0x97, 0x82, 0x3, 0x30, 0xa8, 0x63, 0xa1, 0x78, 0x4b, 0xa5, 0x9, 0x8, 0x75, 0xa2, 0x57, 0x81}} return a, nil } @@ -260,7 +260,7 @@ func _1558084410_add_secretDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558084410_add_secret.down.sql", size: 56, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558084410_add_secret.down.sql", size: 56, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x49, 0xb, 0x65, 0xdf, 0x59, 0xbf, 0xe9, 0x5, 0x5b, 0x6f, 0xd5, 0x3a, 0xb7, 0x57, 0xe8, 0x78, 0x38, 0x73, 0x53, 0x57, 0xf7, 0x24, 0x4, 0xe4, 0xa2, 0x49, 0x22, 0xa2, 0xc6, 0xfd, 0x80, 0xa4}} return a, nil } @@ -280,7 +280,7 @@ func _1558084410_add_secretUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558084410_add_secret.up.sql", size: 301, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558084410_add_secret.up.sql", size: 301, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x32, 0x36, 0x8e, 0x47, 0xb0, 0x8f, 0xc1, 0xc6, 0xf7, 0xc6, 0x9f, 0x2d, 0x44, 0x75, 0x2b, 0x26, 0xec, 0x6, 0xa0, 0x7b, 0xa5, 0xbd, 0xc8, 0x76, 0x8a, 0x82, 0x68, 0x2, 0x42, 0xb5, 0xf4}} return a, nil } @@ -300,7 +300,7 @@ func _1558588866_add_versionDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558588866_add_version.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558588866_add_version.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x52, 0x34, 0x3c, 0x46, 0x4a, 0xf0, 0x72, 0x47, 0x6f, 0x49, 0x5c, 0xc7, 0xf9, 0x32, 0xce, 0xc4, 0x3d, 0xfd, 0x61, 0xa1, 0x8b, 0x8f, 0xf2, 0x31, 0x34, 0xde, 0x15, 0x49, 0xa6, 0xde, 0xb9}} return a, nil } @@ -320,7 +320,7 @@ func _1558588866_add_versionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558588866_add_version.up.sql", size: 57, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558588866_add_version.up.sql", size: 57, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0xea, 0x64, 0x39, 0x61, 0x20, 0x83, 0x83, 0xb, 0x2e, 0x79, 0x64, 0xb, 0x53, 0xfa, 0xfe, 0xc6, 0xf7, 0x67, 0x42, 0xd3, 0x4f, 0xdc, 0x7e, 0x30, 0x32, 0xe8, 0x14, 0x41, 0xe9, 0xe7, 0x3b}} return a, nil } @@ -340,7 +340,7 @@ func _1559627659_add_contact_codeDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1559627659_add_contact_code.down.sql", size: 32, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1559627659_add_contact_code.down.sql", size: 32, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x64, 0x6d, 0xce, 0x24, 0x42, 0x20, 0x8d, 0x4f, 0x37, 0xaa, 0x9d, 0xc, 0x57, 0x98, 0xc1, 0xd1, 0x1a, 0x34, 0xcd, 0x9f, 0x8f, 0x34, 0x86, 0xb3, 0xd3, 0xdc, 0xf1, 0x7d, 0xe5, 0x1b, 0x6e}} return a, nil } @@ -360,7 +360,7 @@ func _1559627659_add_contact_codeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1559627659_add_contact_code.up.sql", size: 198, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1559627659_add_contact_code.up.sql", size: 198, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x16, 0xf6, 0xc2, 0x62, 0x9c, 0xd2, 0xc9, 0x1e, 0xd8, 0xea, 0xaa, 0xea, 0x95, 0x8f, 0x89, 0x6a, 0x85, 0x5d, 0x9d, 0x99, 0x78, 0x3c, 0x90, 0x66, 0x99, 0x3e, 0x4b, 0x19, 0x62, 0xfb, 0x31, 0x4d}} return a, nil } @@ -380,7 +380,7 @@ func _1561368210_add_installation_metadataDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561368210_add_installation_metadata.down.sql", size: 35, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561368210_add_installation_metadata.down.sql", size: 35, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa8, 0xde, 0x3f, 0xd2, 0x4a, 0x50, 0x98, 0x56, 0xe3, 0xc0, 0xcd, 0x9d, 0xb0, 0x34, 0x3b, 0xe5, 0x62, 0x18, 0xb5, 0x20, 0xc9, 0x3e, 0xdc, 0x6a, 0x40, 0x36, 0x66, 0xea, 0x51, 0x8c, 0x71, 0xf5}} return a, nil } @@ -400,7 +400,7 @@ func _1561368210_add_installation_metadataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561368210_add_installation_metadata.up.sql", size: 267, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561368210_add_installation_metadata.up.sql", size: 267, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb4, 0x71, 0x8f, 0x29, 0xb1, 0xaa, 0xd6, 0xd1, 0x8c, 0x17, 0xef, 0x6c, 0xd5, 0x80, 0xb8, 0x2c, 0xc3, 0xfe, 0xec, 0x24, 0x4d, 0xc8, 0x25, 0xd3, 0xb4, 0xcd, 0xa9, 0xac, 0x63, 0x61, 0xb2, 0x9c}} return a, nil } @@ -420,7 +420,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xef, 0xaf, 0xdf, 0xcf, 0x65, 0xae, 0x19, 0xfc, 0x9d, 0x29, 0xc1, 0x91, 0xaf, 0xb5, 0xd5, 0xb1, 0x56, 0xf3, 0xee, 0xa8, 0xba, 0x13, 0x65, 0xdb, 0xab, 0xcf, 0x4e, 0xac, 0x92, 0xe9, 0x60, 0xf1}} return a, nil } diff --git a/protocol/ens.go b/protocol/ens.go new file mode 100644 index 000000000..2166be49e --- /dev/null +++ b/protocol/ens.go @@ -0,0 +1,63 @@ +package protocol + +import ( + "math" + "strings" +) + +// maxRetries is the maximum number of attemps we do before giving up +const maxRetries uint64 = 11 + +// ENSBackoffTimeMs is the step of the exponential backoff +// we retry roughtly for 17 hours after receiving the message 2^11 * 30000 +const ENSBackoffTimeMs uint64 = 30000 + +// We calculate if it's too early to retry, by exponentially backing off +func verifiedENSRecentlyEnough(now, verifiedAt, retries uint64) bool { + return now < verifiedAt+ENSBackoffTimeMs*retries*uint64(math.Exp2(float64(retries))) +} + +func shouldENSBeVerified(c *Contact, now uint64) bool { + if c.Name == "" { + return false + } + + if c.ENSVerified { + return false + } + + if c.ENSVerificationRetries >= maxRetries { + return false + } + + if verifiedENSRecentlyEnough(now, c.ENSVerifiedAt, c.ENSVerificationRetries) { + return false + } + + if !strings.HasSuffix(c.Name, ".eth") { + return false + } + + return true +} + +// This should trigger re-verification of the ENS name for this contact +func hasENSNameChanged(c *Contact, newName string, clockValue uint64) bool { + if c.LastENSClockValue > clockValue { + return false + } + + if newName == "" { + return false + } + + if !strings.HasSuffix(newName, ".eth") { + return false + } + + if newName == c.Name { + return false + } + + return true +} diff --git a/protocol/ens_test.go b/protocol/ens_test.go new file mode 100644 index 000000000..149eb4c48 --- /dev/null +++ b/protocol/ens_test.go @@ -0,0 +1,140 @@ +package protocol + +import ( + "testing" + + "github.com/stretchr/testify/suite" +) + +type ENSSuite struct { + suite.Suite +} + +func TestENSSuite(t *testing.T) { + suite.Run(t, new(ENSSuite)) +} + +func (s *ENSSuite) TestShouldBeVerified() { + testCases := []struct { + Name string + Contact Contact + Expected bool + TimeNow uint64 + }{ + { + Name: "valid eth name", + Contact: Contact{Name: "vitalik.eth"}, + Expected: true, + }, + { + Name: "valid eth name,some retries", + Contact: Contact{ + Name: "vitalik.eth", + ENSVerifiedAt: 10, + ENSVerificationRetries: 4, + }, + Expected: true, + TimeNow: 10 + ENSBackoffTimeMs*4*16 + 1, + }, + { + Name: "Empty name", + Contact: Contact{}, + Expected: false, + }, + { + Name: "invalid eth name", + Contact: Contact{Name: "vitalik.eth2"}, + Expected: false, + }, + { + Name: "Already verified", + Contact: Contact{ + Name: "vitalik.eth", + ENSVerified: true, + }, + Expected: false, + }, + + { + Name: "verified recently", + Contact: Contact{ + Name: "vitalik.eth", + ENSVerifiedAt: 10, + ENSVerificationRetries: 4, + }, + Expected: false, + TimeNow: 10 + ENSBackoffTimeMs*4*16 - 1, + }, + { + Name: "max retries reached", + Contact: Contact{ + Name: "vitalik.eth", + ENSVerifiedAt: 10, + ENSVerificationRetries: 11, + }, + Expected: false, + TimeNow: 10 + ENSBackoffTimeMs*5*2048 + 1, + }, + } + for _, tc := range testCases { + s.Run(tc.Name, func() { + response := shouldENSBeVerified(&tc.Contact, tc.TimeNow) + s.Equal(tc.Expected, response) + }) + } +} + +func (s *ENSSuite) TestHasENSNameChanged() { + testCases := []struct { + Name string + Contact Contact + NewName string + Clock uint64 + Expected bool + }{ + { + Name: "clock value is greater", + Contact: Contact{LastENSClockValue: 0}, + Clock: 1, + NewName: "vitalik.eth", + Expected: true, + }, + { + Name: "name in empty", + Contact: Contact{LastENSClockValue: 0}, + Clock: 1, + Expected: false, + }, + { + Name: "name is invalid", + Contact: Contact{LastENSClockValue: 0}, + Clock: 1, + NewName: "vitalik.eth2", + Expected: false, + }, + { + Name: "name is identical", + Contact: Contact{ + Name: "vitalik.eth", + LastENSClockValue: 0, + }, + Clock: 1, + NewName: "vitalik.eth", + Expected: false, + }, + + { + Name: "clock value is less", + Contact: Contact{LastENSClockValue: 1}, + Clock: 0, + NewName: "vitalik.eth", + Expected: false, + }, + } + for _, tc := range testCases { + s.Run(tc.Name, func() { + response := hasENSNameChanged(&tc.Contact, tc.NewName, tc.Clock) + s.Equal(tc.Expected, response) + }) + } +} diff --git a/protocol/message_handler.go b/protocol/message_handler.go index 7cda081db..3e82380bd 100644 --- a/protocol/message_handler.go +++ b/protocol/message_handler.go @@ -337,6 +337,13 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error { state.ModifiedChats[chat.ID] = true state.AllChats[chat.ID] = chat + contact := state.CurrentMessageState.Contact + if hasENSNameChanged(contact, receivedMessage.EnsName, receivedMessage.Clock) { + contact.ResetENSVerification(receivedMessage.Clock, receivedMessage.EnsName) + state.ModifiedContacts[contact.ID] = true + state.AllContacts[contact.ID] = contact + } + // Add to response if receivedMessage != nil { state.Response.Messages = append(state.Response.Messages, receivedMessage) diff --git a/protocol/messenger.go b/protocol/messenger.go index 9428a4ac5..45557ac86 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -2041,33 +2041,45 @@ func Identicon(id string) (string, error) { } // VerifyENSNames verifies that a registered ENS name matches the expected public key -func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetails []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error) { +func (m *Messenger) VerifyENSNames(ctx context.Context, rpcEndpoint, contractAddress string) (*MessengerResponse, error) { m.mutex.Lock() defer m.mutex.Unlock() + + m.logger.Debug("verifying ENS Names", zap.String("endpoint", rpcEndpoint)) verifier := m.node.NewENSVerifier(m.logger) + var response MessengerResponse + + var ensDetails []enstypes.ENSDetails + + now := m.getTimesource().GetCurrentTime() + for _, contact := range m.allContacts { + if shouldENSBeVerified(contact, now) { + ensDetails = append(ensDetails, enstypes.ENSDetails{ + PublicKeyString: contact.ID[2:], + Name: contact.Name, + }) + } + } + ensResponse, err := verifier.CheckBatch(ensDetails, rpcEndpoint, contractAddress) if err != nil { return nil, err } - // Update contacts - var contacts []*Contact for _, details := range ensResponse { - if details.Error == nil { - contact, ok := m.allContacts["0x"+details.PublicKeyString] - if !ok { - contact, err = buildContact(details.PublicKey) - if err != nil { - return nil, err - } - } - contact.ENSVerified = details.Verified - contact.ENSVerifiedAt = details.VerifiedAt - contact.Name = details.Name + contact, ok := m.allContacts["0x"+details.PublicKeyString] + if !ok { + return nil, errors.New("contact must be existing") + } + m.logger.Debug("verifying ENS Name", zap.Any("details", details), zap.Any("contact", contact)) + + contact.ENSVerifiedAt = uint64(details.VerifiedAt) + + if details.Error == nil { + contact.ENSVerified = details.Verified m.allContacts[contact.ID] = contact - contacts = append(contacts, contact) } else { m.logger.Warn("Failed to resolve ens name", zap.String("name", details.Name), @@ -2075,16 +2087,17 @@ func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetai zap.Error(details.Error), ) } + response.Contacts = append(response.Contacts, contact) } - if len(contacts) != 0 { - err = m.persistence.SaveContacts(contacts) + if len(response.Contacts) != 0 { + err = m.persistence.SaveContacts(response.Contacts) if err != nil { return nil, err } } - return ensResponse, nil + return &response, nil } // GenerateAlias name returns the generated name given a public key hex encoded prefixed with 0x diff --git a/protocol/messenger_test.go b/protocol/messenger_test.go index 72939b6b3..bda53d19d 100644 --- a/protocol/messenger_test.go +++ b/protocol/messenger_test.go @@ -1311,78 +1311,6 @@ func (s *MessengerSuite) TestContactPersistence() { s.Require().Equal(expectedContact, actualContact) } -func (s *MessengerSuite) TestVerifyENSNames() { - rpcEndpoint := os.Getenv("RPC_ENDPOINT") - if rpcEndpoint == "" { - s.T().Skip() - } - contractAddress := "0x314159265dd8dbb310642f98f50c066173c1259b" - pk1 := "04325367620ae20dd878dbb39f69f02c567d789dd21af8a88623dc5b529827c2812571c380a2cd8236a2851b8843d6486481166c39debf60a5d30b9099c66213e4" - pk2 := "044580b6aef9ddebd88c373b43c91237dcc95a8307bc5837d11d3ad2fa5d1dc696b598e7ccc498b414ba80b86b129c48e1eb9464cc9ea26224321539f2f54024cc" - pk3 := "044fee950d9748606da2f77d3c51bf16134a59bde4903aa68076a45d9eefbb54182a24f0c74b381bad0525a90e78770d11559aa02f77343d172f386e3b521c277a" - pk4 := "not a valid pk" - - ensDetails := []enstypes.ENSDetails{ - { - Name: "pedro.stateofus.eth", - PublicKeyString: pk1, - }, - // Not matching pk -> name - { - Name: "pedro.stateofus.eth", - PublicKeyString: pk2, - }, - // Not existing name - { - Name: "definitelynotpedro.stateofus.eth", - PublicKeyString: pk3, - }, - // Malformed pk - { - Name: "pedro.stateofus.eth", - PublicKeyString: pk4, - }, - } - - response, err := s.m.VerifyENSNames(rpcEndpoint, contractAddress, ensDetails) - s.Require().NoError(err) - s.Require().Equal(4, len(response)) - - s.Require().Nil(response[pk1].Error) - s.Require().Nil(response[pk2].Error) - s.Require().NotNil(response[pk3].Error) - s.Require().NotNil(response[pk4].Error) - - s.Require().True(response[pk1].Verified) - s.Require().False(response[pk2].Verified) - s.Require().False(response[pk3].Verified) - s.Require().False(response[pk4].Verified) - - // The contacts are updated - savedContacts := s.m.Contacts() - - s.Require().Equal(2, len(savedContacts)) - - var verifiedContact *Contact - var notVerifiedContact *Contact - - if savedContacts[0].ID == pk1 { - verifiedContact = savedContacts[0] - notVerifiedContact = savedContacts[1] - } else { - notVerifiedContact = savedContacts[0] - verifiedContact = savedContacts[1] - } - - s.Require().Equal("pedro.stateofus.eth", verifiedContact.Name) - s.Require().NotEqual(0, verifiedContact.ENSVerifiedAt) - s.Require().True(verifiedContact.ENSVerified) - - s.Require().Equal("pedro.stateofus.eth", notVerifiedContact.Name) - s.Require().NotEqual(0, notVerifiedContact.ENSVerifiedAt) - s.Require().True(notVerifiedContact.ENSVerified) -} - func (s *MessengerSuite) TestContactPersistenceUpdate() { contactID := "0x0424a68f89ba5fcd5e0640c1e1f591d561fa4125ca4e2a43592bc4123eca10ce064e522c254bb83079ba404327f6eafc01ec90a1444331fe769d3f3a7f90b0dde1" diff --git a/protocol/migrations/migrations.go b/protocol/migrations/migrations.go index ff08e31f9..9e628220e 100644 --- a/protocol/migrations/migrations.go +++ b/protocol/migrations/migrations.go @@ -2,6 +2,8 @@ // sources: // 000001_init.down.db.sql (65B) // 000001_init.up.db.sql (2.719kB) +// 000002_add_last_ens_clock_value.down.sql (0) +// 000002_add_last_ens_clock_value.up.sql (77B) // doc.go (377B) package migrations @@ -86,7 +88,7 @@ func _000001_initDownDbSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1578756765, 0)} + info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1578682784, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5e, 0xbb, 0x3f, 0x1, 0x75, 0x19, 0x70, 0x86, 0xa7, 0x34, 0x40, 0x17, 0x34, 0x3e, 0x18, 0x51, 0x79, 0xd4, 0x22, 0xad, 0x8f, 0x80, 0xcc, 0xa6, 0xcc, 0x6, 0x2b, 0x62, 0x2, 0x47, 0xba, 0xf9}} return a, nil } @@ -106,11 +108,51 @@ func _000001_initUpDbSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2719, mode: os.FileMode(0644), modTime: time.Unix(1578756765, 0)} + info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2719, mode: os.FileMode(0644), modTime: time.Unix(1578682784, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x60, 0xdc, 0xeb, 0xe, 0xc2, 0x4f, 0x75, 0xa, 0xf6, 0x3e, 0xc7, 0xc4, 0x4, 0xe2, 0xe1, 0xa4, 0x73, 0x2f, 0x4a, 0xad, 0x1a, 0x0, 0xc3, 0x93, 0x9d, 0x77, 0x3e, 0x31, 0x91, 0x77, 0x2e, 0xc8}} return a, nil } +var __000002_add_last_ens_clock_valueDownSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00") + +func _000002_add_last_ens_clock_valueDownSqlBytes() ([]byte, error) { + return bindataRead( + __000002_add_last_ens_clock_valueDownSql, + "000002_add_last_ens_clock_value.down.sql", + ) +} + +func _000002_add_last_ens_clock_valueDownSql() (*asset, error) { + bytes, err := _000002_add_last_ens_clock_valueDownSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "000002_add_last_ens_clock_value.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1580459788, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} + return a, nil +} + +var __000002_add_last_ens_clock_valueUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x04\xc0\x41\x0a\x85\x20\x10\x06\xe0\xfd\x3b\xc5\x7f\x84\xb7\x6f\x35\xa5\x41\x30\x8d\x10\xe3\x5a\x64\x70\x95\xe8\x42\xeb\xfc\x7d\xc4\xea\x2f\x28\xad\xec\x61\xbd\xcd\x6c\x73\x80\x9c\xc3\x16\x38\x9e\x82\x9a\xc7\x4c\xa5\x8d\x64\xb5\xdb\x9d\xde\x5c\x9f\x82\x43\x14\x12\x14\x12\x99\xe1\xfc\x4e\x91\x15\xff\xe5\xf7\x05\x00\x00\xff\xff\xd0\x66\x8a\xf7\x4d\x00\x00\x00") + +func _000002_add_last_ens_clock_valueUpSqlBytes() ([]byte, error) { + return bindataRead( + __000002_add_last_ens_clock_valueUpSql, + "000002_add_last_ens_clock_value.up.sql", + ) +} + +func _000002_add_last_ens_clock_valueUpSql() (*asset, error) { + bytes, err := _000002_add_last_ens_clock_valueUpSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "000002_add_last_ens_clock_value.up.sql", size: 77, mode: os.FileMode(0644), modTime: time.Unix(1580459768, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4d, 0x3, 0x8f, 0xd5, 0x85, 0x83, 0x47, 0xbe, 0xf9, 0x82, 0x7e, 0x81, 0xa4, 0xbd, 0xaa, 0xd5, 0x98, 0x18, 0x5, 0x2d, 0x82, 0x42, 0x3b, 0x3, 0x50, 0xc3, 0x1e, 0x84, 0x35, 0xf, 0xb6, 0x2b}} + return a, nil +} + var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x8f\xbb\x6e\xc3\x30\x0c\x45\x77\x7f\xc5\x45\x96\x2c\xb5\xb4\x74\xea\xd6\xb1\x7b\x7f\x80\x91\x68\x89\x88\x1e\xae\x48\xe7\xf1\xf7\x85\xd3\x02\xcd\xd6\xf5\x00\xe7\xf0\xd2\x7b\x7c\x66\x51\x2c\x52\x18\xa2\x68\x1c\x58\x95\xc6\x1d\x27\x0e\xb4\x29\xe3\x90\xc4\xf2\x76\x72\xa1\x57\xaf\x46\xb6\xe9\x2c\xd5\x57\x49\x83\x8c\xfd\xe5\xf5\x30\x79\x8f\x40\xed\x68\xc8\xd4\x62\xe1\x47\x4b\xa1\x46\xc3\xa4\x25\x5c\xc5\x32\x08\xeb\xe0\x45\x6e\x0e\xef\x86\xc2\xa4\x06\xcb\x64\x47\x85\x65\x46\x20\xe5\x3d\xb3\xf4\x81\xd4\xe7\x93\xb4\x48\x46\x6e\x47\x1f\xcb\x13\xd9\x17\x06\x2a\x85\x23\x96\xd1\xeb\xc3\x55\xaa\x8c\x28\x83\x83\xf5\x71\x7f\x01\xa9\xb2\xa1\x51\x65\xdd\xfd\x4c\x17\x46\xeb\xbf\xe7\x41\x2d\xfe\xff\x11\xae\x7d\x9c\x15\xa4\xe0\xdb\xca\xc1\x38\xba\x69\x5a\x29\x9c\x29\x31\xf4\xab\x88\xf1\x34\x79\x9f\xfa\x5b\xe2\xc6\xbb\xf5\xbc\x71\x5e\xcf\x09\x3f\x35\xe9\x4d\x31\x77\x38\xe7\xff\x80\x4b\x1d\x6e\xfa\x0e\x00\x00\xff\xff\x9d\x60\x3d\x88\x79\x01\x00\x00") func docGoBytes() ([]byte, error) { @@ -126,7 +168,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1578669164, 0)} + info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xef, 0xaf, 0xdf, 0xcf, 0x65, 0xae, 0x19, 0xfc, 0x9d, 0x29, 0xc1, 0x91, 0xaf, 0xb5, 0xd5, 0xb1, 0x56, 0xf3, 0xee, 0xa8, 0xba, 0x13, 0x65, 0xdb, 0xab, 0xcf, 0x4e, 0xac, 0x92, 0xe9, 0x60, 0xf1}} return a, nil } @@ -226,6 +268,10 @@ var _bindata = map[string]func() (*asset, error){ "000001_init.up.db.sql": _000001_initUpDbSql, + "000002_add_last_ens_clock_value.down.sql": _000002_add_last_ens_clock_valueDownSql, + + "000002_add_last_ens_clock_value.up.sql": _000002_add_last_ens_clock_valueUpSql, + "doc.go": docGo, } @@ -270,9 +316,11 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}}, - "000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, - "doc.go": &bintree{docGo, map[string]*bintree{}}, + "000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}}, + "000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, + "000002_add_last_ens_clock_value.down.sql": &bintree{_000002_add_last_ens_clock_valueDownSql, map[string]*bintree{}}, + "000002_add_last_ens_clock_value.up.sql": &bintree{_000002_add_last_ens_clock_valueUpSql, map[string]*bintree{}}, + "doc.go": &bintree{docGo, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory. diff --git a/protocol/migrations/sqlite/000002_add_last_ens_clock_value.down.sql b/protocol/migrations/sqlite/000002_add_last_ens_clock_value.down.sql new file mode 100644 index 000000000..e69de29bb diff --git a/protocol/migrations/sqlite/000002_add_last_ens_clock_value.up.sql b/protocol/migrations/sqlite/000002_add_last_ens_clock_value.up.sql new file mode 100644 index 000000000..2ab3b49af --- /dev/null +++ b/protocol/migrations/sqlite/000002_add_last_ens_clock_value.up.sql @@ -0,0 +1 @@ +ALTER TABLE contacts ADD COLUMN last_ens_clock_value INT NOT NULL DEFAULT 0; diff --git a/protocol/transport/waku/migrations/migrations.go b/protocol/transport/waku/migrations/migrations.go index 8809b9b4c..5af483398 100644 --- a/protocol/transport/waku/migrations/migrations.go +++ b/protocol/transport/waku/migrations/migrations.go @@ -86,7 +86,7 @@ func _1561059284_add_waku_keysDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059284_add_waku_keys.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1578604329, 0)} + info := bindataFileInfo{name: "1561059284_add_waku_keys.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1579069853, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe5, 0x2a, 0x7e, 0x9, 0xa3, 0xdd, 0xc6, 0x3, 0xfa, 0xaa, 0x98, 0xa0, 0x26, 0x5e, 0x67, 0x43, 0xe6, 0x20, 0xfd, 0x10, 0xfd, 0x60, 0x89, 0x17, 0x13, 0x87, 0x1b, 0x44, 0x36, 0x79, 0xb6, 0x60}} return a, nil } @@ -106,7 +106,7 @@ func _1561059284_add_waku_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059284_add_waku_keys.up.sql", size: 109, mode: os.FileMode(0644), modTime: time.Unix(1578604337, 0)} + info := bindataFileInfo{name: "1561059284_add_waku_keys.up.sql", size: 109, mode: os.FileMode(0644), modTime: time.Unix(1579069853, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x5c, 0x8, 0x32, 0xef, 0x12, 0x88, 0x21, 0xd, 0x7a, 0x42, 0x4d, 0xe7, 0x2d, 0x6c, 0x99, 0xb6, 0x1, 0xf1, 0xba, 0x2c, 0x40, 0x8d, 0xa9, 0x4b, 0xe6, 0xc4, 0x21, 0xec, 0x47, 0x6b, 0xf7}} return a, nil } @@ -126,7 +126,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1578604293, 0)} + info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1579069853, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x23, 0x6a, 0xc1, 0xce, 0x94, 0xf6, 0xef, 0xf1, 0x97, 0x95, 0xb, 0x35, 0xaf, 0x5f, 0xe7, 0x5f, 0xac, 0x6e, 0xb8, 0xab, 0xba, 0xb5, 0x35, 0x97, 0x22, 0x36, 0x11, 0xce, 0x44, 0xfc, 0xfa, 0xac}} return a, nil } diff --git a/protocol/transport/whisper/migrations/migrations.go b/protocol/transport/whisper/migrations/migrations.go index 7fdff2a38..368797f1a 100644 --- a/protocol/transport/whisper/migrations/migrations.go +++ b/protocol/transport/whisper/migrations/migrations.go @@ -86,7 +86,7 @@ func _1561059285_add_whisper_keysDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059285_add_whisper_keys.down.sql", size: 25, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561059285_add_whisper_keys.down.sql", size: 25, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb9, 0x31, 0x3f, 0xce, 0xfa, 0x44, 0x36, 0x1b, 0xb0, 0xec, 0x5d, 0xb, 0x90, 0xb, 0x21, 0x4f, 0xd5, 0xe5, 0x50, 0xed, 0xc7, 0x43, 0xdf, 0x83, 0xb4, 0x3a, 0xc1, 0x55, 0x2e, 0x53, 0x7c, 0x67}} return a, nil } @@ -106,7 +106,7 @@ func _1561059285_add_whisper_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059285_add_whisper_keys.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561059285_add_whisper_keys.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x25, 0x41, 0xc, 0x92, 0xdd, 0x9e, 0xff, 0x5d, 0xd0, 0x93, 0xe4, 0x24, 0x50, 0x29, 0xcf, 0xc6, 0xf7, 0x49, 0x3c, 0x73, 0xd9, 0x8c, 0xfa, 0xf2, 0xcf, 0xf6, 0x6f, 0xbc, 0x31, 0xe6, 0xf7, 0xe2}} return a, nil } @@ -126,7 +126,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x23, 0x6a, 0xc1, 0xce, 0x94, 0xf6, 0xef, 0xf1, 0x97, 0x95, 0xb, 0x35, 0xaf, 0x5f, 0xe7, 0x5f, 0xac, 0x6e, 0xb8, 0xab, 0xba, 0xb5, 0x35, 0x97, 0x22, 0x36, 0x11, 0xce, 0x44, 0xfc, 0xfa, 0xac}} return a, nil } diff --git a/services/ext/api.go b/services/ext/api.go index 3d3188c85..cd41cf6bb 100644 --- a/services/ext/api.go +++ b/services/ext/api.go @@ -12,9 +12,7 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/status-im/status-go/eth-node/types" - enstypes "github.com/status-im/status-go/eth-node/types/ens" "github.com/status-im/status-go/mailserver" - "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol" "github.com/status-im/status-go/protocol/encryption/multidevice" "github.com/status-im/status-go/protocol/transport" @@ -24,9 +22,6 @@ import ( const ( // defaultRequestTimeout is the default request timeout in seconds defaultRequestTimeout = 10 - - // ensContractAddress is the address of the ENS resolver - ensContractAddress = "0x314159265dd8dbb310642f98f50c066173c1259b" ) var ( @@ -308,11 +303,6 @@ func (api *PublicAPI) SetInstallationMetadata(installationID string, data *multi return api.service.messenger.SetInstallationMetadata(installationID, data) } -// VerifyENSNames takes a list of ensdetails and returns whether they match the public key specified -func (api *PublicAPI) VerifyENSNames(details []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error) { - return api.service.messenger.VerifyENSNames(params.MainnetEthereumNetworkURL, ensContractAddress, details) -} - type ApplicationMessagesResponse struct { Messages []*protocol.Message `json:"messages"` Cursor string `json:"cursor"` diff --git a/services/ext/service.go b/services/ext/service.go index 547bc5cc2..6998d3829 100644 --- a/services/ext/service.go +++ b/services/ext/service.go @@ -173,6 +173,7 @@ func (s *Service) StartMessenger() error { s.cancelMessenger = make(chan struct{}) go s.retrieveMessagesLoop(time.Second, s.cancelMessenger) go s.verifyTransactionLoop(30*time.Second, s.cancelMessenger) + go s.verifyENSLoop(30*time.Second, s.cancelMessenger) return s.messenger.Start() } @@ -261,6 +262,35 @@ func (c *verifyTransactionClient) TransactionByHash(ctx context.Context, hash ty return coremessage, coretypes.TransactionStatus(receipt.Status), nil } +func (s *Service) verifyENSLoop(tick time.Duration, cancel <-chan struct{}) { + if s.config.VerifyENSURL == "" || s.config.VerifyENSContractAddress == "" { + log.Warn("not starting ENS loop") + return + } + + ticker := time.NewTicker(tick) + defer ticker.Stop() + + ctx, cancelVerifyENS := context.WithCancel(context.Background()) + + for { + select { + case <-ticker.C: + response, err := s.messenger.VerifyENSNames(ctx, s.config.VerifyENSURL, s.config.VerifyENSContractAddress) + if err != nil { + log.Error("failed to validate ens", "err", err) + continue + } + if !response.IsEmpty() { + PublisherSignalHandler{}.NewMessages(response) + } + case <-cancel: + cancelVerifyENS() + return + } + } +} + func (s *Service) verifyTransactionLoop(tick time.Duration, cancel <-chan struct{}) { if s.config.VerifyTransactionURL == "" { log.Warn("not starting transaction loop") diff --git a/vendor/github.com/status-im/status-go/protocol/contact.go b/vendor/github.com/status-im/status-go/protocol/contact.go index a12bc12c8..f36cc62a8 100644 --- a/vendor/github.com/status-im/status-go/protocol/contact.go +++ b/vendor/github.com/status-im/status-go/protocol/contact.go @@ -38,7 +38,12 @@ type Contact struct { // EnsVerified whether we verified the name of the contact ENSVerified bool `json:"ensVerified"` // EnsVerifiedAt the time we last verified the name - ENSVerifiedAt int64 `json:"ensVerifiedAt"` + ENSVerifiedAt uint64 `json:"ensVerifiedAt"` + // LastENSClockValue is the last clock value of when we + // received an ENS name for the user + LastENSClockValue uint64 `json:"lastENSClockValue"` + // ENSVerificationRetries is how many times we retried the ENS + ENSVerificationRetries uint64 `json:"ensVerificationRetries"` // Generated username name of the contact Alias string `json:"alias,omitempty"` // Identicon generated from public key @@ -76,6 +81,14 @@ func (c Contact) IsBlocked() bool { return existsInStringSlice(c.SystemTags, contactBlocked) } +func (c *Contact) ResetENSVerification(clock uint64, name string) { + c.ENSVerifiedAt = 0 + c.ENSVerified = false + c.ENSVerificationRetries = 0 + c.LastENSClockValue = clock + c.Name = name +} + // existsInStringSlice checks if a string is in a set. func existsInStringSlice(set []string, find string) bool { for _, s := range set { diff --git a/vendor/github.com/status-im/status-go/protocol/encryption/migrations/migrations.go b/vendor/github.com/status-im/status-go/protocol/encryption/migrations/migrations.go index ea0a151ab..3e93c617c 100644 --- a/vendor/github.com/status-im/status-go/protocol/encryption/migrations/migrations.go +++ b/vendor/github.com/status-im/status-go/protocol/encryption/migrations/migrations.go @@ -100,7 +100,7 @@ func _1536754952_initial_schemaDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1536754952_initial_schema.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1536754952_initial_schema.down.sql", size: 83, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x44, 0xcf, 0x76, 0x71, 0x1f, 0x5e, 0x9a, 0x43, 0xd8, 0xcd, 0xb8, 0xc3, 0x70, 0xc3, 0x7f, 0xfc, 0x90, 0xb4, 0x25, 0x1e, 0xf4, 0x66, 0x20, 0xb8, 0x33, 0x7e, 0xb0, 0x76, 0x1f, 0xc, 0xc0, 0x75}} return a, nil } @@ -120,7 +120,7 @@ func _1536754952_initial_schemaUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1536754952_initial_schema.up.sql", size: 962, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1536754952_initial_schema.up.sql", size: 962, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xea, 0x90, 0x5a, 0x59, 0x3e, 0x3, 0xe2, 0x3c, 0x81, 0x42, 0xcd, 0x4c, 0x9a, 0xe8, 0xda, 0x93, 0x2b, 0x70, 0xa4, 0xd5, 0x29, 0x3e, 0xd5, 0xc9, 0x27, 0xb6, 0xb7, 0x65, 0xff, 0x0, 0xcb, 0xde}} return a, nil } @@ -140,7 +140,7 @@ func _1539249977_update_ratchet_infoDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1539249977_update_ratchet_info.down.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1539249977_update_ratchet_info.down.sql", size: 311, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1, 0xa4, 0xeb, 0xa0, 0xe6, 0xa0, 0xd4, 0x48, 0xbb, 0xad, 0x6f, 0x7d, 0x67, 0x8c, 0xbd, 0x25, 0xde, 0x1f, 0x73, 0x9a, 0xbb, 0xa8, 0xc9, 0x30, 0xb7, 0xa9, 0x7c, 0xaf, 0xb5, 0x1, 0x61, 0xdd}} return a, nil } @@ -160,7 +160,7 @@ func _1539249977_update_ratchet_infoUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1539249977_update_ratchet_info.up.sql", size: 368, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1539249977_update_ratchet_info.up.sql", size: 368, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc, 0x8e, 0xbf, 0x6f, 0xa, 0xc0, 0xe1, 0x3c, 0x42, 0x28, 0x88, 0x1d, 0xdb, 0xba, 0x1c, 0x83, 0xec, 0xba, 0xd3, 0x5f, 0x5c, 0x77, 0x5e, 0xa7, 0x46, 0x36, 0xec, 0x69, 0xa, 0x4b, 0x17, 0x79}} return a, nil } @@ -180,7 +180,7 @@ func _1540715431_add_versionDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1540715431_add_version.down.sql", size: 127, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1540715431_add_version.down.sql", size: 127, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x9, 0x4, 0xe3, 0x76, 0x2e, 0xb8, 0x9, 0x23, 0xf0, 0x70, 0x93, 0xc4, 0x50, 0xe, 0x9d, 0x84, 0x22, 0x8c, 0x94, 0xd3, 0x24, 0x9, 0x9a, 0xc1, 0xa1, 0x48, 0x45, 0xfd, 0x40, 0x6e, 0xe6}} return a, nil } @@ -200,7 +200,7 @@ func _1540715431_add_versionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1540715431_add_version.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1540715431_add_version.up.sql", size: 265, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xc7, 0x4c, 0x36, 0x96, 0xdf, 0x16, 0x10, 0xa6, 0x27, 0x1a, 0x79, 0x8b, 0x42, 0x83, 0x23, 0xc, 0x7e, 0xb6, 0x3d, 0x2, 0xda, 0xa4, 0xb4, 0xd, 0x27, 0x55, 0xba, 0xdc, 0xb2, 0x88, 0x8f, 0xa6}} return a, nil } @@ -220,7 +220,7 @@ func _1541164797_add_installationsDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1541164797_add_installations.down.sql", size: 26, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1541164797_add_installations.down.sql", size: 26, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0xfd, 0xe6, 0xd8, 0xca, 0x3b, 0x38, 0x18, 0xee, 0x0, 0x5f, 0x36, 0x9e, 0x1e, 0xd, 0x19, 0x3e, 0xb4, 0x73, 0x53, 0xe9, 0xa5, 0xac, 0xdd, 0xa1, 0x2f, 0xc7, 0x6c, 0xa8, 0xd9, 0xa, 0x88}} return a, nil } @@ -240,7 +240,7 @@ func _1541164797_add_installationsUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1541164797_add_installations.up.sql", size: 216, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1541164797_add_installations.up.sql", size: 216, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2d, 0x18, 0x26, 0xb8, 0x88, 0x47, 0xdb, 0x83, 0xcc, 0xb6, 0x9d, 0x1c, 0x1, 0xae, 0x2f, 0xde, 0x97, 0x82, 0x3, 0x30, 0xa8, 0x63, 0xa1, 0x78, 0x4b, 0xa5, 0x9, 0x8, 0x75, 0xa2, 0x57, 0x81}} return a, nil } @@ -260,7 +260,7 @@ func _1558084410_add_secretDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558084410_add_secret.down.sql", size: 56, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558084410_add_secret.down.sql", size: 56, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x49, 0xb, 0x65, 0xdf, 0x59, 0xbf, 0xe9, 0x5, 0x5b, 0x6f, 0xd5, 0x3a, 0xb7, 0x57, 0xe8, 0x78, 0x38, 0x73, 0x53, 0x57, 0xf7, 0x24, 0x4, 0xe4, 0xa2, 0x49, 0x22, 0xa2, 0xc6, 0xfd, 0x80, 0xa4}} return a, nil } @@ -280,7 +280,7 @@ func _1558084410_add_secretUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558084410_add_secret.up.sql", size: 301, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558084410_add_secret.up.sql", size: 301, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xf5, 0x32, 0x36, 0x8e, 0x47, 0xb0, 0x8f, 0xc1, 0xc6, 0xf7, 0xc6, 0x9f, 0x2d, 0x44, 0x75, 0x2b, 0x26, 0xec, 0x6, 0xa0, 0x7b, 0xa5, 0xbd, 0xc8, 0x76, 0x8a, 0x82, 0x68, 0x2, 0x42, 0xb5, 0xf4}} return a, nil } @@ -300,7 +300,7 @@ func _1558588866_add_versionDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558588866_add_version.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558588866_add_version.down.sql", size: 47, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xde, 0x52, 0x34, 0x3c, 0x46, 0x4a, 0xf0, 0x72, 0x47, 0x6f, 0x49, 0x5c, 0xc7, 0xf9, 0x32, 0xce, 0xc4, 0x3d, 0xfd, 0x61, 0xa1, 0x8b, 0x8f, 0xf2, 0x31, 0x34, 0xde, 0x15, 0x49, 0xa6, 0xde, 0xb9}} return a, nil } @@ -320,7 +320,7 @@ func _1558588866_add_versionUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1558588866_add_version.up.sql", size: 57, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1558588866_add_version.up.sql", size: 57, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0xea, 0x64, 0x39, 0x61, 0x20, 0x83, 0x83, 0xb, 0x2e, 0x79, 0x64, 0xb, 0x53, 0xfa, 0xfe, 0xc6, 0xf7, 0x67, 0x42, 0xd3, 0x4f, 0xdc, 0x7e, 0x30, 0x32, 0xe8, 0x14, 0x41, 0xe9, 0xe7, 0x3b}} return a, nil } @@ -340,7 +340,7 @@ func _1559627659_add_contact_codeDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1559627659_add_contact_code.down.sql", size: 32, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1559627659_add_contact_code.down.sql", size: 32, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5d, 0x64, 0x6d, 0xce, 0x24, 0x42, 0x20, 0x8d, 0x4f, 0x37, 0xaa, 0x9d, 0xc, 0x57, 0x98, 0xc1, 0xd1, 0x1a, 0x34, 0xcd, 0x9f, 0x8f, 0x34, 0x86, 0xb3, 0xd3, 0xdc, 0xf1, 0x7d, 0xe5, 0x1b, 0x6e}} return a, nil } @@ -360,7 +360,7 @@ func _1559627659_add_contact_codeUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1559627659_add_contact_code.up.sql", size: 198, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1559627659_add_contact_code.up.sql", size: 198, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x16, 0xf6, 0xc2, 0x62, 0x9c, 0xd2, 0xc9, 0x1e, 0xd8, 0xea, 0xaa, 0xea, 0x95, 0x8f, 0x89, 0x6a, 0x85, 0x5d, 0x9d, 0x99, 0x78, 0x3c, 0x90, 0x66, 0x99, 0x3e, 0x4b, 0x19, 0x62, 0xfb, 0x31, 0x4d}} return a, nil } @@ -380,7 +380,7 @@ func _1561368210_add_installation_metadataDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561368210_add_installation_metadata.down.sql", size: 35, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561368210_add_installation_metadata.down.sql", size: 35, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa8, 0xde, 0x3f, 0xd2, 0x4a, 0x50, 0x98, 0x56, 0xe3, 0xc0, 0xcd, 0x9d, 0xb0, 0x34, 0x3b, 0xe5, 0x62, 0x18, 0xb5, 0x20, 0xc9, 0x3e, 0xdc, 0x6a, 0x40, 0x36, 0x66, 0xea, 0x51, 0x8c, 0x71, 0xf5}} return a, nil } @@ -400,7 +400,7 @@ func _1561368210_add_installation_metadataUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561368210_add_installation_metadata.up.sql", size: 267, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561368210_add_installation_metadata.up.sql", size: 267, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb4, 0x71, 0x8f, 0x29, 0xb1, 0xaa, 0xd6, 0xd1, 0x8c, 0x17, 0xef, 0x6c, 0xd5, 0x80, 0xb8, 0x2c, 0xc3, 0xfe, 0xec, 0x24, 0x4d, 0xc8, 0x25, 0xd3, 0xb4, 0xcd, 0xa9, 0xac, 0x63, 0x61, 0xb2, 0x9c}} return a, nil } @@ -420,7 +420,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xef, 0xaf, 0xdf, 0xcf, 0x65, 0xae, 0x19, 0xfc, 0x9d, 0x29, 0xc1, 0x91, 0xaf, 0xb5, 0xd5, 0xb1, 0x56, 0xf3, 0xee, 0xa8, 0xba, 0x13, 0x65, 0xdb, 0xab, 0xcf, 0x4e, 0xac, 0x92, 0xe9, 0x60, 0xf1}} return a, nil } diff --git a/vendor/github.com/status-im/status-go/protocol/ens.go b/vendor/github.com/status-im/status-go/protocol/ens.go new file mode 100644 index 000000000..2166be49e --- /dev/null +++ b/vendor/github.com/status-im/status-go/protocol/ens.go @@ -0,0 +1,63 @@ +package protocol + +import ( + "math" + "strings" +) + +// maxRetries is the maximum number of attemps we do before giving up +const maxRetries uint64 = 11 + +// ENSBackoffTimeMs is the step of the exponential backoff +// we retry roughtly for 17 hours after receiving the message 2^11 * 30000 +const ENSBackoffTimeMs uint64 = 30000 + +// We calculate if it's too early to retry, by exponentially backing off +func verifiedENSRecentlyEnough(now, verifiedAt, retries uint64) bool { + return now < verifiedAt+ENSBackoffTimeMs*retries*uint64(math.Exp2(float64(retries))) +} + +func shouldENSBeVerified(c *Contact, now uint64) bool { + if c.Name == "" { + return false + } + + if c.ENSVerified { + return false + } + + if c.ENSVerificationRetries >= maxRetries { + return false + } + + if verifiedENSRecentlyEnough(now, c.ENSVerifiedAt, c.ENSVerificationRetries) { + return false + } + + if !strings.HasSuffix(c.Name, ".eth") { + return false + } + + return true +} + +// This should trigger re-verification of the ENS name for this contact +func hasENSNameChanged(c *Contact, newName string, clockValue uint64) bool { + if c.LastENSClockValue > clockValue { + return false + } + + if newName == "" { + return false + } + + if !strings.HasSuffix(newName, ".eth") { + return false + } + + if newName == c.Name { + return false + } + + return true +} diff --git a/vendor/github.com/status-im/status-go/protocol/message_handler.go b/vendor/github.com/status-im/status-go/protocol/message_handler.go index 7cda081db..3e82380bd 100644 --- a/vendor/github.com/status-im/status-go/protocol/message_handler.go +++ b/vendor/github.com/status-im/status-go/protocol/message_handler.go @@ -337,6 +337,13 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error { state.ModifiedChats[chat.ID] = true state.AllChats[chat.ID] = chat + contact := state.CurrentMessageState.Contact + if hasENSNameChanged(contact, receivedMessage.EnsName, receivedMessage.Clock) { + contact.ResetENSVerification(receivedMessage.Clock, receivedMessage.EnsName) + state.ModifiedContacts[contact.ID] = true + state.AllContacts[contact.ID] = contact + } + // Add to response if receivedMessage != nil { state.Response.Messages = append(state.Response.Messages, receivedMessage) diff --git a/vendor/github.com/status-im/status-go/protocol/messenger.go b/vendor/github.com/status-im/status-go/protocol/messenger.go index 9428a4ac5..45557ac86 100644 --- a/vendor/github.com/status-im/status-go/protocol/messenger.go +++ b/vendor/github.com/status-im/status-go/protocol/messenger.go @@ -2041,33 +2041,45 @@ func Identicon(id string) (string, error) { } // VerifyENSNames verifies that a registered ENS name matches the expected public key -func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetails []enstypes.ENSDetails) (map[string]enstypes.ENSResponse, error) { +func (m *Messenger) VerifyENSNames(ctx context.Context, rpcEndpoint, contractAddress string) (*MessengerResponse, error) { m.mutex.Lock() defer m.mutex.Unlock() + + m.logger.Debug("verifying ENS Names", zap.String("endpoint", rpcEndpoint)) verifier := m.node.NewENSVerifier(m.logger) + var response MessengerResponse + + var ensDetails []enstypes.ENSDetails + + now := m.getTimesource().GetCurrentTime() + for _, contact := range m.allContacts { + if shouldENSBeVerified(contact, now) { + ensDetails = append(ensDetails, enstypes.ENSDetails{ + PublicKeyString: contact.ID[2:], + Name: contact.Name, + }) + } + } + ensResponse, err := verifier.CheckBatch(ensDetails, rpcEndpoint, contractAddress) if err != nil { return nil, err } - // Update contacts - var contacts []*Contact for _, details := range ensResponse { - if details.Error == nil { - contact, ok := m.allContacts["0x"+details.PublicKeyString] - if !ok { - contact, err = buildContact(details.PublicKey) - if err != nil { - return nil, err - } - } - contact.ENSVerified = details.Verified - contact.ENSVerifiedAt = details.VerifiedAt - contact.Name = details.Name + contact, ok := m.allContacts["0x"+details.PublicKeyString] + if !ok { + return nil, errors.New("contact must be existing") + } + m.logger.Debug("verifying ENS Name", zap.Any("details", details), zap.Any("contact", contact)) + + contact.ENSVerifiedAt = uint64(details.VerifiedAt) + + if details.Error == nil { + contact.ENSVerified = details.Verified m.allContacts[contact.ID] = contact - contacts = append(contacts, contact) } else { m.logger.Warn("Failed to resolve ens name", zap.String("name", details.Name), @@ -2075,16 +2087,17 @@ func (m *Messenger) VerifyENSNames(rpcEndpoint, contractAddress string, ensDetai zap.Error(details.Error), ) } + response.Contacts = append(response.Contacts, contact) } - if len(contacts) != 0 { - err = m.persistence.SaveContacts(contacts) + if len(response.Contacts) != 0 { + err = m.persistence.SaveContacts(response.Contacts) if err != nil { return nil, err } } - return ensResponse, nil + return &response, nil } // GenerateAlias name returns the generated name given a public key hex encoded prefixed with 0x diff --git a/vendor/github.com/status-im/status-go/protocol/migrations/migrations.go b/vendor/github.com/status-im/status-go/protocol/migrations/migrations.go index ff08e31f9..9e628220e 100644 --- a/vendor/github.com/status-im/status-go/protocol/migrations/migrations.go +++ b/vendor/github.com/status-im/status-go/protocol/migrations/migrations.go @@ -2,6 +2,8 @@ // sources: // 000001_init.down.db.sql (65B) // 000001_init.up.db.sql (2.719kB) +// 000002_add_last_ens_clock_value.down.sql (0) +// 000002_add_last_ens_clock_value.up.sql (77B) // doc.go (377B) package migrations @@ -86,7 +88,7 @@ func _000001_initDownDbSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1578756765, 0)} + info := bindataFileInfo{name: "000001_init.down.db.sql", size: 65, mode: os.FileMode(0644), modTime: time.Unix(1578682784, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x5e, 0xbb, 0x3f, 0x1, 0x75, 0x19, 0x70, 0x86, 0xa7, 0x34, 0x40, 0x17, 0x34, 0x3e, 0x18, 0x51, 0x79, 0xd4, 0x22, 0xad, 0x8f, 0x80, 0xcc, 0xa6, 0xcc, 0x6, 0x2b, 0x62, 0x2, 0x47, 0xba, 0xf9}} return a, nil } @@ -106,11 +108,51 @@ func _000001_initUpDbSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2719, mode: os.FileMode(0644), modTime: time.Unix(1578756765, 0)} + info := bindataFileInfo{name: "000001_init.up.db.sql", size: 2719, mode: os.FileMode(0644), modTime: time.Unix(1578682784, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x60, 0xdc, 0xeb, 0xe, 0xc2, 0x4f, 0x75, 0xa, 0xf6, 0x3e, 0xc7, 0xc4, 0x4, 0xe2, 0xe1, 0xa4, 0x73, 0x2f, 0x4a, 0xad, 0x1a, 0x0, 0xc3, 0x93, 0x9d, 0x77, 0x3e, 0x31, 0x91, 0x77, 0x2e, 0xc8}} return a, nil } +var __000002_add_last_ens_clock_valueDownSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x01\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00") + +func _000002_add_last_ens_clock_valueDownSqlBytes() ([]byte, error) { + return bindataRead( + __000002_add_last_ens_clock_valueDownSql, + "000002_add_last_ens_clock_value.down.sql", + ) +} + +func _000002_add_last_ens_clock_valueDownSql() (*asset, error) { + bytes, err := _000002_add_last_ens_clock_valueDownSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "000002_add_last_ens_clock_value.down.sql", size: 0, mode: os.FileMode(0644), modTime: time.Unix(1580459788, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55}} + return a, nil +} + +var __000002_add_last_ens_clock_valueUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x04\xc0\x41\x0a\x85\x20\x10\x06\xe0\xfd\x3b\xc5\x7f\x84\xb7\x6f\x35\xa5\x41\x30\x8d\x10\xe3\x5a\x64\x70\x95\xe8\x42\xeb\xfc\x7d\xc4\xea\x2f\x28\xad\xec\x61\xbd\xcd\x6c\x73\x80\x9c\xc3\x16\x38\x9e\x82\x9a\xc7\x4c\xa5\x8d\x64\xb5\xdb\x9d\xde\x5c\x9f\x82\x43\x14\x12\x14\x12\x99\xe1\xfc\x4e\x91\x15\xff\xe5\xf7\x05\x00\x00\xff\xff\xd0\x66\x8a\xf7\x4d\x00\x00\x00") + +func _000002_add_last_ens_clock_valueUpSqlBytes() ([]byte, error) { + return bindataRead( + __000002_add_last_ens_clock_valueUpSql, + "000002_add_last_ens_clock_value.up.sql", + ) +} + +func _000002_add_last_ens_clock_valueUpSql() (*asset, error) { + bytes, err := _000002_add_last_ens_clock_valueUpSqlBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "000002_add_last_ens_clock_value.up.sql", size: 77, mode: os.FileMode(0644), modTime: time.Unix(1580459768, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x4d, 0x3, 0x8f, 0xd5, 0x85, 0x83, 0x47, 0xbe, 0xf9, 0x82, 0x7e, 0x81, 0xa4, 0xbd, 0xaa, 0xd5, 0x98, 0x18, 0x5, 0x2d, 0x82, 0x42, 0x3b, 0x3, 0x50, 0xc3, 0x1e, 0x84, 0x35, 0xf, 0xb6, 0x2b}} + return a, nil +} + var _docGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x84\x8f\xbb\x6e\xc3\x30\x0c\x45\x77\x7f\xc5\x45\x96\x2c\xb5\xb4\x74\xea\xd6\xb1\x7b\x7f\x80\x91\x68\x89\x88\x1e\xae\x48\xe7\xf1\xf7\x85\xd3\x02\xcd\xd6\xf5\x00\xe7\xf0\xd2\x7b\x7c\x66\x51\x2c\x52\x18\xa2\x68\x1c\x58\x95\xc6\x1d\x27\x0e\xb4\x29\xe3\x90\xc4\xf2\x76\x72\xa1\x57\xaf\x46\xb6\xe9\x2c\xd5\x57\x49\x83\x8c\xfd\xe5\xf5\x30\x79\x8f\x40\xed\x68\xc8\xd4\x62\xe1\x47\x4b\xa1\x46\xc3\xa4\x25\x5c\xc5\x32\x08\xeb\xe0\x45\x6e\x0e\xef\x86\xc2\xa4\x06\xcb\x64\x47\x85\x65\x46\x20\xe5\x3d\xb3\xf4\x81\xd4\xe7\x93\xb4\x48\x46\x6e\x47\x1f\xcb\x13\xd9\x17\x06\x2a\x85\x23\x96\xd1\xeb\xc3\x55\xaa\x8c\x28\x83\x83\xf5\x71\x7f\x01\xa9\xb2\xa1\x51\x65\xdd\xfd\x4c\x17\x46\xeb\xbf\xe7\x41\x2d\xfe\xff\x11\xae\x7d\x9c\x15\xa4\xe0\xdb\xca\xc1\x38\xba\x69\x5a\x29\x9c\x29\x31\xf4\xab\x88\xf1\x34\x79\x9f\xfa\x5b\xe2\xc6\xbb\xf5\xbc\x71\x5e\xcf\x09\x3f\x35\xe9\x4d\x31\x77\x38\xe7\xff\x80\x4b\x1d\x6e\xfa\x0e\x00\x00\xff\xff\x9d\x60\x3d\x88\x79\x01\x00\x00") func docGoBytes() ([]byte, error) { @@ -126,7 +168,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1578669164, 0)} + info := bindataFileInfo{name: "doc.go", size: 377, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xef, 0xaf, 0xdf, 0xcf, 0x65, 0xae, 0x19, 0xfc, 0x9d, 0x29, 0xc1, 0x91, 0xaf, 0xb5, 0xd5, 0xb1, 0x56, 0xf3, 0xee, 0xa8, 0xba, 0x13, 0x65, 0xdb, 0xab, 0xcf, 0x4e, 0xac, 0x92, 0xe9, 0x60, 0xf1}} return a, nil } @@ -226,6 +268,10 @@ var _bindata = map[string]func() (*asset, error){ "000001_init.up.db.sql": _000001_initUpDbSql, + "000002_add_last_ens_clock_value.down.sql": _000002_add_last_ens_clock_valueDownSql, + + "000002_add_last_ens_clock_value.up.sql": _000002_add_last_ens_clock_valueUpSql, + "doc.go": docGo, } @@ -270,9 +316,11 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}}, - "000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, - "doc.go": &bintree{docGo, map[string]*bintree{}}, + "000001_init.down.db.sql": &bintree{_000001_initDownDbSql, map[string]*bintree{}}, + "000001_init.up.db.sql": &bintree{_000001_initUpDbSql, map[string]*bintree{}}, + "000002_add_last_ens_clock_value.down.sql": &bintree{_000002_add_last_ens_clock_valueDownSql, map[string]*bintree{}}, + "000002_add_last_ens_clock_value.up.sql": &bintree{_000002_add_last_ens_clock_valueUpSql, map[string]*bintree{}}, + "doc.go": &bintree{docGo, map[string]*bintree{}}, }} // RestoreAsset restores an asset under the given directory. diff --git a/vendor/github.com/status-im/status-go/protocol/transport/waku/migrations/migrations.go b/vendor/github.com/status-im/status-go/protocol/transport/waku/migrations/migrations.go index 8809b9b4c..5af483398 100644 --- a/vendor/github.com/status-im/status-go/protocol/transport/waku/migrations/migrations.go +++ b/vendor/github.com/status-im/status-go/protocol/transport/waku/migrations/migrations.go @@ -86,7 +86,7 @@ func _1561059284_add_waku_keysDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059284_add_waku_keys.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1578604329, 0)} + info := bindataFileInfo{name: "1561059284_add_waku_keys.down.sql", size: 22, mode: os.FileMode(0644), modTime: time.Unix(1579069853, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xe5, 0x2a, 0x7e, 0x9, 0xa3, 0xdd, 0xc6, 0x3, 0xfa, 0xaa, 0x98, 0xa0, 0x26, 0x5e, 0x67, 0x43, 0xe6, 0x20, 0xfd, 0x10, 0xfd, 0x60, 0x89, 0x17, 0x13, 0x87, 0x1b, 0x44, 0x36, 0x79, 0xb6, 0x60}} return a, nil } @@ -106,7 +106,7 @@ func _1561059284_add_waku_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059284_add_waku_keys.up.sql", size: 109, mode: os.FileMode(0644), modTime: time.Unix(1578604337, 0)} + info := bindataFileInfo{name: "1561059284_add_waku_keys.up.sql", size: 109, mode: os.FileMode(0644), modTime: time.Unix(1579069853, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xa9, 0x5c, 0x8, 0x32, 0xef, 0x12, 0x88, 0x21, 0xd, 0x7a, 0x42, 0x4d, 0xe7, 0x2d, 0x6c, 0x99, 0xb6, 0x1, 0xf1, 0xba, 0x2c, 0x40, 0x8d, 0xa9, 0x4b, 0xe6, 0xc4, 0x21, 0xec, 0x47, 0x6b, 0xf7}} return a, nil } @@ -126,7 +126,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1578604293, 0)} + info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1579069853, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x23, 0x6a, 0xc1, 0xce, 0x94, 0xf6, 0xef, 0xf1, 0x97, 0x95, 0xb, 0x35, 0xaf, 0x5f, 0xe7, 0x5f, 0xac, 0x6e, 0xb8, 0xab, 0xba, 0xb5, 0x35, 0x97, 0x22, 0x36, 0x11, 0xce, 0x44, 0xfc, 0xfa, 0xac}} return a, nil } diff --git a/vendor/github.com/status-im/status-go/protocol/transport/whisper/migrations/migrations.go b/vendor/github.com/status-im/status-go/protocol/transport/whisper/migrations/migrations.go index 7fdff2a38..368797f1a 100644 --- a/vendor/github.com/status-im/status-go/protocol/transport/whisper/migrations/migrations.go +++ b/vendor/github.com/status-im/status-go/protocol/transport/whisper/migrations/migrations.go @@ -86,7 +86,7 @@ func _1561059285_add_whisper_keysDownSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059285_add_whisper_keys.down.sql", size: 25, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561059285_add_whisper_keys.down.sql", size: 25, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xb9, 0x31, 0x3f, 0xce, 0xfa, 0x44, 0x36, 0x1b, 0xb0, 0xec, 0x5d, 0xb, 0x90, 0xb, 0x21, 0x4f, 0xd5, 0xe5, 0x50, 0xed, 0xc7, 0x43, 0xdf, 0x83, 0xb4, 0x3a, 0xc1, 0x55, 0x2e, 0x53, 0x7c, 0x67}} return a, nil } @@ -106,7 +106,7 @@ func _1561059285_add_whisper_keysUpSql() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "1561059285_add_whisper_keys.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "1561059285_add_whisper_keys.up.sql", size: 112, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x25, 0x41, 0xc, 0x92, 0xdd, 0x9e, 0xff, 0x5d, 0xd0, 0x93, 0xe4, 0x24, 0x50, 0x29, 0xcf, 0xc6, 0xf7, 0x49, 0x3c, 0x73, 0xd9, 0x8c, 0xfa, 0xf2, 0xcf, 0xf6, 0x6f, 0xbc, 0x31, 0xe6, 0xf7, 0xe2}} return a, nil } @@ -126,7 +126,7 @@ func docGo() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1575625435, 0)} + info := bindataFileInfo{name: "doc.go", size: 373, mode: os.FileMode(0644), modTime: time.Unix(1574354941, 0)} a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x23, 0x6a, 0xc1, 0xce, 0x94, 0xf6, 0xef, 0xf1, 0x97, 0x95, 0xb, 0x35, 0xaf, 0x5f, 0xe7, 0x5f, 0xac, 0x6e, 0xb8, 0xab, 0xba, 0xb5, 0x35, 0x97, 0x22, 0x36, 0x11, 0xce, 0x44, 0xfc, 0xfa, 0xac}} return a, nil }