diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-08-23 15:41:12 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-08-23 18:57:15 +0800 |
commit | 4ee92f2d193225e70c190194d005a6ce80e70236 (patch) | |
tree | 8931c0af267a03b442089cb8ff8b25f643022c5a | |
parent | 79bf69b55687704429e083c22fb62ba931648e7c (diff) | |
download | go-tangerine-4ee92f2d193225e70c190194d005a6ce80e70236.tar.gz go-tangerine-4ee92f2d193225e70c190194d005a6ce80e70236.tar.zst go-tangerine-4ee92f2d193225e70c190194d005a6ce80e70236.zip |
core/types: reject Metro receipts with > 0x01 status bytes
-rw-r--r-- | core/types/receipt.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/core/types/receipt.go b/core/types/receipt.go index 9c49648b4..b54bd7b4f 100644 --- a/core/types/receipt.go +++ b/core/types/receipt.go @@ -108,14 +108,21 @@ func (r *Receipt) DecodeRLP(s *rlp.Stream) error { } // Deserialize based on the first component type. switch { - case kind == rlp.Byte || kind == rlp.String && len(cnt) == 0: - // The first component of metropolis receipts is Byte - // or empty String(byte with 0x00 value). + case kind == rlp.Byte || (kind == rlp.String && len(cnt) == 0): + // The first component of metropolis receipts is Byte (0x01), or the empty + // string (0x80, decoded as a byte with 0x00 value). var metro metropolisReceiptRLP if err := rlp.DecodeBytes(raw, &metro); err != nil { return err } - r.Failed = metro.Status == receiptStatusFailed + switch metro.Status { + case receiptStatusSuccessful: + r.Failed = false + case receiptStatusFailed: + r.Failed = true + default: + return fmt.Errorf("invalid status byte: 0x%x", metro.Status) + } r.CumulativeGasUsed = metro.CumulativeGasUsed r.Bloom = metro.Bloom r.Logs = metro.Logs |