Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove balance of message bus for burned native value. #2192

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions go/enclave/components/batch_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
gethcommon "github.com/ethereum/go-ethereum/common"

smt "github.com/FantasyJony/openzeppelin-merkle-tree-go/standard_merkle_tree"
"github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/core/types"
gethlog "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -142,6 +143,10 @@ func (executor *batchExecutor) ComputeBatch(ctx context.Context, ec *BatchExecut
return nil, ErrNoTransactionsToProcess
}

if err := executor.postProcessState(ec); err != nil {
StefanIliev545 marked this conversation as resolved.
Show resolved Hide resolved
return nil, fmt.Errorf("failed to post process state. Cause: %w", err)
}

return executor.execResult(ec)
}

Expand Down Expand Up @@ -335,6 +340,20 @@ func (executor *batchExecutor) execRegisteredCallbacks(ec *BatchExecutionContext
return nil
}

func (executor *batchExecutor) postProcessState(ec *BatchExecutionContext) error {
receipts := ec.batchTxResults.Receipts()
valueTransferMessages, err := executor.crossChainProcessors.Local.ExtractOutboundTransfers(ec.ctx, receipts)
if err != nil {
return fmt.Errorf("could not extract outbound transfers. Cause: %w", err)
}

for _, msg := range valueTransferMessages {
ec.stateDB.SubBalance(*executor.crossChainProcessors.Local.GetBusAddress(), uint256.MustFromBig(msg.Amount), tracing.BalanceChangeUnspecified)
}

return nil
}

func (executor *batchExecutor) execOnBlockEndTx(ec *BatchExecutionContext) error {
onBlockTx, err := executor.systemContracts.CreateOnBatchEndTransaction(ec.ctx, ec.stateDB, ec.batchTxResults)
if err != nil && !errors.Is(err, system.ErrNoTransactions) {
Expand Down
Loading