Skip to content

Commit

Permalink
Fix for processing of events.
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanIliev545 committed Jun 13, 2024
1 parent 71f6456 commit 3bc1d1d
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 4 deletions.
138 changes: 136 additions & 2 deletions contracts/generated/ManagementContract/ManagementContract.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions contracts/src/management/ManagementContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ contract ManagementContract is Initializable, OwnableUpgradeable {
event ImportantContractAddressUpdated(string key, address newAddress);
event SequencerEnclaveGranted(address enclaveID);
event SequencerEnclaveRevoked(address enclaveID);
event RollupAdded(bytes32 rollupHash);

// mapping of enclaveID to whether it is attested
mapping(address => bool) private attested;
Expand Down Expand Up @@ -114,6 +115,7 @@ contract ManagementContract is Initializable, OwnableUpgradeable {
require(sequencerEnclave[enclaveID], "enclaveID not a sequencer");

AppendRollup(r);
emit RollupAdded(r.Hash);
}

// InitializeNetworkSecret kickstarts the network secret, can only be called once
Expand Down
14 changes: 12 additions & 2 deletions go/enclave/crosschain/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"errors"
"fmt"
"strings"

"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -108,11 +109,16 @@ func convertLogsToMessages(logs []types.Log, eventName string, messageBusABI abi
messages := make(common.CrossChainMessages, 0)

for _, log := range logs {
if len(log.Topics) != 2 {
return nil, fmt.Errorf("invalid number of topics in log: %d", len(log.Topics))
}

var event MessageBus.MessageBusLogMessagePublished
err := messageBusABI.UnpackIntoInterface(&event, eventName, log.Data)
if err != nil {
return nil, err
}
event.Sender = gethcommon.BytesToAddress(log.Topics[1].Bytes())

msg := createCrossChainMessage(event)
messages = append(messages, msg)
Expand All @@ -137,15 +143,19 @@ func ConvertLogsToValueTransfers(logs []types.Log, eventName string, messageBusA
messages := make(common.ValueTransferEvents, 0)

for _, log := range logs {
if len(log.Topics) != 3 {
return nil, fmt.Errorf("invalid number of topics in log: %d", len(log.Topics))
}

var event MessageBus.MessageBusValueTransfer
err := messageBusABI.UnpackIntoInterface(&event, eventName, log.Data)
if err != nil {
return nil, err
}

messages = append(messages, common.ValueTransferEvent{
Sender: event.Sender,
Receiver: event.Receiver,
Sender: gethcommon.BytesToAddress(log.Topics[1].Bytes()),
Receiver: gethcommon.BytesToAddress(log.Topics[2].Bytes()),
Amount: event.Amount,
Sequence: event.Sequence,
})
Expand Down

0 comments on commit 3bc1d1d

Please sign in to comment.