Skip to content

Commit 9ab4e78

Browse files
authored
chore: remove MessageHandle (#6455)
1 parent 395e714 commit 9ab4e78

File tree

4 files changed

+34
-190
lines changed

4 files changed

+34
-190
lines changed

agreement/message.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ package agreement
1818

1919
import (
2020
"github.com/algorand/go-algorand/protocol"
21-
"github.com/algorand/msgp/msgp"
2221
)
2322

2423
// A message represents an internal message which is passed between components
2524
// of the agreement service.
2625
type message struct {
2726
_struct struct{} `codec:","`
2827

29-
// this field is for backwards compatibility with crash state serialized using go-codec prior to explicit unexport.
30-
// should be removed after the next consensus update.
31-
MessageHandle msgp.Raw `codec:"MessageHandle,omitempty"`
3228
// explicitly unexport this field since we can't define serializers for interface{} type
3329
// the only implementation of this is gossip.messageMetadata which doesn't have exported fields to serialize.
3430
messageHandle MessageHandle

agreement/message_test.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,14 @@
1717
package agreement
1818

1919
import (
20-
"encoding/base64"
2120
"testing"
2221

2322
"github.com/stretchr/testify/require"
2423

2524
"github.com/algorand/go-algorand/crypto"
2625
"github.com/algorand/go-algorand/data/basics"
2726
"github.com/algorand/go-algorand/data/committee"
28-
"github.com/algorand/go-algorand/network"
2927
"github.com/algorand/go-algorand/protocol"
30-
"github.com/algorand/go-algorand/test/partitiontest"
3128
)
3229

3330
var poolAddr = basics.Address{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
@@ -83,52 +80,3 @@ func BenchmarkVoteDecoding(b *testing.B) {
8380
decodeVote(msgBytes)
8481
}
8582
}
86-
87-
// TestMessageBackwardCompatibility ensures MessageHandle field can be
88-
// properly decoded from message.
89-
// This test is only needed for agreement state serialization switch from reflection to msgp.
90-
func TestMessageBackwardCompatibility(t *testing.T) {
91-
partitiontest.PartitionTest(t)
92-
93-
type messageMetadata struct {
94-
raw network.IncomingMessage
95-
}
96-
97-
encoded, err := base64.StdEncoding.DecodeString("iaZCdW5kbGWAr0NvbXBvdW5kTWVzc2FnZYKoUHJvcG9zYWyApFZvdGWArU1lc3NhZ2VIYW5kbGWAqFByb3Bvc2FsgKNUYWeiUFC1VW5hdXRoZW50aWNhdGVkQnVuZGxlgLdVbmF1dGhlbnRpY2F0ZWRQcm9wb3NhbICzVW5hdXRoZW50aWNhdGVkVm90ZYCkVm90ZYA=")
98-
require.NoError(t, err)
99-
100-
// run on master f57a276 to get the encoded data for above
101-
// msg := message{
102-
// MessageHandle: &messageMetadata{raw: network.IncomingMessage{Tag: protocol.Tag("mytag"), Data: []byte("some data")}},
103-
// Tag: protocol.ProposalPayloadTag,
104-
// }
105-
106-
// result := protocol.EncodeReflect(&msg)
107-
// fmt.Println(base64.StdEncoding.EncodeToString(result))
108-
109-
// messages for all rounds after this change should not have MessageHandle set so clearing it out and re-encoding/decoding it should yield this
110-
targetMessage := message{
111-
Tag: protocol.ProposalPayloadTag,
112-
}
113-
114-
require.Containsf(t, string(encoded), "MessageHandle", "encoded message does not contain MessageHandle field")
115-
var m1, m2, m3, m4 message
116-
// Both msgp and reflection should decode the message containing old MessageHandle successfully
117-
err = protocol.Decode(encoded, &m1)
118-
require.NoError(t, err)
119-
err = protocol.DecodeReflect(encoded, &m2)
120-
require.NoError(t, err)
121-
// after setting MessageHandle to nil both should re-encode and decode to same values
122-
m1.MessageHandle = nil
123-
m2.MessageHandle = nil
124-
e1 := protocol.Encode(&m1)
125-
e2 := protocol.EncodeReflect(&m2)
126-
require.Equal(t, e1, e2)
127-
require.NotContainsf(t, string(e1), "MessageHandle", "encoded message still contains MessageHandle field")
128-
err = protocol.DecodeReflect(e1, &m3)
129-
require.NoError(t, err)
130-
err = protocol.Decode(e2, &m4)
131-
require.NoError(t, err)
132-
require.Equal(t, m3, m4)
133-
require.Equal(t, m3, targetMessage)
134-
}

agreement/msgp_gen.go

Lines changed: 34 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agreement/proposalTable_test.go

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)